blob: 00f0f911b0ee284135e82b014aa1f6ab790f212e (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# frozen_string_literal: true
module Integrations
module ChatMessage
class WikiPageMessage < BaseMessage
attr_reader :title
attr_reader :wiki_page_url
attr_reader :action
attr_reader :description
attr_reader :diff_url
def initialize(params)
super
obj_attr = params[:object_attributes]
obj_attr = HashWithIndifferentAccess.new(obj_attr)
@title = obj_attr[:title]
@wiki_page_url = obj_attr[:url]
@description = obj_attr[:message]
@diff_url = obj_attr[:diff_url]
@action =
case obj_attr[:action]
when "create"
"created"
when "update"
"edited"
end
end
def attachments
return description if markdown
description_message
end
def activity
{
title: "#{user_combined_name} #{action} #{wiki_page_link}",
subtitle: "in #{project_link}",
text: title,
image: user_avatar
}
end
private
def message
"#{user_combined_name} #{action} #{wiki_page_link} (#{diff_link}) in #{project_link}: *#{title}*"
end
def description_message
[{ text: format(@description), color: attachment_color }]
end
def diff_link
link('Compare changes', diff_url)
end
def project_link
link(project_name, project_url)
end
def wiki_page_link
link('wiki page', wiki_page_url)
end
end
end
end
|