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
+56 -1
View File
@@ -291,6 +291,11 @@ var de = {
"own.delete": "Unterhaltung l\xF6schen",
"own.deleteSure": "Wirklich l\xF6schen? Sie wird von deinem Knoten entfernt.",
"own.deleteYes": "Ja, l\xF6schen",
"own.block": "Blockieren",
"own.blockSure": "Blockieren? Die Unterhaltung wird gel\xF6scht und weitere Nachrichten dieser Person werden ungelesen verworfen. Sie erf\xE4hrt davon nichts.",
"own.blockYes": "Ja, blockieren",
"own.blocked": "Blockiert ({n})",
"own.unblock": "Freigeben",
"own.sheetTitle": "Adresse freigeben",
"own.sheetHelp": "Eine signierte Nachricht, nur f\xFCr diese Person sichtbar. Ihr Bildschirm blendet sie nach dem Datum aus. Sie k\xF6nnte sie trotzdem kopiert haben.",
"own.fNote": "Hinweis an die Person",
@@ -543,6 +548,11 @@ var en = {
"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.",
"own.fNote": "Note to the buyer",
@@ -4864,6 +4874,15 @@ async function sendReply(listing, thread, r) {
async function deleteThread(listing, thread) {
await call("DELETE", `/api/v1/inbox/${e(listing)}/${e(thread)}`);
}
async function blockThread(listing, thread) {
await call("PUT", `/api/v1/inbox/${e(listing)}/${e(thread)}/block`);
}
async function unblockThread(listing, thread) {
await call("DELETE", `/api/v1/inbox/${e(listing)}/${e(thread)}/block`);
}
async function getBlocked() {
return await call("GET", "/api/v1/blocked");
}
async function getAddress(listing) {
try {
return await call("GET", `/api/v1/listings/${e(listing)}/address`);
@@ -4978,6 +4997,7 @@ async function showOwner(listingId, thread) {
addr.root,
chips,
reqBox,
blockedList(listingId, () => void refresh()),
h("p", { class: "muted small" }, t("own.limitNote"))
] : [h("p", { class: "muted pick" }, t("own.pickListing"))]
);
@@ -4995,7 +5015,8 @@ async function showOwner(listingId, thread) {
firstNote,
addressHint,
composer2(listingId, thread, () => void refresh(), (opener) => openSheet(listingId, thread, opener, () => void refresh())),
deleteControl2(listingId, thread)
deleteControl2(listingId, thread),
blockControl(listingId, thread)
]);
} else {
threadPane.append(h("p", { class: "muted pick" }, listingId ? t("own.pickRequest") : ""));
@@ -5273,6 +5294,40 @@ function deleteControl2(listingId, thread) {
slot.append(h("button", { type: "button", class: "btn", onclick: ask }, t("own.delete")));
return slot;
}
function blockControl(listingId, thread) {
const slot = h("p", null);
const ask = () => {
clear(slot);
append(slot, [
t("own.blockSure"),
" ",
h("button", { type: "button", class: "btn", onclick: () => void 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;
}
function blockedList(listingId, changed) {
const box = h("details", { class: "blocked", hidden: true });
void getBlocked().then((all) => {
const mine2 = all.filter((b) => b.listing === listingId);
if (mine2.length === 0) return;
box.hidden = false;
append(box, [
h("summary", null, t("own.blocked", { n: mine2.length })),
...mine2.map(
(b) => h(
"p",
{ class: "muted small" },
`#${b.thread.slice(0, 6)} \xB7 ${new Date(b.blocked_at * 1e3).toLocaleDateString()} `,
h("button", { type: "button", class: "btn", onclick: () => void unblockThread(listingId, b.thread).then(changed) }, t("own.unblock"))
)
)
]);
}).catch(() => {
});
return box;
}
function addressCard(listingId, changed) {
const root = h("div", { class: "panel addr" });
let saved = null;