Skip to content

Commit 93b916d

Browse files
committed
Don't set empty reactions for deleted messages
It can never be anything other than `{}` because we don't actually fetch them from the database, but also isn't useful at all.
1 parent 4026da2 commit 93b916d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sogs/model/room.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,14 @@ def get_messages_for(
713713
reacts = self.get_reactions(
714714
# Fetch reactions for messages, but skip deleted messages (that have data set to an
715715
# explicit None) since we already know they don't have reactions.
716-
[x['id'] for x in msgs if not ('data' in x and x['data'] is None)],
716+
[x['id'] for x in msgs if 'data' not in x or x['data'] is not None],
717717
user,
718718
reactor_limit=reactor_limit,
719719
session_ids=True,
720720
)
721721
for msg in msgs:
722-
msg['reactions'] = reacts.get(msg['id'], {})
722+
if 'data' not in msg or msg['data'] is not None:
723+
msg['reactions'] = reacts.get(msg['id'], {})
723724

724725
return msgs
725726

tests/test_reactions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ def test_reactions(client, room, room2, user, user2, mod, admin, global_mod, glo
259259
'deleted': True,
260260
'seqno': seqno,
261261
'session_id': user.session_id,
262-
'reactions': {},
263262
}
264263

265264

0 commit comments

Comments
 (0)