fix: name unknown senders by fingerprint
This commit is contained in:
parent
9798d38040
commit
025963371f
1 changed files with 13 additions and 2 deletions
|
|
@ -131,16 +131,20 @@ async function renderFolder() {
|
|||
}
|
||||
|
||||
// Open an envelope and split its body; anything unreadable shows as such
|
||||
// rather than throwing, so one bad message cannot blank the list.
|
||||
// rather than throwing, so one bad message cannot blank the list. The wire
|
||||
// carries no sender name, so an unknown key can only be shown as its
|
||||
// fingerprint until the user imports the sender's smol:// address.
|
||||
function describe(row) {
|
||||
try {
|
||||
const opened = unseal(store.identities(), row.envelope);
|
||||
const { fields, body } = parseFrontmatter(new TextDecoder().decode(opened.body));
|
||||
const known = store.addressForKey(opened.sender);
|
||||
return {
|
||||
...opened,
|
||||
fields, body,
|
||||
subject: fields.Subject || "",
|
||||
from: store.addressForKey(opened.sender) ?? `<${b32encode(opened.sender).slice(0, 16)}…>`,
|
||||
from: known ?? `unknown · ${fingerprint(opened.sender)}`,
|
||||
knownSender: Boolean(known),
|
||||
};
|
||||
} catch (err) {
|
||||
return { error: err.message };
|
||||
|
|
@ -170,6 +174,13 @@ async function openMessage(id) {
|
|||
: `from: ${opened.from}\nkey: ${b32encode(opened.sender)}\nid: ${row.id}\ndate: ${fmtTime(opened.time)}`;
|
||||
view.querySelector(".fields").textContent = fields.map(([k, v]) => `${k}: ${v}`).join("\n");
|
||||
view.querySelector("pre").textContent = opened.body;
|
||||
if (folder === "inbox" && !opened.knownSender) {
|
||||
const note = document.createElement("p");
|
||||
note.className = "placeholder";
|
||||
note.textContent = "The wire carries no sender name, only this signed key. " +
|
||||
"Import the sender's smol:// address in settings to name future mail.";
|
||||
view.append(note);
|
||||
}
|
||||
if (folder === "inbox") {
|
||||
const reply = document.createElement("button");
|
||||
reply.textContent = "reply";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue