-
-
Notifications
You must be signed in to change notification settings - Fork 202
Open
Description
Bug Report
Describe the Bug:
I'm attempting to use the ephemeral notifier with a bulk delivery method. However, by pairing these 2 together, I noticed the following:
- evaluate_option in the delivery method returns nil (apparently the config in itself is an empty hash)
eventis actually a notification object (which is inconsistent with the other notifiers)
To Reproduce:
- Create a bulk delivery method (I created a slack one to use some custom logic we have, but I guess the regular slack one in the gem should work).
class DeliveryMethods::SlackMessenger < Noticed::BulkDeliveryMethod
required_options :channel_ids, :message_obj
def deliver
channel_ids = evaluate_option(:channel_ids)
message_obj = evaluate_option(:message_obj)
user_channel_ids = Array(event.try(:user_recipients)).map(&:slack_channel_id) # user_recipients is a has_many relation I added to the base ApplicationNotifier class as shortcut to get the users.
(channel_ids + user_channel_ids).flatten.compact.uniq.each do |channel_id|
post_message(channel_id, message_obj)
end
...
end
- Create an ephemeral notifier
class MyEphemeralNotifier < Noticed::Ephemeral
bulk_deliver_by :slack_messenger, class: "DeliveryMethods::SlackMessenger" do |config|
config.message_obj = -> { slack_message_obj }
config.channel_ids = -> { slack_channel_ids }
end
def slack_channel_ids
[]
end
def slack_message_obj
{...}
end
end
Expected Behavior:
Slack notification is delivered and no notification records are stored due to the ephemeral notifier being used.
Actual Behavior:
- Undefined method
user_recipientscalled onMyEphemeralNotifier::Notification message_objandchannel_idsevaluated options return nil
Environment:
- Noticed gem version: 2.8.0
- Ruby version: 3.3.9
- Rails version: 8.1.1
- Operating System: WSL2
Possible Fix:
- This should probably use the notifier/event class instead of the Notification
.perform_later(name, "#{notifier}::Notification", recipient: recipient, params: params) - Regarding the empty config, I'm not sure how that gets pulled.
- Additional examples on how to use the ephemeral class would be helpful
Checklist:
- I have searched for similar issues and couldn't find any
- I have checked the documentation for relevant information
- I have included all the required information
Metadata
Metadata
Assignees
Labels
No labels