2014-09-02 18:07:02 +05:30
|
|
|
module Issues
|
2015-04-26 12:48:37 +05:30
|
|
|
class BaseService < ::IssuableBaseService
|
|
|
|
def hook_data(issue, action)
|
|
|
|
issue_data = issue.to_hook_data(current_user)
|
2016-06-02 11:05:42 +05:30
|
|
|
issue_url = Gitlab::UrlBuilder.build(issue)
|
2014-09-02 18:07:02 +05:30
|
|
|
issue_data[:object_attributes].merge!(url: issue_url, action: action)
|
2015-04-26 12:48:37 +05:30
|
|
|
issue_data
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
private
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def create_assignee_note(issue, old_assignees)
|
|
|
|
SystemNoteService.change_issue_assignees(
|
|
|
|
issue, issue.project, current_user, old_assignees)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def execute_hooks(issue, action = 'open')
|
2016-09-29 09:46:39 +05:30
|
|
|
issue_data = hook_data(issue, action)
|
|
|
|
hooks_scope = issue.confidential? ? :confidential_issue_hooks : :issue_hooks
|
|
|
|
issue.project.execute_hooks(issue_data, hooks_scope)
|
|
|
|
issue.project.execute_services(issue_data, hooks_scope)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def filter_assignee(issuable)
|
|
|
|
return if params[:assignee_ids].blank?
|
|
|
|
|
|
|
|
# The number of assignees is limited by one for GitLab CE
|
|
|
|
params[:assignee_ids] = params[:assignee_ids][0, 1]
|
|
|
|
|
|
|
|
assignee_ids = params[:assignee_ids].select { |assignee_id| assignee_can_read?(issuable, assignee_id) }
|
|
|
|
|
|
|
|
if params[:assignee_ids].map(&:to_s) == [IssuableFinder::NONE]
|
|
|
|
params[:assignee_ids] = []
|
|
|
|
elsif assignee_ids.any?
|
|
|
|
params[:assignee_ids] = assignee_ids
|
|
|
|
else
|
|
|
|
params.delete(:assignee_ids)
|
|
|
|
end
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|