From 6c4e2a9d1127a815a2690fb0631c87c9e31e8dea Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 6 Aug 2023 11:54:48 -0400 Subject: [PATCH] perf: Narrow scopes of Slack hook queries --- plugins/slack/server/api/hooks.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/slack/server/api/hooks.ts b/plugins/slack/server/api/hooks.ts index cef40782a..30bb69f3d 100644 --- a/plugins/slack/server/api/hooks.ts +++ b/plugins/slack/server/api/hooks.ts @@ -1,6 +1,7 @@ import { t } from "i18next"; import Router from "koa-router"; import { escapeRegExp } from "lodash"; +import { Op } from "sequelize"; import { IntegrationService } from "@shared/types"; import env from "@server/env"; import { AuthenticationError, InvalidRequestError } from "@server/errors"; @@ -196,6 +197,7 @@ router.post("hooks.slack", async (ctx: APIContext) => { // via integration const integration = await Integration.findOne({ where: { + service: IntegrationService.Slack, settings: { serviceTeamId: team_id, }, @@ -259,6 +261,7 @@ router.post("hooks.slack", async (ctx: APIContext) => { if (!user) { const auth = await IntegrationAuthentication.findOne({ where: { + scopes: { [Op.contains]: ["identity.email"] }, service: IntegrationService.Slack, teamId: team.id, },