From 4ae61dc4e1dcca6ae24131fcd9acc55124e3c0af Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Fri, 9 Oct 2026 12:16:51 +0200 Subject: feat: let the operator purge a group's chat (MNP 6.1) Signed chat_purge from the Chat settings deletes every stored message; epoch keys and attachments stay. The ack is broadcast so open chat panels empty. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-node/src/meshbay_node/ops/chat.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'packages/meshbay-node/src/meshbay_node/ops/chat.py') diff --git a/packages/meshbay-node/src/meshbay_node/ops/chat.py b/packages/meshbay-node/src/meshbay_node/ops/chat.py index 539284b..9fc7b94 100644 --- a/packages/meshbay-node/src/meshbay_node/ops/chat.py +++ b/packages/meshbay-node/src/meshbay_node/ops/chat.py @@ -252,3 +252,22 @@ async def prune_chat(state: dict, group_id: str, max_age_days: int) -> dict: group_id[:8], removed) return {"group_id": group_id, "removed": removed, "max_age_days": max_age_days} + + +async def purge_chat(state: dict, group_id: str) -> dict: + """ + Delete every stored message of the group. Epoch keys are kept, as in + `prune_chat`, and attachments too: they are files in a shared folder. + + The replay index goes with the rows, which is harmless: the node takes a + sealed message only from the device that signed it, so the one party able + to send a purged message again is its author. + """ + ctx = _group_ctx(state, group_id) + store = ctx.get("chat_store") + if store is None: + raise OpError("This group has no chat store", status=404) + removed = await store.delete_all() + log.info("Chat purged for group %s: %d message(s) removed", + group_id[:8], removed) + return {"group_id": group_id, "removed": removed} -- cgit v1.2.3