feat: notifications in the app and, optionally, by e-mail

Derived from events and kept per person: whoever a ticket is assigned to,
whoever reports or works on it when it moves, fails QA or gets a comment,
and whoever joins a project. Never about what you did yourself, once per
event. They arrive live through a subscription to a bell in the header,
and are copied by e-mail to whoever turns it on when SMTP_URL is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 09:19:59 +02:00
parent 0b65c1c912
commit efa06a0723
60 changed files with 3406 additions and 28 deletions

View File

@@ -1,11 +1,15 @@
import { Args, ID, Resolver, Subscription } from '@nestjs/graphql';
import { User } from '@task-stream/api/identity/domain';
import { CurrentUser } from '@task-stream/api/identity/presenters';
import { ChangesService } from '@task-stream/api/tracker/application';
import {
ChangesService,
NotificationsService,
} from '@task-stream/api/tracker/application';
import {
ActivityGql,
CommentChangeGql,
IssueChangeGql,
NotificationGql,
ProjectChangeGql,
ReleaseChangeGql,
} from './types';
@@ -18,7 +22,10 @@ const asIs = { resolve: <T>(payload: T) => payload };
*/
@Resolver()
export class SubscriptionResolver {
constructor(private readonly changes: ChangesService) {}
constructor(
private readonly changes: ChangesService,
private readonly notifications: NotificationsService,
) {}
@Subscription(() => IssueChangeGql, {
...asIs,
@@ -74,4 +81,12 @@ export class SubscriptionResolver {
myProjectsChanged(@CurrentUser() me: User) {
return this.changes.watchMyProjects(me.id);
}
@Subscription(() => NotificationGql, {
...asIs,
description: 'My notifications, as they happen',
})
notificationAdded(@CurrentUser() me: User) {
return this.notifications.watch(me.id);
}
}