[manual] Handle old and new notify_tornado payloads

This commit must be deployed standalone, before the following commits

(imported from commit bb695cd39f51baacb02fd219329305fabf7c4702)
This commit is contained in:
Leo Franchi 2013-05-24 10:55:05 -04:00 committed by Tim Abbott
parent 9454683108
commit 1d279abdcf
1 changed files with 19 additions and 1 deletions

View File

@ -253,7 +253,25 @@ def process_new_message(data):
message_dict_markdown = message.to_dict(True)
message_dict_no_markdown = message.to_dict(False)
for user_profile_id in data['users']:
user_flags = {}
user_ids = []
users = data.get('users', [])
first = users[0] if len(users) else None
# TODO(leo)
# We can remove this support for old payloads (the elif int case)
# once we have deployed the new format to prod
if type(first) == dict:
# We modified the users list to be a list of {id, flag} maps
for user_data in data['users']:
id = user_data['id']
user_ids.append(id)
user_flags[id] = user_data.get('flags', [])
elif type(first) == int:
user_ids = data['users']
for user_profile_id in user_ids:
user_receive_message(user_profile_id, message)
for client in get_client_descriptors_for_user(user_profile_id):