@bobfrankston/rmfmail 1.0.697 → 1.0.699

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1198,15 +1198,28 @@ async function showMessage(accountId, uid, folderId, specialUse, isRetry = false
1198
1198
  const m = mailUrl.match(/^mailto:([^?]*)(?:\?(.*))?$/i);
1199
1199
  const to = m?.[1] ? decodeURIComponent(m[1]) : "";
1200
1200
  const qs = new URLSearchParams(m?.[2] || "");
1201
- const subject = qs.get("subject") || "Unsubscribe";
1202
- const body = qs.get("body") || "";
1201
+ const origFrom = msg.from ? msg.from.name ? `${msg.from.name} <${msg.from.address}>` : msg.from.address : "";
1202
+ const origSubject = msg.subject || "";
1203
+ const origDate = msg.date ? new Date(msg.date).toLocaleString(void 0, { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hour12: false }) : "";
1204
+ const subject = qs.get("subject") || (origSubject ? `Unsubscribe: ${origSubject}` : "Unsubscribe");
1205
+ const inlineBody = qs.get("body") || "";
1206
+ const escape = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1207
+ const contextLines = [];
1208
+ if (origFrom)
1209
+ contextLines.push(`From: ${escape(origFrom)}`);
1210
+ if (origSubject)
1211
+ contextLines.push(`Subject: ${escape(origSubject)}`);
1212
+ if (origDate)
1213
+ contextLines.push(`Date: ${escape(origDate)}`);
1214
+ const contextBlock = contextLines.length ? `<p>\u2014<br>${contextLines.join("<br>")}</p>` : "";
1215
+ const bodyHtml = inlineBody ? `<p>${escape(inlineBody)}</p>${contextBlock}` : `<p>Please unsubscribe me from this list.</p>${contextBlock}`;
1203
1216
  const init = {
1204
1217
  mode: "new",
1205
1218
  accountId: currentAccountId,
1206
1219
  to: to ? [{ name: "", address: to }] : [],
1207
1220
  cc: [],
1208
1221
  subject,
1209
- bodyHtml: body ? `<p>${body}</p>` : "",
1222
+ bodyHtml,
1210
1223
  inReplyTo: "",
1211
1224
  references: [],
1212
1225
  accounts: []