diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-03 00:11:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-03 00:11:07 +0300 |
commit | eb1755b2d90efcc161774f66ccd2317ad4c471de (patch) | |
tree | 9404125b4bec27588f2a479470e46a27043d94f0 /app/services/system_hooks_service.rb | |
parent | bf2439c21308c74e437b872180046b39a61734b5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/system_hooks_service.rb')
-rw-r--r-- | app/services/system_hooks_service.rb | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index 5273dedb56f..d854b95cb93 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class SystemHooksService - BUILDER_DRIVEN_EVENT_DATA_AVAILABLE_FOR_CLASSES = [GroupMember, Group].freeze + BUILDER_DRIVEN_EVENT_DATA_AVAILABLE_FOR_CLASSES = [GroupMember, Group, ProjectMember].freeze def execute_hooks_for(model, event) data = build_event_data(model, event) @@ -56,22 +56,13 @@ class SystemHooksService when :failed_login data[:state] = model.state end - when ProjectMember - data.merge!(project_member_data(model)) end data end def build_event_name(model, event) - case model - when ProjectMember - return "user_add_to_team" if event == :create - return "user_remove_from_team" if event == :destroy - return "user_update_for_team" if event == :update - else - "#{model.class.name.downcase}_#{event}" - end + "#{model.class.name.downcase}_#{event}" end def project_data(model) @@ -88,23 +79,6 @@ class SystemHooksService } end - def project_member_data(model) - project = model.project || Project.unscoped.find(model.source_id) - - { - project_name: project.name, - project_path: project.path, - project_path_with_namespace: project.full_path, - project_id: project.id, - user_username: model.user.username, - user_name: model.user.name, - user_email: model.user.email, - user_id: model.user.id, - access_level: model.human_access, - project_visibility: Project.visibility_levels.key(project.visibility_level_value).downcase - } - end - def user_data(model) { name: model.name, @@ -124,6 +98,8 @@ class SystemHooksService Gitlab::HookData::GroupMemberBuilder when Group Gitlab::HookData::GroupBuilder + when ProjectMember + Gitlab::HookData::ProjectMemberBuilder end builder_class.new(model).build(event) |