feat: refactor delete user mutation with the REST API endpoint

This commit is contained in:
kasia.oczkowska
2024-07-18 10:14:46 +01:00
committed by Faruk AYDIN
parent 0e26032ac3
commit 1aa1f441b3
7 changed files with 25 additions and 46 deletions

View File

@@ -1,24 +0,0 @@
import { Duration } from 'luxon';
import User from '../../models/user.js';
import deleteUserQueue from '../../queues/delete-user.ee.js';
const deleteUser = async (_parent, params, context) => {
context.currentUser.can('delete', 'User');
const id = params.input.id;
await User.query().deleteById(id);
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 deleteUser;