From 3995a4d0d96e0aec8b9765116fd787aca108dc01 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 7 Jun 2015 14:16:54 -0700 Subject: [PATCH] Don't send pins until a subscription is established, since unpin events never come in that case. --- api.py | 2 +- clients/c/cosmopolite.c | 4 ---- lib/models.py | 6 ++++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api.py b/api.py index 0ea9db2..1bf6057 100644 --- a/api.py +++ b/api.py @@ -137,7 +137,7 @@ def Subscribe(google_user, client, client_address, instance_id, args): # Probably a race with the channel opening return { 'result': 'retry', - 'events': subject.GetEvents(messages, last_id, args['subject']), + 'events': subject.GetEvents(messages, last_id, args['subject'], pins=False), } return { diff --git a/clients/c/cosmopolite.c b/clients/c/cosmopolite.c index 3be7842..e2383d0 100644 --- a/clients/c/cosmopolite.c +++ b/clients/c/cosmopolite.c @@ -237,14 +237,10 @@ static void cosmo_handle_event(cosmo *instance, json_t *event) { const char *event_type = json_string_value(json_object_get(event, "event_type")); if (strcmp(event_type, "message") == 0) { cosmo_handle_message(instance, event); - /* - // This can all come back once we have channel support. } else if (strcmp(event_type, "pin") == 0) { cosmo_handle_pin(instance, event); - // unpin never fires when we're just polling } else if (strcmp(event_type, "unpin") == 0) { cosmo_handle_unpin(instance, event); - */ } else { fprintf(stderr, "unknown event type: %s\n", event_type); } diff --git a/lib/models.py b/lib/models.py index 2aaf5d6..686a760 100644 --- a/lib/models.py +++ b/lib/models.py @@ -365,8 +365,10 @@ class Subject(db.Model): for event in events] @db.transactional() - def GetEvents(self, messages, last_id, request): - events = [m.ToEvent() for m in self.GetPins()] + def GetEvents(self, messages, last_id, request, pins=True): + events = [] + if pins: + events.extend(m.ToEvent() for m in self.GetPins()) if messages: events.extend(m.ToEvent() for m in self.GetRecentMessages(messages)) if last_id is not None: