domma-cms 1.10.37 → 1.10.39

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.
@@ -15,7 +15,7 @@
15
15
  const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
16
16
 
17
17
  /**
18
- * @param {{label?: string, unseen: number|null, error?: string}[]} boxes - one per mailbox
18
+ * @param {{id?: string, label?: string, unseen: number|null, uidNext?: number|null, error?: string}[]} boxes - one per mailbox
19
19
  * @returns {{count: number, label: string, tone: string, details: object}}
20
20
  */
21
21
  export function unreadBadge(boxes = []) {
@@ -31,6 +31,7 @@ export function unreadBadge(boxes = []) {
31
31
  // shown even at 0 - otherwise a broken password reads as "all read".
32
32
  tone: failed ? 'danger' : 'info',
33
33
  ...(failed ? {showZero: true} : {}),
34
+ ...newMailNotice(known),
34
35
  details: {
35
36
  title: 'Mail',
36
37
  rows: boxes.map(b => ({
@@ -43,3 +44,25 @@ export function unreadBadge(boxes = []) {
43
44
  }
44
45
  };
45
46
  }
47
+
48
+ /**
49
+ * The sidebar's "new mail" signal (admin/js/lib/sidebar-notify.js): one mark
50
+ * per mailbox with unread mail - the inbox's newest UID, which only rises when
51
+ * something arrives. STATUS has no sender or subject, so the notice says how
52
+ * many and where.
53
+ *
54
+ * @param {object[]} boxes - the reachable ones
55
+ * @returns {{notify?: object}}
56
+ */
57
+ function newMailNotice(boxes) {
58
+ const marks = {};
59
+ const where = [];
60
+ for (const box of boxes) {
61
+ const uidNext = Number(box.uidNext);
62
+ if (!box.id || !(box.unseen > 0) || !Number.isFinite(uidNext) || uidNext < 2) continue;
63
+ marks[box.id] = uidNext - 1;
64
+ where.push(`${plural(box.unseen, 'unread message')} in ${String(box.label || 'your inbox')}`);
65
+ }
66
+ if (!where.length) return {};
67
+ return {notify: {marks, title: 'New mail', body: where.join('; ')}};
68
+ }
@@ -97,7 +97,10 @@ export async function runVacation({
97
97
  // Not filed. One holiday produces a hundred of these, and a
98
98
  // Sent folder that is mostly "Out of office" is one nobody can
99
99
  // find anything in - the reply log is the audit trail instead.
100
- fileCopy: false
100
+ fileCopy: false,
101
+ // So the mailbox's rules about leaving (secure delivery) apply
102
+ // to its away message too.
103
+ account
101
104
  });
102
105
 
103
106
  // Recorded AFTER it has gone. The other order would mean a send
@@ -55,7 +55,7 @@ export async function sidebarCountRoutes(fastify, opts = {}) {
55
55
  const count = Number(value);
56
56
  if (value == null || !Number.isFinite(count) || count < 0) { answers.set(url, null); continue; }
57
57
  if (typeof answer !== 'object') answers.set(url, count);
58
- else answers.set(url, Object.fromEntries(['count', 'label', 'tone', 'inventory', 'showZero', 'details']
58
+ else answers.set(url, Object.fromEntries(['count', 'label', 'tone', 'inventory', 'showZero', 'details', 'notify']
59
59
  .filter(key => answer[key] !== undefined).map(key => [key, answer[key]])));
60
60
  } catch { answers.set(url, null); }
61
61
  finally { clearTimeout(timer); }