Don't send pins until a subscription is established, since unpin events never come in that case.
This commit is contained in:
2
api.py
2
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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user