2021-04-12 14:12:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module MergeRequests
|
|
|
|
class HandleAssigneesChangeService < MergeRequests::BaseService
|
|
|
|
def async_execute(merge_request, old_assignees, options = {})
|
2021-05-14 02:10:55 -04:00
|
|
|
MergeRequests::HandleAssigneesChangeWorker
|
|
|
|
.perform_async(
|
|
|
|
merge_request.id,
|
|
|
|
current_user.id,
|
|
|
|
old_assignees.map(&:id),
|
2021-05-20 11:10:13 -04:00
|
|
|
options.stringify_keys # see: https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1090
|
2021-05-14 02:10:55 -04:00
|
|
|
)
|
2021-04-12 14:12:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute(merge_request, old_assignees, options = {})
|
|
|
|
create_assignee_note(merge_request, old_assignees)
|
|
|
|
notification_service.async.reassigned_merge_request(merge_request, current_user, old_assignees.to_a)
|
|
|
|
todo_service.reassigned_assignable(merge_request, current_user, old_assignees)
|
|
|
|
|
|
|
|
new_assignees = merge_request.assignees - old_assignees
|
|
|
|
merge_request_activity_counter.track_users_assigned_to_mr(users: new_assignees)
|
|
|
|
merge_request_activity_counter.track_assignees_changed_action(user: current_user)
|
|
|
|
|
|
|
|
execute_assignees_hooks(merge_request, old_assignees) if options[:execute_hooks]
|
2021-12-08 07:13:04 -05:00
|
|
|
|
2022-01-12 10:13:54 -05:00
|
|
|
unless new_assignees.include?(current_user)
|
2022-03-02 04:13:50 -05:00
|
|
|
remove_attention_requested(merge_request)
|
2022-01-12 10:13:54 -05:00
|
|
|
end
|
2021-04-12 14:12:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def execute_assignees_hooks(merge_request, old_assignees)
|
|
|
|
execute_hooks(
|
|
|
|
merge_request,
|
|
|
|
'update',
|
|
|
|
old_associations: { assignees: old_assignees }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
MergeRequests::HandleAssigneesChangeService.prepend_mod_with('MergeRequests::HandleAssigneesChangeService')
|