Commit 28ab9662 authored by Chantal Rollison's avatar Chantal Rollison Committed by Rémy Coutable

Port of ccr/6274/add_weight_to_payload to CE

parent edf7d1d4
...@@ -28,7 +28,7 @@ module Gitlab ...@@ -28,7 +28,7 @@ module Gitlab
end end
def safe_keys def safe_keys
issuable_builder::SAFE_HOOK_ATTRIBUTES + issuable_builder::SAFE_HOOK_RELATIONS issuable_builder.safe_hook_attributes + issuable_builder::SAFE_HOOK_RELATIONS
end end
private private
......
module Gitlab module Gitlab
module HookData module HookData
class IssueBuilder < BaseBuilder class IssueBuilder < BaseBuilder
SAFE_HOOK_ATTRIBUTES = %i[
assignee_id
author_id
closed_at
confidential
created_at
description
due_date
id
iid
last_edited_at
last_edited_by_id
milestone_id
moved_to_id
project_id
relative_position
state
time_estimate
title
updated_at
updated_by_id
].freeze
SAFE_HOOK_RELATIONS = %i[ SAFE_HOOK_RELATIONS = %i[
assignees assignees
labels labels
total_time_spent total_time_spent
].freeze ].freeze
def self.safe_hook_attributes
%i[
assignee_id
author_id
closed_at
confidential
created_at
description
due_date
id
iid
last_edited_at
last_edited_by_id
milestone_id
moved_to_id
project_id
relative_position
state
time_estimate
title
updated_at
updated_by_id
].freeze
end
alias_method :issue, :object alias_method :issue, :object
def build def build
attrs = { attrs = {
description: absolute_image_urls(issue.description), description: absolute_image_urls(issue.description),
url: Gitlab::UrlBuilder.build(issue), url: Gitlab::UrlBuilder.build(issue),
total_time_spent: issue.total_time_spent, total_time_spent: issue.total_time_spent,
human_total_time_spent: issue.human_total_time_spent, human_total_time_spent: issue.human_total_time_spent,
human_time_estimate: issue.human_time_estimate, human_time_estimate: issue.human_time_estimate,
assignee_ids: issue.assignee_ids, assignee_ids: issue.assignee_ids,
assignee_id: issue.assignee_ids.first # This key is deprecated assignee_id: issue.assignee_ids.first # This key is deprecated
} }
issue.attributes.with_indifferent_access.slice(*SAFE_HOOK_ATTRIBUTES) issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
.merge!(attrs) .merge!(attrs)
end end
end end
end end
......
module Gitlab module Gitlab
module HookData module HookData
class MergeRequestBuilder < BaseBuilder class MergeRequestBuilder < BaseBuilder
SAFE_HOOK_ATTRIBUTES = %i[ def self.safe_hook_attributes
assignee_id %i[
author_id assignee_id
created_at author_id
description created_at
head_pipeline_id description
id head_pipeline_id
iid id
last_edited_at iid
last_edited_by_id last_edited_at
merge_commit_sha last_edited_by_id
merge_error merge_commit_sha
merge_params merge_error
merge_status merge_params
merge_user_id merge_status
merge_when_pipeline_succeeds merge_user_id
milestone_id merge_when_pipeline_succeeds
source_branch milestone_id
source_project_id source_branch
state source_project_id
target_branch state
target_project_id target_branch
time_estimate target_project_id
title time_estimate
updated_at title
updated_by_id updated_at
].freeze updated_by_id
].freeze
end
SAFE_HOOK_RELATIONS = %i[ SAFE_HOOK_RELATIONS = %i[
assignee assignee
...@@ -50,8 +52,8 @@ module Gitlab ...@@ -50,8 +52,8 @@ module Gitlab
human_time_estimate: merge_request.human_time_estimate human_time_estimate: merge_request.human_time_estimate
} }
merge_request.attributes.with_indifferent_access.slice(*SAFE_HOOK_ATTRIBUTES) merge_request.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
.merge!(attrs) .merge!(attrs)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment