From cfae35425017e6560d172878da9fcbee9da2a143 Mon Sep 17 00:00:00 2001 From: Phil Reynolds Date: Mon, 22 Jan 2024 13:06:31 +0000 Subject: [PATCH 01/10] add linebreak to upgrade.md --- UPGRADE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 88bf277a..b94e28a0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -64,8 +64,8 @@ You will need to remove `deliver_by :database` from your notifiers. For clarity, we've renamed `app/notifications` to `app/notifiers`. -Notifiers - the class that delivers notifications -Notification - the database record of the notification +**Notifiers** - the class that delivers notifications
+**Notification** - the database record of the notification We recommend renaming your existing classes to match. You'll also need to update the `type` column on existing notifications when renaming. From 21f27901854814c7a4bb1d9890826eafb854d526 Mon Sep 17 00:00:00 2001 From: Phil Reynolds Date: Mon, 22 Jan 2024 13:10:38 +0000 Subject: [PATCH 02/10] add note about notficiation model extensions to upgrade.md --- UPGRADE.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index b94e28a0..ae9656cb 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -138,6 +138,34 @@ class NewCommentNotifier < Noticed::Event end ``` +#### Notification Model Methods + +In order to extend the Notification model you'll need to use a concern an a to_prepare block: + +```ruby +module NotificationExtensions + extend ActiveSupport::Concern + + included do + scope :filter_by_type, ->(type) { where(type:) } + scope :filter_by_org, ->(organisation_id) { where(organisation_id:) } + scope :exclude_type, ->(type) { where.not(type:) } + + counter_culture :recipient, column_name: "notifications_count" + counter_culture :recipient, column_name: proc { |a| 'unread_notifications_count' if a.read_at.nil? }, + column_names: { Notification.unread => :unread_notifications_count } + end + + def organisation + Organisation.find_by(id: organisation_id) + end +end + +Rails.application.config.to_prepare do + Noticed::Notification.include NotificationExtensions +end +``` + ### Has Noticed Notifications `has_noticed_notifications` has been removed in favor of the `record` polymorphic relationship that can be directly queried with ActiveRecord. You can add the necessary json query to your model(s) to restore the json query if needed. From 93fb569cc5612a1c7952e1739c6ec98845963cc4 Mon Sep 17 00:00:00 2001 From: Phil Reynolds Date: Mon, 22 Jan 2024 13:12:23 +0000 Subject: [PATCH 03/10] add comment about deliver later --- UPGRADE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index ae9656cb..1fb065e9 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -93,6 +93,10 @@ class CommentNotifier < Noticed::Event end ``` +### Deliver Later + +Notifications are always delivered later now. The `.deliver_later` method has been removed. Instead you can just user `.deliver` + ### Required Params `param` and `params` have been renamed to `required_param(s)` to be more clear. From e14957ff7b744c57f4de88f72cf67d416eb614b9 Mon Sep 17 00:00:00 2001 From: Phil Reynolds Date: Mon, 22 Jan 2024 13:14:41 +0000 Subject: [PATCH 04/10] rename format -> json in ios.md --- docs/delivery_methods/ios.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/delivery_methods/ios.md b/docs/delivery_methods/ios.md index 81c86118..de0681da 100644 --- a/docs/delivery_methods/ios.md +++ b/docs/delivery_methods/ios.md @@ -36,7 +36,7 @@ end ## Options -* `format` +* `json` Customize the Apnotic notification object From c1e937e1389057d9b7dcaacb7efdd6b3193661d0 Mon Sep 17 00:00:00 2001 From: Phil Reynolds Date: Mon, 22 Jan 2024 13:16:19 +0000 Subject: [PATCH 05/10] typo --- UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 1fb065e9..d934063f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -201,7 +201,7 @@ model.where("json_extract(params, ?) = ?", "$.#{param_name}", Noticed::Coder.dum model.where(params: {param_name.to_sym => self}) ``` -### Receipient Notifications Association +### Recipient Notifications Association Recipients can be associated with notifications using the following. This is useful for displaying notifications in your UI. From 14082437105f38ea363b968d1cd0b5aa96fd4914 Mon Sep 17 00:00:00 2001 From: Phil Reynolds Date: Mon, 22 Jan 2024 13:19:35 +0000 Subject: [PATCH 06/10] add note about cert_path key change to apns_key --- UPGRADE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index d934063f..57ebc43b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -226,7 +226,8 @@ The `Noticed::NotificationChannel` has been removed and an example channel is pr #### FCM -The `format` option has been renamed to `json`. +The `format` option has been renamed to `json`. +The `cert_path` option has been renamed to `apns_key`. The `device_tokens` option is now required and should return an Array of device tokens. The `invalid_token` option replaces the `cleanup_device_tokens` method for handling invalid/expired tokens. From 9c1ffb28c4f8cd62c7707f7d8f227175e3295816 Mon Sep 17 00:00:00 2001 From: Phil Reynolds Date: Mon, 22 Jan 2024 13:20:26 +0000 Subject: [PATCH 07/10] add additional linebreaks to delivery method changes --- UPGRADE.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 57ebc43b..24a20fbb 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -217,7 +217,7 @@ Options for delivery methods have been renamed for clarity and consistency. #### ActionCable -The `format` option has been renamed to `message`. +The `format` option has been renamed to `message`.
The `Noticed::NotificationChannel` has been removed and an example channel is provided in the [ActionCable docs](docs/delivery_methods/action_cable.md). #### Email Delivery Method @@ -226,15 +226,15 @@ The `Noticed::NotificationChannel` has been removed and an example channel is pr #### FCM -The `format` option has been renamed to `json`. -The `cert_path` option has been renamed to `apns_key`. -The `device_tokens` option is now required and should return an Array of device tokens. +The `format` option has been renamed to `json`.
+The `cert_path` option has been renamed to `apns_key`.
+The `device_tokens` option is now required and should return an Array of device tokens.
The `invalid_token` option replaces the `cleanup_device_tokens` method for handling invalid/expired tokens. #### iOS -The `format` option has been renamed to `json`. -The `device_tokens` option is now required and should return an Array of device tokens. +The `format` option has been renamed to `json`.
+The `device_tokens` option is now required and should return an Array of device tokens.
The `invalid_token` option replaces the `cleanup_device_tokens` method for handling invalid/expired tokens. #### Microsoft Teams @@ -243,15 +243,15 @@ The `format` option has been renamed to `json`. #### Slack -The `format` option has been renamed to `json`. +The `format` option has been renamed to `json`.
The `url` option now defaults to `"https://slack.com/api/chat.postMessage` instead of `Rails.application.credentials.dig(:slack, :notification_url)` #### Twilio Messaging -Twilio has been renamed to `:twilio_messaging` to make room for `:twilio_voice` and other services they may provide in the future. +Twilio has been renamed to `:twilio_messaging` to make room for `:twilio_voice` and other services they may provide in the future.
The `format` option has been renamed to `json`. #### Vonage SMS -Vonage has been renamed to `:vonage_sms` to make room for other Vonage services in the future. +Vonage has been renamed to `:vonage_sms` to make room for other Vonage services in the future.
The `format` option has been renamed to `json` and is now required. From 55ea51edaf9e228cbf1b1562f382c51e5263caec Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Mon, 22 Jan 2024 08:15:31 -0600 Subject: [PATCH 08/10] Update UPGRADE.md --- UPGRADE.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 24a20fbb..af31693e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -64,7 +64,7 @@ You will need to remove `deliver_by :database` from your notifiers. For clarity, we've renamed `app/notifications` to `app/notifiers`. -**Notifiers** - the class that delivers notifications
+**Notifiers** - the class that delivers notifications **Notification** - the database record of the notification We recommend renaming your existing classes to match. You'll also need to update the `type` column on existing notifications when renaming. @@ -217,7 +217,7 @@ Options for delivery methods have been renamed for clarity and consistency. #### ActionCable -The `format` option has been renamed to `message`.
+The `format` option has been renamed to `message`. The `Noticed::NotificationChannel` has been removed and an example channel is provided in the [ActionCable docs](docs/delivery_methods/action_cable.md). #### Email Delivery Method @@ -226,15 +226,15 @@ The `Noticed::NotificationChannel` has been removed and an example channel is pr #### FCM -The `format` option has been renamed to `json`.
-The `cert_path` option has been renamed to `apns_key`.
-The `device_tokens` option is now required and should return an Array of device tokens.
+The `format` option has been renamed to `json`. +The `device_tokens` option is now required and should return an Array of device tokens. The `invalid_token` option replaces the `cleanup_device_tokens` method for handling invalid/expired tokens. #### iOS -The `format` option has been renamed to `json`.
-The `device_tokens` option is now required and should return an Array of device tokens.
+The `cert_path` option has been renamed to `apns_key` and should be given the key and not a path. +The `format` option has been renamed to `json`. +The `device_tokens` option is now required and should return an Array of device tokens. The `invalid_token` option replaces the `cleanup_device_tokens` method for handling invalid/expired tokens. #### Microsoft Teams @@ -243,15 +243,15 @@ The `format` option has been renamed to `json`. #### Slack -The `format` option has been renamed to `json`.
+The `format` option has been renamed to `json`. The `url` option now defaults to `"https://slack.com/api/chat.postMessage` instead of `Rails.application.credentials.dig(:slack, :notification_url)` #### Twilio Messaging -Twilio has been renamed to `:twilio_messaging` to make room for `:twilio_voice` and other services they may provide in the future.
+Twilio has been renamed to `:twilio_messaging` to make room for `:twilio_voice` and other services they may provide in the future. The `format` option has been renamed to `json`. #### Vonage SMS -Vonage has been renamed to `:vonage_sms` to make room for other Vonage services in the future.
+Vonage has been renamed to `:vonage_sms` to make room for other Vonage services in the future. The `format` option has been renamed to `json` and is now required. From c23f063b63cc1b773fd776770a0f9b1cc7139b16 Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Mon, 22 Jan 2024 08:17:22 -0600 Subject: [PATCH 09/10] Update UPGRADE.md --- UPGRADE.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index af31693e..f2c1a9f7 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -151,18 +151,13 @@ module NotificationExtensions extend ActiveSupport::Concern included do + belongs_to :organisation + scope :filter_by_type, ->(type) { where(type:) } - scope :filter_by_org, ->(organisation_id) { where(organisation_id:) } scope :exclude_type, ->(type) { where.not(type:) } - - counter_culture :recipient, column_name: "notifications_count" - counter_culture :recipient, column_name: proc { |a| 'unread_notifications_count' if a.read_at.nil? }, - column_names: { Notification.unread => :unread_notifications_count } end - def organisation - Organisation.find_by(id: organisation_id) - end + # You can also add instance methods here end Rails.application.config.to_prepare do From 3b0337991e54859ba6f33cd53e9a9f827420eaa3 Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Mon, 22 Jan 2024 08:19:40 -0600 Subject: [PATCH 10/10] Update UPGRADE.md --- UPGRADE.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index f2c1a9f7..cec37485 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -144,9 +144,10 @@ end #### Notification Model Methods -In order to extend the Notification model you'll need to use a concern an a to_prepare block: +In order to extend the Noticed models you'll need to use a concern an a to_prepare block: ```ruby +# config/initializers/noticed.rb module NotificationExtensions extend ActiveSupport::Concern @@ -161,6 +162,8 @@ module NotificationExtensions end Rails.application.config.to_prepare do + # You can extend Noticed::Event or Noticed::Notification here + Noticed::Event.include NotificationExtensions Noticed::Notification.include NotificationExtensions end ```