feat(notifications): emit at maintenance/turn/sync/reauth events

This commit is contained in:
Gabriel Brown
2026-07-11 16:08:22 -04:00
parent 4eb0c963ff
commit 3766a29871
7 changed files with 270 additions and 2 deletions
+10
View File
@@ -8,6 +8,7 @@ import {
query,
} from './_generated/server';
import { getRequiredUserId } from './model';
import { emitNotification } from './notifications';
export const getInstallUrl = query({
args: {},
@@ -158,6 +159,15 @@ export const setConnectionStatusByInstallation = internalMutation({
const now = Date.now();
for (const connection of connections) {
await ctx.db.patch(connection._id, { status, updatedAt: now });
if (status !== 'active') {
await emitNotification(ctx, {
userId: connection.userId,
kind: 'connection_needs_reauth',
title: 'GitHub connection needs re-authorization',
body: 'Reconnect your GitHub account to keep syncing.',
link: '/settings/integrations',
});
}
}
return { updated: connections.length };