appearance.rb 672 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class User::Current::Appearance < BaseMutation
  4. description 'Update user profile appearance settings'
  5. argument :theme, Gql::Types::Enum::AppearanceThemeType, description: 'Theme to set'
  6. field :success, Boolean, null: false, description: 'Profile appearance settings updated successfully?'
  7. def self.authorize(_obj, ctx)
  8. ctx.current_user.permissions?('user_preferences.appearance')
  9. end
  10. def resolve(theme:)
  11. user = context.current_user
  12. user.preferences['theme'] = theme
  13. user.save!
  14. { success: true }
  15. end
  16. end
  17. end