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, },