article_sender_id.rb 559 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Zendesk::Common::ArticleSenderId < Sequencer::Unit::Common::Provider::Named
  3. uses :user_id
  4. private
  5. def article_sender_id
  6. return article_sender('Customer') if author.role?('Customer')
  7. return article_sender('Agent') if author.role?('Agent')
  8. article_sender('System')
  9. end
  10. def author
  11. @author ||= ::User.find(user_id)
  12. end
  13. def article_sender(name)
  14. ::Ticket::Article::Sender.select(:id).find_by(name: name).id
  15. end
  16. end