Private
Public Access
Add the ability to delete a message (#53)
Message.deleted_at has existed since the initial schema but was never wired up -- no WS envelope, no permission check, no frontend concept of it at all. Soft delete, author-only (mirrors the existing edit permission exactly): content and any attached image/file are cleared and the underlying MessageImage/MessageFile row and stored file are actually removed, not just detached, so the message becomes a "This message was deleted" tombstone with nothing left to recover through a stale attachment URL. A deleted message can no longer be edited or reacted to. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,10 @@ async def _message_payload(db: AsyncSession, message: Message, username: str) ->
|
||||
"reactions": [],
|
||||
"created_at": message.created_at.isoformat(),
|
||||
"edited_at": message.edited_at.isoformat() if message.edited_at else None,
|
||||
# Always null here -- a message just being created can't already be
|
||||
# deleted -- but included for wire-format parity with MessageRead
|
||||
# and message_deleted (#53).
|
||||
"deleted_at": None,
|
||||
}
|
||||
|
||||
|
||||
@@ -204,6 +208,16 @@ async def broadcast_message_update(
|
||||
_maybe_fetch_link_preview(broadcaster, room_id, message)
|
||||
|
||||
|
||||
async def broadcast_message_delete(broadcaster: Broadcaster, room_id: uuid.UUID, message_id: uuid.UUID) -> None:
|
||||
# #53: no dispatch_event() call, deliberately -- same scope cut as
|
||||
# broadcast_reaction_update's, and for the same reason (see
|
||||
# backend/README.md): message.deleted isn't an outgoing-webhook event
|
||||
# type here.
|
||||
await broadcaster.publish(
|
||||
room_id, {"type": "message_deleted", "id": str(message_id), "room_id": str(room_id)}
|
||||
)
|
||||
|
||||
|
||||
async def broadcast_reaction_update(
|
||||
broadcaster: Broadcaster,
|
||||
room_id: uuid.UUID,
|
||||
|
||||
Reference in New Issue
Block a user