pager_tree-integrations 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/pager_tree/integrations/slack/webhook/v3.rb +65 -0
- data/app/views/pager_tree/integrations/slack/webhook/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/slack/webhook/v3/_show_options.html.erb +12 -0
- data/config/locales/en.yml +7 -0
- data/lib/pager_tree/integrations/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1abea82b9a7e579d86fce8fc0554d8c5a902e302505bf9e2afa3364592acb33
|
4
|
+
data.tar.gz: da59644ea1421b1699eb2ff238a12220d1ad198f9664f85a349f2c96681fa66d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e778d7bee5f69a0cef43dc32a72a39f24fc35d59b5af0b6ce2fda64560fc1c7ac6ced2d4027e66d26476227d326aebc56dbdeadaf36e79e282aa98ba19d396a
|
7
|
+
data.tar.gz: d499cc390b6bd4f636da0fe8302ba9c4aa2c7beebc5df51760df6ed42b01684bc788072f881c2e49e23da4d4f3bfa25e904088274cab67f1fa5a19063ecaecd6
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Slack::Webhook::V3 < Integration
|
3
|
+
OPTIONS = [
|
4
|
+
{key: :token, type: :string, default: nil}
|
5
|
+
]
|
6
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
7
|
+
|
8
|
+
after_initialize do
|
9
|
+
end
|
10
|
+
|
11
|
+
def adapter_should_block_incoming?(request)
|
12
|
+
option_token.present? && (request.params["token"] != option_token)
|
13
|
+
end
|
14
|
+
|
15
|
+
def adapter_supports_incoming?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def adapter_supports_outgoing?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def adapter_incoming_can_defer?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def adapter_thirdparty_id
|
28
|
+
[adapter_incoming_request_params.dig("channel_id"), adapter_incoming_request_params.dig("timestamp")].join(".")
|
29
|
+
end
|
30
|
+
|
31
|
+
def adapter_action
|
32
|
+
:create
|
33
|
+
end
|
34
|
+
|
35
|
+
def adapter_process_create
|
36
|
+
Alert.new(
|
37
|
+
title: _title,
|
38
|
+
urgency: _urgency,
|
39
|
+
thirdparty_id: adapter_thirdparty_id,
|
40
|
+
dedup_keys: [],
|
41
|
+
additional_data: _additional_datums
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def _title
|
48
|
+
adapter_incoming_request_params.dig("text")
|
49
|
+
end
|
50
|
+
|
51
|
+
def _urgency
|
52
|
+
text = adapter_incoming_request_params.dig("text")&.downcase
|
53
|
+
matches = /(?<urgency>low|medium|high|critical)/.match(text)
|
54
|
+
matches ? matches[:urgency].to_sym : urgency
|
55
|
+
end
|
56
|
+
|
57
|
+
def _additional_datums
|
58
|
+
[
|
59
|
+
AdditionalDatum.new(format: "text", label: "Trigger", value: adapter_incoming_request_params.dig("trigger_word")),
|
60
|
+
AdditionalDatum.new(format: "text", label: "Channel", value: adapter_incoming_request_params.dig("channel")),
|
61
|
+
AdditionalDatum.new(format: "text", label: "User", value: adapter_incoming_request_params.dig("user_name"))
|
62
|
+
]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="sm:col-span-2">
|
2
|
+
<dt class="text-sm font-medium text-gray-500">
|
3
|
+
<%= t("activerecord.attributes.pager_tree/integrations/slack/webhook/v3.option_token") %>
|
4
|
+
</dt>
|
5
|
+
<dd class="mt-1 text-sm text-gray-900">
|
6
|
+
<div class="flex items-center gap-2">
|
7
|
+
<p class="text-sm truncate">
|
8
|
+
<%= mask integration.option_token %>
|
9
|
+
</p>
|
10
|
+
</div>
|
11
|
+
</dd>
|
12
|
+
</div>
|
data/config/locales/en.yml
CHANGED
@@ -79,6 +79,11 @@ en:
|
|
79
79
|
v3:
|
80
80
|
form_options:
|
81
81
|
option_resolve_warn_hint_html: "Resolve the alert when <code>'check_result' === 'WARNING'</code>"
|
82
|
+
slack:
|
83
|
+
webhook:
|
84
|
+
v3:
|
85
|
+
form_options:
|
86
|
+
option_token_hint_html: "The token can be used to authenticate requests from Slack servers (optional)"
|
82
87
|
webhook:
|
83
88
|
v3:
|
84
89
|
form_options:
|
@@ -143,6 +148,8 @@ en:
|
|
143
148
|
option_force_input: "Force Caller Input"
|
144
149
|
option_record: "Voicemail"
|
145
150
|
option_record_emails_list: "Voicemail Emails"
|
151
|
+
"pager_tree/integrations/slack/webhook/v3":
|
152
|
+
option_token: "Slack Token"
|
146
153
|
"pager_tree/integrations/server_guard24/v3":
|
147
154
|
option_resolve_warn: "Resolve on Warning"
|
148
155
|
"pager_tree/integrations/webhook/v3":
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pager_tree-integrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- app/models/pager_tree/integrations/prtg/v3.rb
|
129
129
|
- app/models/pager_tree/integrations/server_guard24/v3.rb
|
130
130
|
- app/models/pager_tree/integrations/site24x7/v3.rb
|
131
|
+
- app/models/pager_tree/integrations/slack/webhook/v3.rb
|
131
132
|
- app/models/pager_tree/integrations/solar_winds/v3.rb
|
132
133
|
- app/models/pager_tree/integrations/stackdriver/v3.rb
|
133
134
|
- app/models/pager_tree/integrations/status_cake/v3.rb
|
@@ -210,6 +211,8 @@ files:
|
|
210
211
|
- app/views/pager_tree/integrations/server_guard24/v3/_show_options.html.erb
|
211
212
|
- app/views/pager_tree/integrations/site24x7/v3/_form_options.html.erb
|
212
213
|
- app/views/pager_tree/integrations/site24x7/v3/_show_options.html.erb
|
214
|
+
- app/views/pager_tree/integrations/slack/webhook/v3/_form_options.html.erb
|
215
|
+
- app/views/pager_tree/integrations/slack/webhook/v3/_show_options.html.erb
|
213
216
|
- app/views/pager_tree/integrations/solar_winds/v3/_form_options.html.erb
|
214
217
|
- app/views/pager_tree/integrations/solar_winds/v3/_show_options.html.erb
|
215
218
|
- app/views/pager_tree/integrations/stackdriver/v3/_form_options.html.erb
|