delete.rb 754 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class OnlineNotification::Delete < BaseMutation
  4. description 'Marks notifications for active user as seen'
  5. argument :online_notification_id, GraphQL::Types::ID, required: true, loads: Gql::Types::OnlineNotificationType, description: 'The unique identifier of the notification which should be deleted.'
  6. field :success, Boolean, null: false, description: 'Was the notification deletion successful?'
  7. def resolve(online_notification:)
  8. online_notification.destroy
  9. { success: true }
  10. end
  11. def authorized?(online_notification:)
  12. Pundit.authorize(context.current_user, online_notification, :destroy?)
  13. end
  14. end
  15. end