noticed 1.2.16 → 1.2.17

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: 3b37e7d17da790342493c2ffc575cc5d013ac156b7ac600fb0022c79bcb034de
4
- data.tar.gz: 87fc46cbf6829e174b0dc6df1751187965e645f7461848469e48a2ea7bcb6a46
3
+ metadata.gz: 5dc2e5f50621a5b5da4f901c472621c2fce03d5f0f4db7c5a00a42de527e3128
4
+ data.tar.gz: 1e07d7ea3599b7999d9a252a062ab38641cf6553c8392bf54d70ec9fbc164050
5
5
  SHA512:
6
- metadata.gz: b9b4db6825f88670f27d768f40724fbd22c2f8e92fc6ce5f3bc32650cc9e77475d3c6eecb51fd7f59b10d70e735f648c92ecdae6f6d4b8ff61ff4b5c39e501d3
7
- data.tar.gz: f474ad70283d4faa9b33bd51346acb64b29a4076b9c9c0ffcff58e60f75d331bc54b162a8e3d77310153d39caf898ac2924b234389b1089b3262b35fa7b48ac3
6
+ metadata.gz: 5f2dc0a1735bea8161241f7b384f722fd0a0d5bf1bac80424d63647d39cf9ef727839f3ba8320474c57da327e381daa46c533a788ca7d3ea1978c5eee10dcbfc
7
+ data.tar.gz: 44eb3c5472b947d416d6f14bb2fa1b6a6d9ed26e853eb5d5ca559c0467c0dea9b83634fb1aac72a691b8fbd7805103e3029562e0800d0f433d2ecd9ab5a4e4d1
data/README.md CHANGED
@@ -12,6 +12,7 @@ Currently, we support these notification delivery methods out of the box:
12
12
  * Email
13
13
  * ActionCable channels
14
14
  * Slack
15
+ * Microsoft Teams
15
16
  * Twilio (SMS)
16
17
  * Vonage / Nexmo (SMS)
17
18
 
@@ -253,6 +254,42 @@ Sends a Slack notification via webhook.
253
254
 
254
255
  Defaults to `Rails.application.credentials.slack[:notification_url]`
255
256
 
257
+ ### Microsoft Teams
258
+
259
+ Sends a Teams notification via webhook.
260
+
261
+ `deliver_by :microsoft_teams`
262
+
263
+ #### Options
264
+
265
+ * `format: :format_for_teams` - *Optional*
266
+
267
+ Use a custom method to define the payload sent to slack. Method should return a Hash.
268
+ Documentation for posting via Webhooks available at: https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook
269
+
270
+ ```ruby
271
+ {
272
+ title: "This is the title for the card",
273
+ text: "This is the body text for the card",
274
+ sections: [{activityTitle: "Section Title", activityText: "Section Text"}],
275
+ "potentialAction": [{
276
+ "@type": "OpenUri",
277
+ name: "Button Text",
278
+ targets: [{
279
+ os: "default",
280
+ uri: "https://example.com/foo/action"
281
+ }]
282
+ }]
283
+
284
+ }
285
+ ```
286
+
287
+ * `url: :url_for_teams_channel`: - *Optional*
288
+
289
+ Use a custom method to retrieve the MS Teams Webhook URL. Method should return a string.
290
+
291
+ Defaults to `Rails.application.credentials.microsoft_teams[:notification_url]`
292
+
256
293
  ### Twilio SMS
257
294
 
258
295
  Sends an SMS notification via Twilio.
@@ -440,10 +477,11 @@ Convert back into a Noticed notification object:
440
477
  @notification.to_notification
441
478
  ```
442
479
 
443
- Mark notification as read:
480
+ Mark notification as read / unread:
444
481
 
445
482
  ```ruby
446
483
  @notification.mark_as_read!
484
+ @notification.mark_as_unread!
447
485
  ```
448
486
 
449
487
  Check if read / unread:
@@ -16,6 +16,7 @@ module Noticed
16
16
  autoload :Database, "noticed/delivery_methods/database"
17
17
  autoload :Email, "noticed/delivery_methods/email"
18
18
  autoload :Slack, "noticed/delivery_methods/slack"
19
+ autoload :MicrosoftTeams, "noticed/delivery_methods/microsoft_teams"
19
20
  autoload :Test, "noticed/delivery_methods/test"
20
21
  autoload :Twilio, "noticed/delivery_methods/twilio"
21
22
  autoload :Vonage, "noticed/delivery_methods/vonage"
@@ -106,7 +106,7 @@ module Noticed
106
106
  if options[:class]
107
107
  options[:class].constantize
108
108
  else
109
- "Noticed::DeliveryMethods::#{name.to_s.classify}".constantize
109
+ "Noticed::DeliveryMethods::#{name.to_s.camelize}".constantize
110
110
  end
111
111
  end
112
112
 
@@ -0,0 +1,32 @@
1
+ module Noticed
2
+ module DeliveryMethods
3
+ class MicrosoftTeams < Base
4
+ def deliver
5
+ post(url, json: format)
6
+ end
7
+
8
+ private
9
+
10
+ def format
11
+ if (method = options[:format])
12
+ notification.send(method)
13
+ else
14
+ {
15
+ title: notification.params[:title],
16
+ text: notification.params[:text],
17
+ sections: notification.params[:sections],
18
+ potentialAction: notification.params[:notification_action]
19
+ }
20
+ end
21
+ end
22
+
23
+ def url
24
+ if (method = options[:url])
25
+ notification.send(method)
26
+ else
27
+ Rails.application.credentials.microsoft_teams[:notification_url]
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -42,6 +42,10 @@ module Noticed
42
42
  update(read_at: Time.current)
43
43
  end
44
44
 
45
+ def mark_as_unread!
46
+ update(read_at: nil)
47
+ end
48
+
45
49
  def unread?
46
50
  !read?
47
51
  end
@@ -1,3 +1,3 @@
1
1
  module Noticed
2
- VERSION = "1.2.16"
2
+ VERSION = "1.2.17"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noticed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.16
4
+ version: 1.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-16 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -104,6 +104,7 @@ files:
104
104
  - lib/noticed/delivery_methods/base.rb
105
105
  - lib/noticed/delivery_methods/database.rb
106
106
  - lib/noticed/delivery_methods/email.rb
107
+ - lib/noticed/delivery_methods/microsoft_teams.rb
107
108
  - lib/noticed/delivery_methods/slack.rb
108
109
  - lib/noticed/delivery_methods/test.rb
109
110
  - lib/noticed/delivery_methods/twilio.rb