debian-mirror-gitlab/lib/gitlab/hook_data/issue_builder.rb

62 lines
1.5 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Gitlab
module HookData
2018-11-18 11:00:15 +05:30
class IssueBuilder < BaseBuilder
2018-03-17 18:26:18 +05:30
SAFE_HOOK_RELATIONS = %i[
assignees
labels
total_time_spent
].freeze
2018-11-20 20:47:30 +05:30
def self.safe_hook_attributes
%i[
assignee_id
author_id
closed_at
confidential
created_at
description
2020-04-22 19:07:51 +05:30
discussion_locked
2018-11-20 20:47:30 +05:30
due_date
id
iid
last_edited_at
last_edited_by_id
milestone_id
moved_to_id
2019-12-04 20:38:33 +05:30
duplicated_to_id
2018-11-20 20:47:30 +05:30
project_id
relative_position
2019-12-21 20:55:43 +05:30
state_id
2018-11-20 20:47:30 +05:30
time_estimate
title
updated_at
updated_by_id
].freeze
end
2018-11-18 11:00:15 +05:30
alias_method :issue, :object
2018-03-17 18:26:18 +05:30
def build
attrs = {
2018-11-20 20:47:30 +05:30
description: absolute_image_urls(issue.description),
url: Gitlab::UrlBuilder.build(issue),
total_time_spent: issue.total_time_spent,
human_total_time_spent: issue.human_total_time_spent,
human_time_estimate: issue.human_time_estimate,
assignee_ids: issue.assignee_ids,
2019-09-04 21:01:54 +05:30
assignee_id: issue.assignee_ids.first, # This key is deprecated
2019-12-21 20:55:43 +05:30
labels: issue.labels_hook_attrs,
state: issue.state
2018-03-17 18:26:18 +05:30
}
2018-11-20 20:47:30 +05:30
issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
2019-07-07 11:18:12 +05:30
.merge!(attrs)
2018-03-17 18:26:18 +05:30
end
end
end
end
2019-12-04 20:38:33 +05:30
Gitlab::HookData::IssueBuilder.prepend_if_ee('EE::Gitlab::HookData::IssueBuilder')