Add ability to link Slack <-> Outline accounts (#6682)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Router from "koa-router";
|
||||
import { WhereOptions } from "sequelize";
|
||||
import { WhereOptions, Op } from "sequelize";
|
||||
import { IntegrationType } from "@shared/types";
|
||||
import auth from "@server/middlewares/authentication";
|
||||
import { transaction } from "@server/middlewares/transaction";
|
||||
@@ -20,19 +20,31 @@ router.post(
|
||||
pagination(),
|
||||
validate(T.IntegrationsListSchema),
|
||||
async (ctx: APIContext<T.IntegrationsListReq>) => {
|
||||
const { direction, type, sort } = ctx.input.body;
|
||||
const { direction, service, type, sort } = ctx.input.body;
|
||||
const { user } = ctx.state.auth;
|
||||
|
||||
let where: WhereOptions<Integration> = {
|
||||
teamId: user.teamId,
|
||||
};
|
||||
|
||||
if (type) {
|
||||
where = {
|
||||
...where,
|
||||
type,
|
||||
};
|
||||
where = { ...where, type };
|
||||
}
|
||||
if (service) {
|
||||
where = { ...where, service };
|
||||
}
|
||||
|
||||
// Linked account is special as these are user-specific, other integrations are workspace-wide.
|
||||
where = {
|
||||
...where,
|
||||
[Op.or]: [
|
||||
{ userId: user.id, type: IntegrationType.LinkedAccount },
|
||||
{
|
||||
type: {
|
||||
[Op.not]: IntegrationType.LinkedAccount,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const integrations = await Integration.findAll({
|
||||
where,
|
||||
@@ -121,7 +133,7 @@ router.post(
|
||||
|
||||
router.post(
|
||||
"integrations.delete",
|
||||
auth({ admin: true }),
|
||||
auth(),
|
||||
validate(T.IntegrationsDeleteSchema),
|
||||
transaction(),
|
||||
async (ctx: APIContext<T.IntegrationsDeleteReq>) => {
|
||||
|
||||
Reference in New Issue
Block a user