brack3t / Djrill

[INACTIVE/UNMAINTAINED] Djrill is an email backend and new message class for Django users that want to take advantage of the Mandrill transactional email service from MailChimp.
BSD 3-Clause "New" or "Revised" License
319 stars 64 forks source link

Idea: add mandrill_id as property of EmailMessage in _send() #54

Closed erichennings closed 10 years ago

erichennings commented 10 years ago

I'm interested in getting the _id that Mandrill returns when you call their send api.

I think them returning it is fairly new. Getting this value is useful because you can then directly query the status of that message without using a webhook.

Of course we can't return this value directly from DjrillBackend._send() because Django defines the signature of that method.

As an idea, what about adding either the id or the full response json to the message that was sent as a property, probably prefacing with 'djrill' for the sake of namespacing. It could be done by adding either: message.djrill_mandrill_id = response.json()[0].get('_id', None) or, for the full response (I like this better), message.djrill_mandrill_response = response.json()[0]

just before the final return True in DjrillBackend._send

Then someone who wanted this value could do:

msg = ...
msg.send()
id = msg.djrill_mandrill_response.get('_id', None)

Thoughts? Happy to submit a pull request if this concept makes sense.

--Eric

medmunds commented 10 years ago

I think that's a great idea. Please do submit a pull request.

You probably could just call the attribute mandrill_response. (For better or worse, Djrill has never namespaced the attributes it allows on message objects; it would somehow seem inconsistent to start doing that with a single attribute now.)

Thanks for the suggestion.