File tree Expand file tree Collapse file tree 1 file changed +7
-28
lines changed Expand file tree Collapse file tree 1 file changed +7
-28
lines changed Original file line number Diff line number Diff line change 5555)
5656
5757
58- STATE_EVENT_TYPES_TO_MARK_UNREAD = {
59- EventTypes .Topic ,
60- EventTypes .Name ,
61- EventTypes .RoomAvatar ,
62- EventTypes .Tombstone ,
63- }
64-
65-
6658def _should_count_as_unread (event : EventBase , context : EventContext ) -> bool :
6759 # Exclude rejected and soft-failed events.
6860 if context .rejected or event .internal_metadata .is_soft_failed ():
6961 return False
7062
71- # Exclude notices.
72- if (
73- not event .is_state ()
74- and event .type == EventTypes .Message
75- and event .content .get ("msgtype" ) == "m.notice"
76- ):
77- return False
78-
7963 # Exclude edits.
8064 relates_to = event .content .get ("m.relates_to" , {})
8165 if relates_to .get ("rel_type" ) == RelationTypes .REPLACE :
8266 return False
8367
84- # Mark events that have a non-empty string body as unread.
85- body = event .content .get ("body" )
86- if isinstance (body , str ) and body :
87- return True
88-
89- # Mark some state events as unread.
90- if event .is_state () and event .type in STATE_EVENT_TYPES_TO_MARK_UNREAD :
91- return True
92-
93- # Mark encrypted events as unread.
94- if not event .is_state () and event .type == EventTypes .Encrypted :
95- return True
68+ # Mark encrypted and plain text messages events as unread.
69+ if not event .is_state ():
70+ if event .type == EventTypes .Encrypted :
71+ return True
72+ elif event .type == EventTypes .Message :
73+ body = event .content .get ("body" )
74+ return isinstance (body , str ) and bool (body )
9675
9776 return False
9877
You can’t perform that action at this time.
0 commit comments