Fix _send inconsistent return format#106
Conversation
|
@nicholasserra : I didn't actually have a real-life case yet where we were running into it. The only reason I noticed it was because the change referenced were breaking our own subclass of the Django backend (where we returned the message object from Reviewing the code, and the newly added tests, I do believe the issue to be fixed. |
| return False, None | ||
| else: | ||
| pm_messages = list(map(self._build_message, messages)) | ||
| pm_messages = [m for m in pm_messages if m] |
There was a problem hiding this comment.
If I send three messages, but one of the messages doesn't have a recipient, then at this stage the pm_messages list will have only two elements.
How is user-code supposed to figure out which of the three messages didn't get send? That is, after this point, there's no difference between:
connection.send_messages([wrong_message, correct_message1, correct_message2])
connection.send_messages([correct_message1, wrong_message, correct_message2])
connection.send_messages([correct_message1, correct_message2, wrong_message])
Would be great if the return value could then be
[None, message_id1, message_id2]
[message_id1, None, message_id2]
[message_id1, message_id2, None]
in these cases?
Refs #105
cc @sjoerdjob-legalsense This solve the issues you're seeing?