diff options
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/ops/chat.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/ops/chat.py | 19 |
1 files changed, 19 insertions, 0 deletions
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} |