active.rb 659 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class User::Current::Avatar::Active < BaseQuery
  4. description 'Fetch actively used avatar of the currently logged-in user.'
  5. type Gql::Types::AvatarType, null: true
  6. def self.authorize(_obj, ctx)
  7. ctx.current_user.permissions?('user_preferences.avatar')
  8. end
  9. def resolve(...)
  10. return if context.current_user.image.blank?
  11. Avatar.find_by(
  12. object_lookup_id: ObjectLookup.by_name('User'),
  13. o_id: context.current_user.id,
  14. store_hash: context.current_user.image,
  15. )
  16. end
  17. end
  18. end