praekelt/vumi — pull request #425 by hodgestar (2012-11-27 23:23:44+00:00)
Title: SMPP can generate events without a user_message_id

SMPP can generate events without a user_message_id. This surprises the message store. The message store can be fixed with a patch like the diff below but I think it would be better if SMPP didn't generate these sorts of events. There's not much that can be done with them except log them anyway.

```diff
diff --git a/vumi/components/message_store.py b/vumi/components/message_store.py
index ce08d84..e17fac2 100644
--- a/vumi/components/message_store.py
+++ b/vumi/components/message_store.py
@@ -13,6 +13,7 @@ from vumi.persist.fields import (VumiMessage, ForeignKey, ListOf, Tag, Dynamic,
Unicode)
from vumi import log
from vumi.components.message_store_cache import MessageStoreCache
+from vumi import log

class Batch(Model):
@@ -211,6 +212,10 @@ class MessageStore(object):
def add_event(self, event):
event_id = event['event_id']
msg_id = event['user_message_id']
+ if msg_id is None:
+ log.error('Cannot store event with None user_message_id: %s' % (event,))
+ return
+
event_record = self.events(event_id, event=event, message=msg_id)
yield event_record.save()
```