notification_methods
not working when used on ApplicationNotifier
#404
Replies: 2 comments 15 replies
-
Yeah, that's expected since it applies that block immediately to the Notification class under the Notifier. Don't know that there's a good way of doing that but since we didn't intend this I wouldn't consider it a bug. We may want to add support for it, but it's more of a feature add. |
Beta Was this translation helpful? Give feedback.
-
Umm I have some issues with # NewPostNotifier
#
class NewPostNotifier < Noticed::Event
validates :record, presence: true
deliver_by :email do |config|
config.mailer = "NotificationMailer"
config.method = :notify_new_post
config.if = :email_notifications?
end
required_params :discussion, :story
notification_methods do
def message
t(".message", discussion_title: params[:discussion].title)
end
def url
story_discussion_path(params[:story], params[:discussion])
end
end
# @todo save to db if email_notification?
# we send notifications to all participants who have set their preference
# and also to the discussion creator if preference is set
def email_notifications?(notification)
recipient = notification.recipient
# skip when recipient is the post creator
return false if recipient.id == record.user.id
if recipient.id == discussion.user.id # discussion owner
recipient.preference&.notify_new_post_on_discussion
else # any participants in post
recipient.preference&.notify_any_post_in_discussion
end
end
def discussion
params[:discussion]
end
def story
params[:story]
end
end
|
Beta Was this translation helpful? Give feedback.
-
Bug Report
Describe the Bug:
When using
notification_methods
on my notifier, it works:When using on
ApplicationNotifier
(generated automatically) like this:it doesn't, saying:
To Reproduce:
rails generate noticed:notifier NewCommentNotifier
ApplicationNotifier
Environment:
Noticed gem version: 2.1.3
Ruby version: 3.2.2
Rails version: 7.1.3
Operating System: Ubuntu 23.10
[x ] I have searched for similar issues and couldn't find any
[ x] I have checked the documentation for relevant information
[ x] I have included all the required information
Beta Was this translation helpful? Give feedback.
All reactions