realtime: emit and handle chat_deleted for full chat removals
All checks were successful
CI / test (push) Successful in 38s
All checks were successful
CI / test (push) Successful in 38s
This commit is contained in:
@@ -263,7 +263,9 @@ async def delete_chat(
|
||||
await delete_chat_for_user(db, chat_id=chat_id, user_id=current_user.id, payload=ChatDeleteRequest(for_all=for_all))
|
||||
if chat_before_delete and not chat_before_delete.is_saved:
|
||||
realtime_gateway.remove_chat_subscription(chat_id=chat_id, user_id=current_user.id)
|
||||
if not delete_for_all:
|
||||
if delete_for_all:
|
||||
await realtime_gateway.publish_chat_deleted(chat_id=chat_id)
|
||||
else:
|
||||
await realtime_gateway.publish_chat_updated(chat_id=chat_id)
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ RealtimeEventName = Literal[
|
||||
"user_online",
|
||||
"user_offline",
|
||||
"chat_updated",
|
||||
"chat_deleted",
|
||||
"pong",
|
||||
"error",
|
||||
]
|
||||
|
||||
@@ -162,6 +162,13 @@ class RealtimeGateway:
|
||||
payload={"chat_id": chat_id},
|
||||
)
|
||||
|
||||
async def publish_chat_deleted(self, *, chat_id: int) -> None:
|
||||
await self._publish_chat_event(
|
||||
chat_id,
|
||||
event="chat_deleted",
|
||||
payload={"chat_id": chat_id},
|
||||
)
|
||||
|
||||
async def disconnect_user(self, user_id: int, *, code: int = 4401, reason: str = "Session revoked") -> None:
|
||||
user_connections = self._connections.get(user_id, {})
|
||||
if not user_connections:
|
||||
|
||||
Reference in New Issue
Block a user