pager_tree-integrations 1.1.3 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1232e60d15e2dce895e6cc02e391cb1ec4f0230bcb3642c65f7d2eebaf499666
4
- data.tar.gz: 2b1b7bd0787d7d001127b0391ce02a25bb258e74f86609b128e488e90c9efae4
3
+ metadata.gz: 48ec1c4823f433b06f6d208be7148941457bfd8e62abe4f8bd5daf7ff502cc4a
4
+ data.tar.gz: a13190685045dd29141360b31e232e40a7fe9628ccbdbf707047cfad3a25ef1f
5
5
  SHA512:
6
- metadata.gz: 1d1efc213cc97634b6530653d5f06f14f79f80cf7df72c8f7130e890d968bfe74282cd95142dfc1fa4fbddd70c8634a538354049093f1b1617f9e6cd7f840df1
7
- data.tar.gz: b2c8fea7246e9c3e00671b9fde25d0214fe254a28902056b4393e3623ee416113eb984e1b8d9f8b511c2e0b6f747513c1b3ed6c66f09ac416524c986005cb5ba
6
+ metadata.gz: 95cab16e6759fc7b013e6ab16611d6c1441503b688e8e26a201adcc3647dbfe63e557b6a80b429288278014fcb9bb2993f736de2687ef2fc9b3e039cc325a650
7
+ data.tar.gz: b77187a86484fe1e6e75f42dfb00c33f622d103b8d4956d0603e24869ee672a96c52b0415371f6b35e85d04005e23f8977ae3445107ea6908b507b8d48a4e244
@@ -10,8 +10,8 @@ module PagerTree::Integrations
10
10
  validates :option_dedup_threads, inclusion: {in: [true, false]}
11
11
 
12
12
  after_initialize do
13
- self.option_allow_spam ||= true
14
- self.option_dedup_threads ||= false
13
+ self.option_allow_spam = false if option_allow_spam.nil?
14
+ self.option_dedup_threads = true if option_dedup_threads.nil?
15
15
  end
16
16
 
17
17
  # SPECIAL: override integration endpoint
@@ -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,7 @@
1
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
2
+ <div class="form-group">
3
+ <%= form.label :option_token %>
4
+ <%= form.text_field :option_token, class: "form-control" %>
5
+ <p class="form-hint"><%== t(".option_token_hint_html") %></p>
6
+ </div>
7
+ </div>
@@ -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>
@@ -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":
@@ -1,5 +1,5 @@
1
1
  module PagerTree
2
2
  module Integrations
3
- VERSION = "1.1.3"
3
+ VERSION = "1.1.5"
4
4
  end
5
5
  end
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.3
4
+ version: 1.1.5
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-09-22 00:00:00.000000000 Z
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