mirror of https://github.com/zulip/zulip.git
Switch update_message to a generic event type.
(imported from commit db3c4d2326727ca05d25ab43ebc061d3e5cd0630)
This commit is contained in:
parent
167b883c38
commit
1cc3a6a903
|
@ -1744,8 +1744,7 @@ def do_update_message(user_profile, message_id, subject, propagate_mode, content
|
|||
'id': um.user_profile_id,
|
||||
'flags': um.flags_list()
|
||||
}
|
||||
notice = dict(event=event, users=map(user_info, ums), type='update_message')
|
||||
tornado_callbacks.send_notification(notice)
|
||||
send_event(event, map(user_info, ums))
|
||||
|
||||
def encode_email_address(stream):
|
||||
return encode_email_address_helper(stream.name, stream.email_token)
|
||||
|
|
|
@ -197,25 +197,27 @@ def process_event(data):
|
|||
if client.accepts_event(event):
|
||||
client.add_event(event.copy())
|
||||
|
||||
def process_update_message(data):
|
||||
event = data['event']
|
||||
for user in data['users']:
|
||||
user_profile_id = user['id']
|
||||
user_event = event.copy() # shallow, but deep enough for our needs
|
||||
user_event['flags'] = user['flags']
|
||||
def process_userdata_event(data):
|
||||
raw_event = data['event']
|
||||
for user_data in data['users']:
|
||||
user_profile_id = user_data['id']
|
||||
user_event = raw_event.copy() # shallow, but deep enough for our needs
|
||||
for key in user_data.keys():
|
||||
if key != "id":
|
||||
user_event[key] = user_data[key]
|
||||
|
||||
for client in get_client_descriptors_for_user(user_profile_id):
|
||||
if client.accepts_event(user_event):
|
||||
client.add_event(user_event)
|
||||
|
||||
def process_notification(data):
|
||||
if 'type' not in data:
|
||||
if data['event']['type'] in ["update_message"]:
|
||||
process_userdata_event(data)
|
||||
elif 'type' not in data:
|
||||
# Generic event that doesn't need special handling
|
||||
process_event(data)
|
||||
elif data['type'] == 'new_message':
|
||||
process_new_message(data)
|
||||
elif data['type'] == 'update_message':
|
||||
process_update_message(data)
|
||||
else:
|
||||
raise JsonableError('bad notification type ' + data['type'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue