user_group_map.rb 510 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Zendesk::UserGroupMap < Sequencer::Unit::Base
  3. uses :client
  4. provides :user_group_map
  5. def process
  6. state.provide(:user_group_map, mapping)
  7. end
  8. private
  9. def mapping
  10. result = {}
  11. client.group_memberships.all! do |group_membership|
  12. result[ group_membership.user_id ] ||= []
  13. result[ group_membership.user_id ].push(group_membership.group_id)
  14. end
  15. result
  16. end
  17. end