Allow subscribe to return events from a subject even when not creating a subscription

This commit is contained in:
Ian Gulliver
2014-06-01 21:14:58 -07:00
parent c004d27e9d
commit 5079aac9a6
3 changed files with 37 additions and 10 deletions

9
api.py
View File

@@ -114,16 +114,17 @@ def SendMessage(google_user, client, instance_id, args):
def Subscribe(google_user, client, instance_id, args):
instance = models.Instance.FromID(instance_id)
subject = models.Subject.FindOrCreate(args['subject'])
messages = args.get('messages', 0)
last_id = args.get('last_id', None)
if not instance or not instance.active:
# Probably a race with the channel opening
return {
'result': 'retry',
'events': subject.GetEvents(messages, last_id),
}
subject = models.Subject.FindOrCreate(args['subject'])
messages = args.get('messages', 0)
last_id = args.get('last_id', None)
try:
return {
'result': 'ok',