realtime(chats): update subscriptions on delete/leave chat actions
All checks were successful
CI / test (push) Successful in 41s
All checks were successful
CI / test (push) Successful in 41s
This commit is contained in:
@@ -19,6 +19,8 @@ from app.chats.schemas import (
|
|||||||
ChatRead,
|
ChatRead,
|
||||||
ChatTitleUpdateRequest,
|
ChatTitleUpdateRequest,
|
||||||
)
|
)
|
||||||
|
from app.chats import repository as chats_repository
|
||||||
|
from app.chats.models import ChatType
|
||||||
from app.chats.service import (
|
from app.chats.service import (
|
||||||
add_chat_member_for_user,
|
add_chat_member_for_user,
|
||||||
ban_chat_member_for_user,
|
ban_chat_member_for_user,
|
||||||
@@ -250,7 +252,19 @@ async def delete_chat(
|
|||||||
db: AsyncSession = Depends(get_db),
|
db: AsyncSession = Depends(get_db),
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
) -> None:
|
) -> None:
|
||||||
|
chat_before_delete = await chats_repository.get_chat_by_id(db, chat_id)
|
||||||
|
delete_for_all = bool(
|
||||||
|
chat_before_delete
|
||||||
|
and (
|
||||||
|
(for_all and not chat_before_delete.is_saved)
|
||||||
|
or (chat_before_delete.type == ChatType.CHANNEL and not chat_before_delete.is_saved)
|
||||||
|
)
|
||||||
|
)
|
||||||
await delete_chat_for_user(db, chat_id=chat_id, user_id=current_user.id, payload=ChatDeleteRequest(for_all=for_all))
|
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:
|
||||||
|
await realtime_gateway.publish_chat_updated(chat_id=chat_id)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/{chat_id}/clear", status_code=status.HTTP_204_NO_CONTENT)
|
@router.post("/{chat_id}/clear", status_code=status.HTTP_204_NO_CONTENT)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Legend:
|
|||||||
31. Privacy - `PARTIAL` (avatar/last-seen/group-invites + PM policy `everyone|contacts|nobody`; policy behavior covered by integration tests, remaining UX/matrix hardening)
|
31. Privacy - `PARTIAL` (avatar/last-seen/group-invites + PM policy `everyone|contacts|nobody`; policy behavior covered by integration tests, remaining UX/matrix hardening)
|
||||||
32. Security - `PARTIAL` (sessions + revoke + 2FA base + access-session visibility; revoke-all now force-disconnects active realtime sessions; 2FA setup now blocked after enable to prevent secret re-issuance; one-time recovery codes added; UX polish ongoing)
|
32. Security - `PARTIAL` (sessions + revoke + 2FA base + access-session visibility; revoke-all now force-disconnects active realtime sessions; 2FA setup now blocked after enable to prevent secret re-issuance; one-time recovery codes added; UX polish ongoing)
|
||||||
33. Realtime Events - `DONE` (connect/disconnect/send/receive/typing/read/delivered/online/offline + chat/message updates)
|
33. Realtime Events - `DONE` (connect/disconnect/send/receive/typing/read/delivered/online/offline + chat/message updates)
|
||||||
34. Sync - `PARTIAL` (cross-device via backend state + realtime; reconciliation improved for loaded chats/messages, chat-info panel now hot-refreshes on `chat_updated`)
|
34. Sync - `PARTIAL` (cross-device via backend state + realtime; reconciliation improved for loaded chats/messages, chat-info panel hot-refreshes on `chat_updated`, delete/leave now updates realtime subscriptions)
|
||||||
35. Additional - `PARTIAL` (drafts/link preview partial/autoload media basic)
|
35. Additional - `PARTIAL` (drafts/link preview partial/autoload media basic)
|
||||||
|
|
||||||
## Current Focus to reach ~80%
|
## Current Focus to reach ~80%
|
||||||
|
|||||||
Reference in New Issue
Block a user