1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
module Gitlab
module GithubImport
module Importer
module Events
class ChangedAssignee < BaseImporter
def execute(issue_event)
assignee_id = author_id(issue_event, author_key: :assignee)
author_id = author_id(issue_event, author_key: :actor)
note_body = parse_body(issue_event, assignee_id)
create_note(issue_event, note_body, author_id)
end
private
def create_note(issue_event, note_body, author_id)
Note.create!(
system: true,
noteable_type: issuable_type(issue_event),
noteable_id: issuable_db_id(issue_event),
project: project,
author_id: author_id,
note: note_body,
system_note_metadata: SystemNoteMetadata.new(
{
action: "assignee",
created_at: issue_event.created_at,
updated_at: issue_event.created_at
}
),
created_at: issue_event.created_at,
updated_at: issue_event.created_at
)
end
def parse_body(issue_event, assignee_id)
assignee = User.find(assignee_id).to_reference
Gitlab::I18n.with_default_locale do
if issue_event.event == "unassigned"
"unassigned #{assignee}"
else
"assigned to #{assignee}"
end
end
end
end
end
end
end
end
|