Closed pacMakaveli closed 1 year ago
Correct, Twilio won't look for a message
method. It just uses a message in the params
. https://github.com/excid3/noticed/blob/master/lib/noticed/delivery_methods/twilio.rb#L10-L20
I like the idea of calling a message
method if it's defined and updating the delivery methods to call that and fallback to a message
in params. That would be useful for I18n messages.
PRs welcome.
@excid3 cool! I'll work on it at some point this week.
Chiming in my support for this. When the documented idiomatic way to construct messages for notifications is to have a message
method on the Notification
, I found this default behavior to be unintuitive.
Easy override for anyone else coming along: use the format
option as in:
deliver_by :twilio, credentials: :get_twilio_credentials, format: :twilio_formatted, debug: true
def twilio_formatted
{
From: get_twilio_credentials[:phone_number],
To: recipient.phone_number,
Body: message
}
end
Hi guys,
I do apologise if this has been raised before. I could only find https://github.com/excid3/noticed/issues/26 that relates to my problem, but it doesn't fix it.
Maybe I'm not understanding the documentation
My understanding is that by creating
Twillio should pick that message. It doesn't. Looking at the code https://github.com/excid3/noticed/blob/master/lib/noticed/delivery_methods/twilio.rb#L17 I can't see where Noticed tries to call that method at all and instead its looking at
notification.params[:message]
I can fix this by doing either:
Body: notification.params[:message] || notification.message
or passing another value to:
::RefreshErrorNotification.with(resource: resource, error: e.to_s).deliver(user.partner)
ofmessage: "my twillio message here"
I personally would've thought that Noticed should automatically call the message method first and perhaps fallback to the message param or check if there is a param of message and then fallback to the message.
Am I doing something wrong?