Prevent duplicate notifications for the same event
This commit is contained in:
parent
8691a8c85b
commit
4a6e2ea46a
@ -9,7 +9,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, DefaultDict, Dict, List, Optional, Tuple, Union
|
from typing import Any, DefaultDict, Dict, List, Optional, Set, Tuple, Union
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -134,7 +134,8 @@ class Backend:
|
|||||||
|
|
||||||
self.mxc_events: DefaultDict[str, List[Event]] = DefaultDict(list)
|
self.mxc_events: DefaultDict[str, List[Event]] = DefaultDict(list)
|
||||||
|
|
||||||
self.notification_avatar_cache: Dict[str, Path] = {} # {mxc: path}
|
self.notified_events: Set[str] = set() # {event_id}
|
||||||
|
self.notification_avatar_cache: Dict[str, Path] = {} # {mxc: path}
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
@ -2181,12 +2181,16 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
if from_us:
|
if from_us:
|
||||||
return item
|
return item
|
||||||
|
|
||||||
if await self.event_is_past(ev):
|
already_notified = item.event_id in self.backend.notified_events
|
||||||
|
|
||||||
|
if already_notified or await self.event_is_past(ev):
|
||||||
await self.update_account_unread_counts()
|
await self.update_account_unread_counts()
|
||||||
return item
|
return item
|
||||||
|
|
||||||
# Alerts & notifications
|
# Alerts & notifications
|
||||||
|
|
||||||
|
self.backend.notified_events.add(item.event_id)
|
||||||
|
|
||||||
room_item = self.models[self.user_id, "rooms"][room.room_id]
|
room_item = self.models[self.user_id, "rooms"][room.room_id]
|
||||||
|
|
||||||
unread = \
|
unread = \
|
||||||
|
Loading…
Reference in New Issue
Block a user