configs.rb 730 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Ldap::Sources::Configs < Sequencer::Unit::Base
  3. optional :ldap_config
  4. provides :configs
  5. def process
  6. result = []
  7. @ldap_config_set = false
  8. LdapSource.active.find_each do |source|
  9. next if source.preferences.blank?
  10. result << source_config(source)
  11. end
  12. if ldap_config.present? && !@ldap_config_set
  13. result << ldap_config
  14. end
  15. state.provide(:configs, result)
  16. end
  17. def source_config(source)
  18. if ldap_config.present? && ldap_config[:id] == source.id
  19. @ldap_config_set = true
  20. ldap_config
  21. else
  22. source.preferences.merge(id: source.id)
  23. end
  24. end
  25. end