Store room member read markers in model
This commit is contained in:
parent
160ce2643e
commit
7b5aa8ffe1
|
@ -158,6 +158,8 @@ class Member(ModelItem):
|
||||||
power_level: int = 0
|
power_level: int = 0
|
||||||
invited: bool = False
|
invited: bool = False
|
||||||
profile_updated: datetime = ZeroDate
|
profile_updated: datetime = ZeroDate
|
||||||
|
last_read_event: str = ""
|
||||||
|
last_read_at: datetime = ZeroDate
|
||||||
|
|
||||||
def __lt__(self, other: "Member") -> bool:
|
def __lt__(self, other: "Member") -> bool:
|
||||||
"""Sort by power level, then by display name/user ID."""
|
"""Sort by power level, then by display name/user ID."""
|
||||||
|
|
|
@ -537,3 +537,20 @@ class NioCallbacks:
|
||||||
room.user_name(user_id) or user_id for user_id in ev.users
|
room.user_name(user_id) or user_id for user_id in ev.users
|
||||||
if user_id not in self.client.backend.clients
|
if user_id not in self.client.backend.clients
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def onReceiptEvent(
|
||||||
|
self, room: nio.MatrixRoom, ev: nio.ReceiptEvent,
|
||||||
|
) -> None:
|
||||||
|
model = self.models[self.user_id, room.room_id, "members"]
|
||||||
|
|
||||||
|
for receipt in ev.receipts:
|
||||||
|
if receipt.receipt_type != "m.read":
|
||||||
|
continue
|
||||||
|
|
||||||
|
member = model.get(receipt.user_id)
|
||||||
|
|
||||||
|
if member:
|
||||||
|
member.last_read_event = receipt.event_id
|
||||||
|
timestamp = receipt.timestamp / 1000
|
||||||
|
member.last_read_at = datetime.fromtimestamp(timestamp)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user