chore: remove redundant delete current user mutation
This commit is contained in:
@@ -5,7 +5,6 @@ import executeFlow from './mutations/execute-flow.js';
|
||||
import updateUser from './mutations/update-user.ee.js';
|
||||
import deleteStep from './mutations/delete-step.js';
|
||||
import verifyConnection from './mutations/verify-connection.js';
|
||||
import deleteCurrentUser from './mutations/delete-current-user.ee.js';
|
||||
import updateCurrentUser from './mutations/update-current-user.js';
|
||||
import generateAuthUrl from './mutations/generate-auth-url.js';
|
||||
import createConnection from './mutations/create-connection.js';
|
||||
@@ -18,7 +17,6 @@ import updateFlowStatus from './mutations/update-flow-status.js';
|
||||
const mutationResolvers = {
|
||||
createConnection,
|
||||
createUser,
|
||||
deleteCurrentUser,
|
||||
deleteFlow,
|
||||
deleteStep,
|
||||
executeFlow,
|
||||
|
@@ -1,58 +0,0 @@
|
||||
import { Duration } from 'luxon';
|
||||
import deleteUserQueue from '../../queues/delete-user.ee.js';
|
||||
import flowQueue from '../../queues/flow.js';
|
||||
import Flow from '../../models/flow.js';
|
||||
import ExecutionStep from '../../models/execution-step.js';
|
||||
import appConfig from '../../config/app.js';
|
||||
|
||||
const deleteCurrentUser = async (_parent, params, context) => {
|
||||
const id = context.currentUser.id;
|
||||
|
||||
const flows = await context.currentUser.$relatedQuery('flows').where({
|
||||
active: true,
|
||||
});
|
||||
|
||||
const repeatableJobs = await flowQueue.getRepeatableJobs();
|
||||
|
||||
for (const flow of flows) {
|
||||
const job = repeatableJobs.find((job) => job.id === flow.id);
|
||||
|
||||
if (job) {
|
||||
await flowQueue.removeRepeatableByKey(job.key);
|
||||
}
|
||||
}
|
||||
|
||||
const executionIds = (
|
||||
await context.currentUser
|
||||
.$relatedQuery('executions')
|
||||
.select('executions.id')
|
||||
).map((execution) => execution.id);
|
||||
const flowIds = flows.map((flow) => flow.id);
|
||||
|
||||
await ExecutionStep.query().delete().whereIn('execution_id', executionIds);
|
||||
await context.currentUser.$relatedQuery('executions').delete();
|
||||
await context.currentUser.$relatedQuery('steps').delete();
|
||||
await Flow.query().whereIn('id', flowIds).delete();
|
||||
await context.currentUser.$relatedQuery('connections').delete();
|
||||
await context.currentUser.$relatedQuery('identities').delete();
|
||||
|
||||
if (appConfig.isCloud) {
|
||||
await context.currentUser.$relatedQuery('subscriptions').delete();
|
||||
await context.currentUser.$relatedQuery('usageData').delete();
|
||||
}
|
||||
|
||||
await context.currentUser.$query().delete();
|
||||
|
||||
const jobName = `Delete user - ${id}`;
|
||||
const jobPayload = { id };
|
||||
const millisecondsFor30Days = Duration.fromObject({ days: 30 }).toMillis();
|
||||
const jobOptions = {
|
||||
delay: millisecondsFor30Days,
|
||||
};
|
||||
|
||||
await deleteUserQueue.add(jobName, jobPayload, jobOptions);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default deleteCurrentUser;
|
@@ -4,7 +4,6 @@ type Query {
|
||||
type Mutation {
|
||||
createConnection(input: CreateConnectionInput): Connection
|
||||
createUser(input: CreateUserInput): UserWithAcceptInvitationUrl
|
||||
deleteCurrentUser: Boolean
|
||||
deleteFlow(input: DeleteFlowInput): Boolean
|
||||
deleteStep(input: DeleteStepInput): Step
|
||||
executeFlow(input: ExecuteFlowInput): executeFlowType
|
||||
|
@@ -1,6 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
export const DELETE_CURRENT_USER = gql`
|
||||
mutation DeleteCurrentUser {
|
||||
deleteCurrentUser
|
||||
}
|
||||
`;
|
Reference in New Issue
Block a user