mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
Clean up parsing in process_event and friends.
(imported from commit 408f9171fa481fa678dd6e27ea4cc610add232d5)
This commit is contained in:
@@ -190,16 +190,14 @@ def process_new_message(data):
|
|||||||
continue
|
continue
|
||||||
client.add_event(event)
|
client.add_event(event)
|
||||||
|
|
||||||
def process_event(data):
|
def process_event(event, users):
|
||||||
event = data['event']
|
for user_profile_id in users:
|
||||||
for user_profile_id in data['users']:
|
|
||||||
for client in get_client_descriptors_for_user(user_profile_id):
|
for client in get_client_descriptors_for_user(user_profile_id):
|
||||||
if client.accepts_event(event):
|
if client.accepts_event(event):
|
||||||
client.add_event(event.copy())
|
client.add_event(event.copy())
|
||||||
|
|
||||||
def process_userdata_event(data):
|
def process_userdata_event(raw_event, users):
|
||||||
raw_event = data['event']
|
for user_data in users:
|
||||||
for user_data in data['users']:
|
|
||||||
user_profile_id = user_data['id']
|
user_profile_id = user_data['id']
|
||||||
user_event = raw_event.copy() # shallow, but deep enough for our needs
|
user_event = raw_event.copy() # shallow, but deep enough for our needs
|
||||||
for key in user_data.keys():
|
for key in user_data.keys():
|
||||||
@@ -211,15 +209,14 @@ def process_userdata_event(data):
|
|||||||
client.add_event(user_event)
|
client.add_event(user_event)
|
||||||
|
|
||||||
def process_notification(data):
|
def process_notification(data):
|
||||||
if data['event']['type'] in ["update_message"]:
|
event = data['event']
|
||||||
process_userdata_event(data)
|
users = data['users']
|
||||||
elif 'type' not in data:
|
if event['type'] in ["update_message"]:
|
||||||
# Generic event that doesn't need special handling
|
process_userdata_event(event, users)
|
||||||
process_event(data)
|
elif event['type'] == "message":
|
||||||
elif data['type'] == 'new_message':
|
|
||||||
process_new_message(data)
|
process_new_message(data)
|
||||||
else:
|
else:
|
||||||
raise JsonableError('bad notification type ' + data['type'])
|
process_event(event, users)
|
||||||
|
|
||||||
# Runs in the Django process to send a notification to Tornado.
|
# Runs in the Django process to send a notification to Tornado.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user