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

56 lines
1.3 KiB
Ruby
Raw Normal View History

2019-02-13 22:33:31 +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
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
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,
assignee_id: issue.assignee_ids.first # This key is deprecated
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)
.merge!(attrs)
2018-03-17 18:26:18 +05:30
end
end
end
end