@meith/notifications 0.30.1 → 0.32.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meith/notifications",
3
- "version": "0.30.1",
3
+ "version": "0.32.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,8 +19,8 @@
19
19
  "access": "public"
20
20
  },
21
21
  "dependencies": {
22
- "@meith/core": "0.30.1",
23
- "@meith/i18n": "0.30.1",
24
- "@meith/mail": "0.30.1"
22
+ "@meith/core": "0.32.0",
23
+ "@meith/i18n": "0.32.0",
24
+ "@meith/mail": "0.32.0"
25
25
  }
26
26
  }
package/src/kinds.ts CHANGED
@@ -70,6 +70,20 @@ export const NOTIFICATION_KINDS = [
70
70
  pushByDefault: false,
71
71
  pushConfigurable: true,
72
72
  },
73
+ {
74
+ id: 'board.digest',
75
+ titleKey: 'notification.board.digest.title',
76
+ descriptionKey: 'notification.board.digest.description',
77
+ title: 'A recap of what you missed on the board',
78
+ description:
79
+ 'Sent only after you have been away a while, listing the busiest threads since ' +
80
+ 'your last visit. Off by default — nobody gets this without asking for it.',
81
+ audience: 'member',
82
+ emailByDefault: false,
83
+ emailConfigurable: true,
84
+ pushByDefault: false,
85
+ pushConfigurable: true,
86
+ },
73
87
  {
74
88
  id: 'post.mentioned',
75
89
  titleKey: 'notification.post.mentioned.title',
package/src/render.ts CHANGED
@@ -80,6 +80,11 @@ const DIGEST_CADENCE_KEYS = {
80
80
  weekly: 'notification.render.digest.weekly',
81
81
  } as const
82
82
 
83
+ const BOARD_DIGEST_CADENCE_KEYS = {
84
+ weekly: 'notification.render.digest.weekly',
85
+ monthly: 'notification.render.boardDigest.monthly',
86
+ } as const
87
+
83
88
  const TEMPLATES: Readonly<
84
89
  Record<string, (data: NotificationData, t: Translator) => { subject: string; body: string }>
85
90
  > = {
@@ -167,6 +172,29 @@ const TEMPLATES: Readonly<
167
172
  }
168
173
  },
169
174
 
175
+ 'board.digest': (data, t) => {
176
+ const cadence = str(data, 'cadence') === 'monthly' ? 'monthly' : 'weekly'
177
+ const threadCount = num(data, 'threadCount')
178
+ const more = num(data, 'more')
179
+
180
+ const lines = objects(data, 'threads').map((entry) =>
181
+ t.t('notification.render.boardDigest.entry', {
182
+ title: str(entry, 'title', t.t('notification.render.digest.fallbackTitle')),
183
+ forum: str(entry, 'forumTitle', t.t('notification.render.boardDigest.forumFallback')),
184
+ }),
185
+ )
186
+
187
+ if (more > 0) lines.push(t.t('notification.render.digest.more', { count: more }))
188
+
189
+ return {
190
+ subject: t.t('notification.render.boardDigest.subject', {
191
+ cadence: t.t(BOARD_DIGEST_CADENCE_KEYS[cadence]),
192
+ threads: threadCount,
193
+ }),
194
+ body: lines.join('\n'),
195
+ }
196
+ },
197
+
170
198
  'post.mentioned': (data, t) => {
171
199
  const by = str(data, 'byUsername', t.t('notification.render.somebody'))
172
200
  const title = str(data, 'threadTitle', t.t('notification.render.threadFallback'))