feat(notification): add email notification infrastructure, smtp configuration, and periodic background delivery job (#431)

* feat(notification): add email notification support and dedicated workflow

* feat(webui): add team email notification settings and test email dialog

* refactor(webui): remove redundant card header from email notification settings

* fix(notification): prevent sending notification emails to AI agents

* feat(notification): display project, avatar, upload time and resolve mention names in notification emails

* refactor(notification): remove uploadDebounceSeconds and naive workflow sleep

* refactor(notification): remove temporal notification workflow and keep email infrastructure

* fix(team): prevent leaking email notification settings and credentials in team settings

* feat(notification): add periodic background job for batched email notification delivery

* fix(notification): embed avatars and thumbnails as inline cid attachments
This commit is contained in:
Yiling-J
2026-09-28 09:58:59 +08:00
committed by GitHub
parent 94ea4c917a
commit d98f486c9d
33 changed files with 4021 additions and 20 deletions
+55
View File
@@ -1,11 +1,14 @@
import { zValidator } from '@hono/zod-validator'
import { Hono } from 'hono'
import { notificationService } from '@shumai/core/src/notification/notification'
import { emailService } from '@shumai/core/src/notification/email'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import {
listNotificationsRequestSchema,
markNotificationReadRequestSchema,
notificationSettingsSchema,
updateEmailNotificationSettingsSchema,
testEmailRequestSchema,
} from '@shumai/dtos'
import { userMetadataService } from '@shumai/core/src/user-metadata/user-metadata'
import type { Prisma } from '@shumai/db'
@@ -109,5 +112,57 @@ const route = new Hono<{ Variables: { user: User } }>()
return c.json({ success: true })
},
)
.get('/teams/:teamId/notifications/email', async (c) => {
const teamId = c.req.param('teamId')
const user = c.get('user')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Team,
id: teamId,
})
const settings = await emailService.getEmailSettings(teamId)
return c.json(settings)
})
.put(
'/teams/:teamId/notifications/email',
zValidator('json', updateEmailNotificationSettingsSchema),
async (c) => {
const teamId = c.req.param('teamId')
const user = c.get('user')
const req = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Team,
id: teamId,
})
const settings = await emailService.updateEmailSettings(teamId, req)
return c.json(settings)
},
)
.post(
'/teams/:teamId/notifications/email/test',
zValidator('json', testEmailRequestSchema),
async (c) => {
const teamId = c.req.param('teamId')
const user = c.get('user')
const req = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Team,
id: teamId,
})
const result = await emailService.sendTestEmail(teamId, user, req)
return c.json(result)
},
)
export default route