feat(notifications): emit at maintenance/turn/sync/reauth events
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user