Closed soulnafein closed 10 years ago
Are you looking for sender_email
? Don't have a from_email accessor defined on the decorator at the moment.
# Returns the email (String) of the sender.
# Applicable events: inbound
def sender_email
msg['from_email']
end
@soulnafein did that help/did you fix the error? I'm going to close the issue, but just reply/re-open if there's more
Actually, still having the problem!
I answer you: we use sender_email accessor
Very strange. I checked again, and the Mandril::Rails code never tries to call a method called 'from_email'. Can you grep your sources for 'from_email' .. something must be trying to call it!
OK, the callstack is wrong, the problem is that we get a nil message_body, try running this spec with that breaking fixture. Hope the spec is correct! I never used this syntax.
describe "#message_body" do let(:raw_event) { webhook_example_event('inbound_breaking') } let(:event_payload) { Mandrill::WebHook::EventDecorator[raw_event] } subject { event_payload.message_body } describe "Crash test" do it { should_not be_nil } end end
I just added some tests for a case when msg is not present in the webhook post (although this should never happen?). Can't make it break through.
Can you post/push/email me your 'inbound_breaking' payload? Does it look legit according to the Mandrill docs?
ahah. I added the example you posted earlier and discovered the issue is that if you just ask for EventDecorator#message_body (without specifying the format you want), it will try and return the text body content. But the example you have here is a message with HTML-only. So unless you ask for message_body(:html), it will be nil.
I've just updated the behaviour of message_body:
# Returns the +format+ (:text,:html,:raw) message body.
# If +format+ is not specified, it will return the first available message content in order: text, html, raw.
# Applicable events: inbound
def message_body(format=nil)
PS: that's now in gem version 1.0.1
Great, so you also released a new gem version? Thanks!
I confirm it's fixed also on our application after updating the gem
Exception backtrace
Webhook Payload (redacted)