out_of_office.rb 769 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::User::OutOfOffice < Service::Base
  3. attr_reader :user, :enabled, :start_at, :end_at, :replacement, :text
  4. def initialize(user, enabled:, start_at: nil, end_at: nil, replacement: nil, text: nil)
  5. super()
  6. @user = user
  7. @enabled = enabled
  8. @start_at = start_at
  9. @end_at = end_at
  10. @replacement = replacement
  11. @text = text
  12. end
  13. def execute
  14. user.out_of_office = enabled
  15. user.out_of_office_start_at = start_at
  16. user.out_of_office_end_at = end_at
  17. user.out_of_office_replacement = replacement
  18. user.preferences[:out_of_office_text] = text
  19. user.save!
  20. end
  21. end