perf: Narrow scopes of Slack hook queries
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user