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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
1.9 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
2022-05-07 20:08:51 +05:30
def self.safe_hook_relations
%i[
assignees
labels
total_time_spent
time_change
severity
escalation_status
].freeze
end
2018-03-17 18:26:18 +05:30
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,
2021-09-04 01:27:46 +05:30
time_change: issue.time_change,
2018-11-20 20:47:30 +05:30
human_total_time_spent: issue.human_total_time_spent,
2021-09-04 01:27:46 +05:30
human_time_change: issue.human_time_change,
2018-11-20 20:47:30 +05:30
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,
2021-09-30 23:02:18 +05:30
state: issue.state,
severity: issue.severity
2018-03-17 18:26:18 +05:30
}
2022-05-07 20:08:51 +05:30
if issue.supports_escalation? && issue.escalation_status
attrs[:escalation_status] = issue.escalation_status.status_name
end
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
2021-06-08 01:23:25 +05:30
Gitlab::HookData::IssueBuilder.prepend_mod_with('Gitlab::HookData::IssueBuilder')