refactor(notification): simplify email wording and remove redundant team references

This commit is contained in:
yiling
2026-09-28 13:37:16 +08:00
parent af8f24aa95
commit bf5ac566b6
3 changed files with 25 additions and 18 deletions
+11 -3
View File
@@ -544,7 +544,15 @@ describe('EmailService', () => {
],
})
expect(rendered.subject).toBe('[Shumai] 2 new notifications in Designers')
expect(rendered.subject).toBe('[Shumai] 2 new notifications')
expect(rendered.html).toContain('You have 2 new updates:')
expect(rendered.html).not.toContain('in <strong>Designers</strong>')
expect(rendered.html).toContain('Open Shumai')
expect(rendered.html).not.toContain('Open Designers')
expect(rendered.html).not.toContain('Team: Designers')
expect(rendered.text).toContain('You have 2 new update(s):')
expect(rendered.text).toContain('Open Shumai:')
expect(rendered.text).not.toContain('Team: Designers')
expect(rendered.html).toContain('img1.png')
expect(rendered.html).toContain('img2.png')
// img1 has thumbnail, img2 does not
@@ -576,7 +584,7 @@ describe('EmailService', () => {
items,
})
expect(rendered.subject).toBe('[Shumai] 5 new notifications in Designers')
expect(rendered.subject).toBe('[Shumai] 5 new notifications')
expect(rendered.html).toContain('Alice uploaded 5 assets to Website Redesign')
// Thumbnails must be omitted for collapsed groups (> 3)
expect(rendered.html).not.toContain('https://example.com/thumb_')
@@ -621,7 +629,7 @@ describe('EmailService', () => {
items: [...commentItems, uploadItem],
})
expect(rendered.subject).toBe('[Shumai] 5 new notifications in Designers')
expect(rendered.subject).toBe('[Shumai] 5 new notifications')
// Collapsed comment group
expect(rendered.html).toContain('UserB left 4 comments in Project Alpha')
// Detailed upload item with thumbnail
+12 -13
View File
@@ -323,7 +323,7 @@ Sent from Shumai at ${baseUrl}
actionText = 'View Task'
} else if (ctx.teamId) {
actionUrl = `${baseUrl}/teams/${ctx.teamId}`
actionText = 'Open Team'
actionText = 'Open Shumai'
}
let subject = '[Shumai] Notification'
@@ -496,7 +496,7 @@ Sent from Shumai at ${baseUrl}
<a href="${actionUrl}" class="btn">${escapeHtml(actionText)}</a>
</div>
<div class="footer">
Team: ${escapeHtml(ctx.teamName)} &bull; Sent from <a href="${baseUrl}" style="color: #6366f1; text-decoration: none;">Shumai</a>
Sent from <a href="${baseUrl}" style="color: #6366f1; text-decoration: none;">Shumai</a>
</div>
</div>
</body>
@@ -509,8 +509,7 @@ ${subject}
${headline}
${formattedUploadTime ? `Uploaded at: ${formattedUploadTime}\n` : ''}${detail ? `\n${detail}\n` : ''}
${actionText}: ${actionUrl}
Team: ${ctx.teamName}
Sent from Shumai at ${baseUrl}
`.trim()
return { subject, html, text }
@@ -526,14 +525,14 @@ Team: ${ctx.teamName}
if (ctx.items.length === 0) {
return {
subject: `[Shumai] Notifications in ${ctx.teamName}`,
subject: `[Shumai] Notifications`,
html: `<p>No new notifications.</p>`,
text: `No new notifications.`,
}
}
// Determine subject
let subject = `[Shumai] ${ctx.items.length} new notifications in ${ctx.teamName}`
let subject = `[Shumai] ${ctx.items.length} new notifications`
if (ctx.items.length === 1) {
const single = ctx.items[0]
const actor = single.creatorName || 'Someone'
@@ -563,7 +562,7 @@ Team: ${ctx.teamName}
break
}
default:
subject = `[Shumai] 1 new notification in ${ctx.teamName}`
subject = `[Shumai] 1 new notification`
break
}
}
@@ -718,15 +717,15 @@ Team: ${ctx.teamName}
<body>
<div class="container">
<div class="header">Shumai Notifications</div>
<div class="subtitle">You have ${ctx.items.length} new update${ctx.items.length > 1 ? 's' : ''} in <strong>${escapeHtml(ctx.teamName)}</strong>:</div>
<div class="subtitle">You have ${ctx.items.length} new update${ctx.items.length > 1 ? 's' : ''}:</div>
<div>
${htmlRows.join('\n')}
</div>
<div style="text-align: center; margin-top: 20px;">
<a href="${teamUrl}" class="btn">Open ${escapeHtml(ctx.teamName)}</a>
<a href="${teamUrl}" class="btn">Open Shumai</a>
</div>
<div class="footer">
Team: ${escapeHtml(ctx.teamName)} &bull; Sent from <a href="${baseUrl}" style="color: #6366f1; text-decoration: none;">Shumai</a>
Sent from <a href="${baseUrl}" style="color: #6366f1; text-decoration: none;">Shumai</a>
</div>
</div>
</body>
@@ -736,11 +735,11 @@ Team: ${ctx.teamName}
const text = `
Shumai Notifications
You have ${ctx.items.length} new update(s) in ${ctx.teamName}:
You have ${ctx.items.length} new update(s):
${textRows.join('\n\n')}
Open Team: ${teamUrl}
Open Shumai: ${teamUrl}
Sent from Shumai at ${baseUrl}
`.trim()
@@ -854,7 +853,7 @@ function getItemAction(
} else if (item.teamId) {
return {
url: `${baseUrl}/teams/${item.teamId}`,
text: 'Open Team',
text: 'Open Shumai',
}
}
return { url: baseUrl, text: 'Open Shumai' }
@@ -98,7 +98,7 @@ describe('NotificationJobService', () => {
expect.objectContaining({ host: 'smtp.test.com' }),
expect.objectContaining({
to: 'bob@test.com',
subject: '[Shumai] 2 new notifications in Email Team',
subject: '[Shumai] 2 new notifications',
}),
)
@@ -341,7 +341,7 @@ describe('NotificationJobService', () => {
expect(sendMailSpy).toHaveBeenCalledTimes(1)
const call = sendMailSpy.mock.calls[0]
expect(call[1].to).toBe('recip@test.com')
expect(call[1].subject).toBe('[Shumai] 6 new notifications in Email Team')
expect(call[1].subject).toBe('[Shumai] 6 new notifications')
// Uploads collapsed into 1 row because count > 3
expect(call[1].html).toContain('UserB uploaded 5 assets to Project Alpha')
// Comment rendered as individual row