mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 19:16:22 +00:00
feat: slack integration deletion
This commit is contained in:
@@ -12,13 +12,17 @@ import { TProjectDALFactory } from "../project/project-dal";
|
||||
import { TSlackIntegrationDALFactory } from "./slack-integration-dal";
|
||||
import {
|
||||
TCompleteSlackIntegrationDTO,
|
||||
TDeleteSlackIntegrationDTO,
|
||||
TGetSlackInstallUrlDTO,
|
||||
TGetSlackIntegrationByProjectId,
|
||||
TUpdateSlackIntegration
|
||||
TGetSlackIntegrationByProjectIdDTO,
|
||||
TUpdateSlackIntegrationDTO
|
||||
} from "./slack-types";
|
||||
|
||||
type TSlackServiceFactoryDep = {
|
||||
slackIntegrationDAL: Pick<TSlackIntegrationDALFactory, "create" | "findOne" | "findById" | "updateById">;
|
||||
slackIntegrationDAL: Pick<
|
||||
TSlackIntegrationDALFactory,
|
||||
"create" | "findOne" | "findById" | "updateById" | "deleteById"
|
||||
>;
|
||||
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
|
||||
projectDAL: Pick<TProjectDALFactory, "findById">;
|
||||
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
|
||||
@@ -156,7 +160,7 @@ export const slackServiceFactory = ({
|
||||
actorOrgId,
|
||||
actorAuthMethod,
|
||||
projectId
|
||||
}: TGetSlackIntegrationByProjectId) => {
|
||||
}: TGetSlackIntegrationByProjectIdDTO) => {
|
||||
const { permission } = await permissionService.getProjectPermission(
|
||||
actor,
|
||||
actorId,
|
||||
@@ -183,7 +187,7 @@ export const slackServiceFactory = ({
|
||||
accessRequestChannels,
|
||||
isSecretRequestNotificationEnabled,
|
||||
secretRequestChannels
|
||||
}: TUpdateSlackIntegration) => {
|
||||
}: TUpdateSlackIntegrationDTO) => {
|
||||
const slackIntegration = await slackIntegrationDAL.findById(id);
|
||||
if (!slackIntegration) {
|
||||
throw new NotFoundError({
|
||||
@@ -208,11 +212,38 @@ export const slackServiceFactory = ({
|
||||
});
|
||||
};
|
||||
|
||||
const deleteSlackIntegration = async ({
|
||||
actorId,
|
||||
actor,
|
||||
actorOrgId,
|
||||
actorAuthMethod,
|
||||
id
|
||||
}: TDeleteSlackIntegrationDTO) => {
|
||||
const slackIntegration = await slackIntegrationDAL.findById(id);
|
||||
if (!slackIntegration) {
|
||||
throw new NotFoundError({
|
||||
message: "Slack integration not found"
|
||||
});
|
||||
}
|
||||
const { permission } = await permissionService.getProjectPermission(
|
||||
actor,
|
||||
actorId,
|
||||
slackIntegration.projectId,
|
||||
actorAuthMethod,
|
||||
actorOrgId
|
||||
);
|
||||
|
||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Settings);
|
||||
|
||||
return slackIntegrationDAL.deleteById(id);
|
||||
};
|
||||
|
||||
return {
|
||||
getInstallUrl,
|
||||
getSlackIntegrationByProjectId,
|
||||
completeSlackIntegration,
|
||||
getSlackInstaller,
|
||||
updateSlackIntegration
|
||||
updateSlackIntegration,
|
||||
deleteSlackIntegration
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,9 +2,9 @@ import { TProjectPermission } from "@app/lib/types";
|
||||
|
||||
export type TGetSlackInstallUrlDTO = TProjectPermission;
|
||||
|
||||
export type TGetSlackIntegrationByProjectId = TProjectPermission;
|
||||
export type TGetSlackIntegrationByProjectIdDTO = TProjectPermission;
|
||||
|
||||
export type TUpdateSlackIntegration = {
|
||||
export type TUpdateSlackIntegrationDTO = {
|
||||
id: string;
|
||||
isAccessRequestNotificationEnabled?: boolean;
|
||||
accessRequestChannels?: string;
|
||||
@@ -12,6 +12,10 @@ export type TUpdateSlackIntegration = {
|
||||
secretRequestChannels?: string;
|
||||
} & Omit<TProjectPermission, "projectId">;
|
||||
|
||||
export type TDeleteSlackIntegrationDTO = {
|
||||
id: string;
|
||||
} & Omit<TProjectPermission, "projectId">;
|
||||
|
||||
export type TCompleteSlackIntegrationDTO = {
|
||||
projectId: string;
|
||||
teamId: string;
|
||||
|
||||
Reference in New Issue
Block a user