deactivate.rb 744 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer
  3. class Unit
  4. module Import
  5. module Ldap
  6. module Sources
  7. module Lost
  8. class Deactivate < Sequencer::Unit::Base
  9. uses :dry_run, :lost_ids
  10. def process
  11. return if dry_run
  12. # Why not use `#update_all`?
  13. # It bypasses validations/callbacks
  14. # (which are used to send notifications to the client)
  15. ::User.where(id: lost_ids).find_each do |user|
  16. user.update!(active: false, updated_by_id: 1)
  17. end
  18. end
  19. end
  20. end
  21. end
  22. end
  23. end
  24. end
  25. end