messaging: owners can block a conversation

A blocked thread key is dropped unread (not announced, not counted against
the daily new-conversation limit). API, UI button with confirmation, and a
list with unblock.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-18 20:50:38 +01:00
co-authored by Claude Sonnet 5.5
parent a54094ea35
commit 13c82f8d59
14 changed files with 433 additions and 3 deletions
+25
View File
@@ -18,6 +18,7 @@ function fakeNode() {
const s = {
token: TOKEN,
calls: [] as { method: string; path: string; body: string; auth: string }[],
blocked: [] as { listing: string; thread: string; blocked_at: number }[],
address: { address: "Musterweg 7, 22765 Hamburg", phone: "+49 40 1" } as Address | null,
mine: [
{ id: L1, title: "Helle Wohnung", kind: "rent", price: { amount_cents: 115000, currency: "EUR", period: "month" }, expires_at: NOW + 86400 * 30, threads: 3, needs_reply: 1, hidden: 1, address_saved: true },
@@ -46,6 +47,13 @@ function fakeNode() {
if (regions.includes("zzz")) return { status: 400, body: { error: `"zzz" is not a region: use 3 geohash characters` } };
return { status: 200, body: { regions } };
}
if (r.path === "/api/v1/blocked") return { status: 200, body: s.blocked };
const bl = /^\/api\/v1\/inbox\/([0-9a-f]{32})\/([0-9a-f]{64})\/block$/.exec(r.path);
if (bl) {
if (r.method === "DELETE") s.blocked = s.blocked.filter((b) => b.thread !== bl[2]);
else s.blocked.push({ listing: bl[1]!, thread: bl[2]!, blocked_at: NOW });
return { status: 204 };
}
if (r.path === "/api/v1/inbox") return { status: 200, body: s.threads.filter((t) => t.listing === r.query.get("listing")) };
const th = /^\/api\/v1\/inbox\/([0-9a-f]{32})\/([0-9a-f]{64})$/.exec(r.path);
if (th) {
@@ -329,6 +337,23 @@ test("deleting a conversation asks first, then goes back to the requests", async
assert.equal(node.s.calls.filter((c) => c.method === "DELETE")[0]!.path, `/api/v1/inbox/${L1}/${T_LINK}`);
});
test("blocking asks first, goes back to the requests, and can be undone", async () => {
open(`#/login/${TOKEN}`);
await page!.waitFor(() => qa(".pane-listings .ocard").length === 2, "the listings");
page!.window.location.hash = `#/mine/${L1}/${T_LINK}`;
await page!.waitFor(() => button("Block") !== undefined, "the block button");
button("Block")!.click();
assert.equal(node.s.blocked.length, 0, "nothing is blocked by one click");
button("Yes, block")!.click();
await page!.waitFor(() => page!.window.location.hash === `#/mine/${L1}`, "back to the requests");
assert.equal(node.s.blocked[0]!.thread, T_LINK);
await page!.waitFor(() => text().includes("Blocked (1)"), "the blocked list");
button("Unblock")!.click();
await page!.waitFor(() => node.s.blocked.length === 0, "the block lifted");
});
test("a token that stops working sends the owner back to sign in", async () => {
open(`#/login/${TOKEN}`);
await page!.waitFor(() => qa(".pane-listings .ocard").length === 2, "the listings");