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
+32
View File
@@ -521,4 +521,36 @@ describe('TeamService', () => {
expect(result).toBe(false)
})
})
it('should not leak emailNotification or credentials in getSettings', async () => {
const team = await prisma.team.create({
data: {
name: 'Team With Credentials',
settings: {
transcode: {
videoStrategy: 'best_match',
hardwareAcceleration: 'off',
threads: 4,
},
appearance: {
hideAgent: true,
},
emailNotification: {
enabled: true,
host: 'smtp.secret.com',
port: 587,
password: 'super-secret-smtp-password',
from: 'noreply@secret.com',
},
},
},
})
const settings = await teamService.getSettings(team.id)
expect(settings).toBeDefined()
expect(settings.transcode?.threads).toBe(4)
expect(settings.appearance?.hideAgent).toBe(true)
expect((settings as Record<string, unknown>).emailNotification).toBeUndefined()
})
})
+7 -3
View File
@@ -298,7 +298,11 @@ export class TeamService {
where: { id: teamId },
})
if (!team) throw new HTTPException(404, { message: 'team not found' })
const settings = (team.settings || {}) as TeamSettingsResponse
const rawSettings = { ...(team.settings || {}) } as PrismaJson.Settings & {
[key: string]: unknown
}
delete rawSettings.emailNotification
const settings = rawSettings as TeamSettingsResponse
const embeddingAgent = await prisma.agent.findFirst({
where: { teamId, type: 'embedding', enabled: true },
@@ -360,12 +364,12 @@ export class TeamService {
settings[key] = value
}
const updated = await prisma.team.update({
await prisma.team.update({
where: { id: teamId },
data: { settings: settings as unknown as PrismaJson.Settings },
})
return (updated.settings || {}) as TeamSettingsResponse
return this.getSettings(teamId)
}
async getSandboxSettings(teamId: string): Promise<SandboxSettings> {