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
+10
View File
@@ -199,6 +199,11 @@ const de = {
"own.delete": "Unterhaltung löschen",
"own.deleteSure": "Wirklich löschen? Sie wird von deinem Knoten entfernt.",
"own.deleteYes": "Ja, löschen",
"own.block": "Blockieren",
"own.blockSure": "Blockieren? Die Unterhaltung wird gelöscht und weitere Nachrichten dieser Person werden ungelesen verworfen. Sie erfährt davon nichts.",
"own.blockYes": "Ja, blockieren",
"own.blocked": "Blockiert ({n})",
"own.unblock": "Freigeben",
"own.sheetTitle": "Adresse freigeben",
"own.sheetHelp":
"Eine signierte Nachricht, nur für diese Person sichtbar. Ihr Bildschirm blendet sie nach dem Datum aus. Sie könnte sie trotzdem kopiert haben.",
@@ -476,6 +481,11 @@ const en: Record<keyof typeof de, string> = {
"own.delete": "Delete conversation",
"own.deleteSure": "Really delete? It is removed from your node.",
"own.deleteYes": "Yes, delete",
"own.block": "Block",
"own.blockSure": "Block? The conversation is deleted and anything more from this person is dropped unread. They are not told.",
"own.blockYes": "Yes, block",
"own.blocked": "Blocked ({n})",
"own.unblock": "Unblock",
"own.sheetTitle": "Release address",
"own.sheetHelp":
"A signed message, visible only to this person. Their screen hides it after the date. They could still have copied it.",
+41
View File
@@ -111,6 +111,7 @@ export async function showOwner(listingId?: string, thread?: string): Promise<vo
addr!.root,
chips,
reqBox,
blockedList(listingId, () => void refresh()),
h("p", { class: "muted small" }, t("own.limitNote")),
]
: [h("p", { class: "muted pick" }, t("own.pickListing"))],
@@ -132,6 +133,7 @@ export async function showOwner(listingId?: string, thread?: string): Promise<vo
addressHint,
composer(listingId, thread, () => void refresh(), (opener) => openSheet(listingId, thread, opener, () => void refresh())),
deleteControl(listingId, thread),
blockControl(listingId, thread),
]);
} else {
threadPane.append(h("p", { class: "muted pick" }, listingId ? t("own.pickRequest") : ""));
@@ -451,6 +453,45 @@ function deleteControl(listingId: string, thread: string): HTMLElement {
return slot;
}
function blockControl(listingId: string, thread: string): HTMLElement {
const slot = h("p", null);
const ask = () => {
clear(slot);
append(slot, [
t("own.blockSure"),
" ",
h("button", { type: "button", class: "btn", onclick: () => void o.blockThread(listingId, thread).then(() => (location.hash = `#/mine/${listingId}`)) }, t("own.blockYes")),
]);
};
slot.append(h("button", { type: "button", class: "btn", onclick: ask }, t("own.block")));
return slot;
}
/** The blocked conversations of one listing, each with a way to lift the block. */
function blockedList(listingId: string, changed: () => void): HTMLElement {
const box = h("details", { class: "blocked", hidden: true });
void o
.getBlocked()
.then((all) => {
const mine = all.filter((b) => b.listing === listingId);
if (mine.length === 0) return;
box.hidden = false;
append(box, [
h("summary", null, t("own.blocked", { n: mine.length })),
...mine.map((b) =>
h(
"p",
{ class: "muted small" },
`#${b.thread.slice(0, 6)} · ${new Date(b.blocked_at * 1000).toLocaleDateString()} `,
h("button", { type: "button", class: "btn", onclick: () => void o.unblockThread(listingId, b.thread).then(changed) }, t("own.unblock")),
),
),
]);
})
.catch(() => {});
return box;
}
/** The listing's saved address, shown and editable. It lives on this node only. */
function addressCard(listingId: string, changed: () => void): { root: HTMLElement } {
const root = h("div", { class: "panel addr" });
+18
View File
@@ -157,6 +157,24 @@ export async function deleteThread(listing: string, thread: string): Promise<voi
await call("DELETE", `/api/v1/inbox/${e(listing)}/${e(thread)}`);
}
export async function blockThread(listing: string, thread: string): Promise<void> {
await call("PUT", `/api/v1/inbox/${e(listing)}/${e(thread)}/block`);
}
export async function unblockThread(listing: string, thread: string): Promise<void> {
await call("DELETE", `/api/v1/inbox/${e(listing)}/${e(thread)}/block`);
}
export interface Blocked {
listing: string;
thread: string;
blocked_at: number;
}
export async function getBlocked(): Promise<Blocked[]> {
return (await call("GET", "/api/v1/blocked")) as Blocked[];
}
/** The saved address of a listing, or null if none is saved. */
export async function getAddress(listing: string): Promise<Address | null> {
try {