Add email to address release and an address hint

The release sheet gets an optional email field, prefilled from the saved
address and kept with it. A conversation suggests releasing the address
when the buyer's latest message contains words like "address" or "wo
genau" (a keyword guess, German and English, only ever a suggestion).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 20:04:10 +01:00
co-authored by Claude Sonnet 5.5
parent 8edae3ae56
commit 7348067350
6 changed files with 81 additions and 3 deletions
+4
View File
@@ -158,6 +158,8 @@ const de = {
"own.first":
"Erste Nachricht dieser Person. Bis du antwortest, darf sie nur kurzen Text ohne Links schicken. Alles wird als reiner Text angezeigt, nie als Link.",
"own.hiddenMsg": "Ausgeblendet: Eine erste Nachricht muss kurz sein und darf keine Links enthalten.",
"own.hintAddress":
"Die Person fragt möglicherweise nach der Adresse (Vermutung anhand einzelner Wörter). Mit „Adresse freigeben“ schickst du sie.",
"own.grantSent": "Adresse freigegeben bis {date}",
"own.reply": "Antwort",
"own.send": "Senden",
@@ -355,6 +357,8 @@ const en: Record<keyof typeof de, string> = {
"own.first":
"First message from this person. Until you reply they can send short text only, no links. Everything is shown as plain text, never as a link.",
"own.hiddenMsg": "Hidden: a first message must be short and contain no links.",
"own.hintAddress":
"This person may be asking for the address (a guess based on a few words). Use \"Release address\" to send it.",
"own.grantSent": "Address released until {date}",
"own.reply": "Reply",
"own.send": "Send",
+18 -1
View File
@@ -116,6 +116,7 @@ export async function showOwner(listingId?: string, thread?: string): Promise<vo
const msgBox = h("div", { class: "thread", "aria-live": "polite" });
const threadHead = h("h2", { class: "pane-title" });
const firstNote = h("p", { class: "note warn" }, t("own.first"));
const addressHint = h("p", { class: "note hint", hidden: true }, t("own.hintAddress"));
const threadPane = h("section", { class: "pane pane-thread" });
if (listingId && thread) {
append(threadPane, [
@@ -124,6 +125,7 @@ export async function showOwner(listingId?: string, thread?: string): Promise<vo
h("p", { class: "muted small" }, t("own.anon")),
msgBox,
firstNote,
addressHint,
composer(listingId, thread, () => void refresh(), (opener) => openSheet(listingId, thread, opener, () => void refresh())),
deleteControl(listingId, thread),
]);
@@ -222,6 +224,7 @@ export async function showOwner(listingId?: string, thread?: string): Promise<vo
clear(msgBox);
for (const m of msgs) msgBox.append(bubble(m));
firstNote.hidden = msgs.some((m) => m.dir === "out");
addressHint.hidden = !asksForAddress(msgs);
}
function renderAll(): void {
@@ -277,6 +280,16 @@ export async function showOwner(listingId?: string, thread?: string): Promise<vo
// --- pieces ------------------------------------------------------------------------------
// Words that suggest the buyer wants to know where the place is, in German and
// English. A guess, so it only ever produces a suggestion, never an action.
const ASKS_ADDRESS = /adress|address|anschrift|wo genau|wo liegt|wo befindet|which street|what street|where exactly|where is|where in/i;
/** True if the buyer's latest readable message looks like a request for the address. */
function asksForAddress(msgs: o.OwnerMessage[]): boolean {
const last = msgs[msgs.length - 1];
return !!last && last.dir === "in" && !last.hidden && last.type === "text" && ASKS_ADDRESS.test(last.text ?? "");
}
function bubble(m: o.OwnerMessage): HTMLElement {
const mine = m.dir === "out";
const who = mine ? t("own.you") : t("own.buyer");
@@ -437,6 +450,7 @@ function openSheet(listingId: string, thread: string, opener: HTMLElement, done:
};
const address = h("input", { name: "address", maxlength: 300, required: true });
const phone = h("input", { name: "phone", maxlength: 40 });
const email = h("input", { name: "email", type: "email", maxlength: 120, autocomplete: "off" });
const note = h("textarea", { name: "note", rows: 2, maxlength: 1000 });
const valid = h("select", { name: "valid" }, ...VALID_DAYS.map((d) => h("option", { value: String(d), selected: d === DEFAULT_DAYS }, d === 1 ? t("own.day") : t("own.days", { n: d }))));
const remember = h("input", { type: "checkbox", name: "remember" });
@@ -462,12 +476,13 @@ function openSheet(listingId: string, thread: string, opener: HTMLElement, done:
send.textContent = t("own.sending");
try {
if (remember.checked && (!saved || saved.address !== a)) {
await o.putAddress(listingId, { address: a, phone: phone.value.trim() || undefined, email: saved?.email });
await o.putAddress(listingId, { address: a, phone: phone.value.trim() || undefined, email: email.value.trim() || undefined });
}
await o.sendReply(listingId, thread, {
type: "grant",
address: a,
phone: phone.value.trim() || undefined,
email: email.value.trim() || undefined,
note: note.value.trim() || undefined,
valid_days: Number(valid.value),
});
@@ -483,6 +498,7 @@ function openSheet(listingId: string, thread: string, opener: HTMLElement, done:
},
h("label", null, t("own.fAddress"), address),
h("label", null, t("own.fPhone"), phone),
h("label", null, t("own.fEmail"), email),
h("label", null, t("own.fNote"), note),
h("label", null, t("own.fValid"), valid),
rememberRow,
@@ -509,6 +525,7 @@ function openSheet(listingId: string, thread: string, opener: HTMLElement, done:
if (a) {
if (!address.value) address.value = a.address;
if (!phone.value && a.phone) phone.value = a.phone;
if (!email.value && a.email) email.value = a.email;
} else {
remember.checked = true; // nothing saved yet: offer to keep what is typed
}
+1
View File
@@ -98,6 +98,7 @@ export interface Reply {
text?: string;
address?: string;
phone?: string;
email?: string;
note?: string;
valid_days?: number;
}