mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
Send UserMessage flags for update_message events.
When we edit a message, send out UserMessage flags to the recipients. This sets the stage for making sure that changes related to user-specific alert words or mentions get sent out to users. (imported from commit bce1de19acef44b5e106352f261203352ece02b9)
This commit is contained in:
committed by
Waseem Daher
parent
175aeef09a
commit
0326fa92b4
@@ -1548,6 +1548,8 @@ def do_update_message(user_profile, message_id, subject, propagate_mode, content
|
||||
if 'prev_rendered_content' in old_edit_history_event:
|
||||
first_rendered_content = old_edit_history_event['prev_rendered_content']
|
||||
|
||||
ums = UserMessage.objects.filter(message=message_id)
|
||||
|
||||
if content is not None:
|
||||
if len(content.strip()) == 0:
|
||||
content = "(deleted)"
|
||||
@@ -1637,8 +1639,12 @@ def do_update_message(user_profile, message_id, subject, propagate_mode, content
|
||||
(stringify_message_dict(changed_message.to_dict_uncached(apply_markdown=False)),)
|
||||
cache_set_many(items_for_memcached)
|
||||
|
||||
recipients = [um.user_profile_id for um in UserMessage.objects.filter(message=message_id)]
|
||||
notice = dict(event=event, users=recipients)
|
||||
def user_info(um):
|
||||
return {
|
||||
'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)
|
||||
|
||||
def encode_email_address(stream):
|
||||
|
||||
@@ -234,12 +234,25 @@ 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']
|
||||
|
||||
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:
|
||||
# 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)
|
||||
elif data['type'] == 'pointer_update':
|
||||
update_pointer(data['user'], data['new_pointer'])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user