Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
slack app: fix (#2351)
Thibault Le Ouayaa93e7423cbc
diff --git a/apps/server/src/routes/slack/workspace-resolver.ts b/apps/server/src/routes/slack/workspace-resolver.tsindex 750110ca5..ec01c8b98 100644--- a/apps/server/src/routes/slack/workspace-resolver.ts+++ b/apps/server/src/routes/slack/workspace-resolver.ts@@ -1,4 +1,4 @@-import { and, db, eq } from "@openstatus/db";+import { and, db, desc, eq } from "@openstatus/db";import {integration,selectWorkspaceSchema,@@ -32,6 +32,10 @@ export async function resolveWorkspace(eq(integration.externalId, teamId),),)+ // Slack keeps one live token per (app, team); a reinstall invalidates all+ // earlier ones. If the team is linked to several workspaces, the newest row+ // is the only one holding a valid token.+ .orderBy(desc(integration.updatedAt)).get();if (!row?.workspaceId) return null;diff --git a/packages/subscriptions/src/channels/slack.ts b/packages/subscriptions/src/channels/slack.tsindex 6759e6881..f70589e15 100644--- a/packages/subscriptions/src/channels/slack.ts+++ b/packages/subscriptions/src/channels/slack.ts@@ -1,4 +1,4 @@-import { and, db, eq } from "@openstatus/db";+import { and, db, desc, eq } from "@openstatus/db";import { integration, pageSubscriber } from "@openstatus/db/src/schema";import type {ChatPostMessageArguments,@@ -77,6 +77,10 @@ async function getBotTokenFromDb(teamId: string): Promise<string | null> {eq(integration.externalId, teamId),),)+ // Slack keeps one live token per (app, team); a reinstall invalidates all+ // earlier ones. If the team is linked to several workspaces, the newest row+ // is the only one holding a valid token.+ .orderBy(desc(integration.updatedAt)).get();const credential = row?.credential as { botToken?: string } | null;return credential?.botToken ?? null;