fix(dashboard): remove popup from slack integrations

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-10-03 20:16:03 +02:00
parent f45b02407c
commit 4329960bd9
8 changed files with 87 additions and 99 deletions

View File

@@ -224,39 +224,3 @@ export async function wsProjectNotifications(
getRedisSub().off('message', message as any);
});
}
export async function wsIntegrationsSlack(
connection: {
socket: WebSocket;
},
req: FastifyRequest<{
Querystring: {
organizationId?: string;
};
}>,
) {
const { organizationId } = req.query;
if (!organizationId) {
connection.socket.send('No organizationId provided');
connection.socket.close();
return;
}
const subscribeToEvent = 'integrations:slack';
getRedisSub().subscribe(subscribeToEvent);
const onMessage = (channel: string, message: string) => {
if (channel === subscribeToEvent) {
const parsed = getSuperJson<{ organizationId: string }>(message);
if (parsed && parsed.organizationId === organizationId) {
connection.socket.send(message);
}
}
};
getRedisSub().on('message', onMessage);
connection.socket.on('close', () => {
getRedisSub().unsubscribe(subscribeToEvent);
getRedisSub().off('message', onMessage);
});
}