Debug API delete user

This commit is contained in:
lethemanh
2025-04-26 13:56:54 +07:00
committed by Anton Shepilov
parent 58f8fed56f
commit 0989d2f3c3
2 changed files with 7 additions and 0 deletions
@@ -44,6 +44,7 @@ export class AdminDeleteUserController {
} as unknown as ExecutionContext, } as unknown as ExecutionContext,
deleteData, deleteData,
); );
adminLogger.info({ data }, "Anonymize and delete data");
if (data.isDeleted) if (data.isDeleted)
return { return {
@@ -51,6 +52,7 @@ export class AdminDeleteUserController {
userId: data.userId, userId: data.userId,
}; };
const existingUser = await (await this.getRepos()).user.findOne({ id: userId }); const existingUser = await (await this.getRepos()).user.findOne({ id: userId });
adminLogger.info({ existingUser }, "Existing user data");
if (existingUser?.deleted) { if (existingUser?.deleted) {
if (existingUser.delete_process_started_epoch > 0) { if (existingUser.delete_process_started_epoch > 0) {
return { return {
@@ -66,6 +68,7 @@ export class AdminDeleteUserController {
userId, userId,
}; };
} }
adminLogger.info({ userId }, "Return delete result");
return { return {
status: "done", status: "done",
userId, userId,
@@ -33,6 +33,7 @@ import gr from "../../../global-resolver";
import { TYPE as DriveFileType, DriveFile } from "../../../documents/entities/drive-file"; import { TYPE as DriveFileType, DriveFile } from "../../../documents/entities/drive-file";
import { UpdateUser } from "./types"; import { UpdateUser } from "./types";
import { formatUsername } from "../../../../utils/users"; import { formatUsername } from "../../../../utils/users";
import { logger } from "../../../../core/platform/framework";
export class UserServiceImpl { export class UserServiceImpl {
version: "1"; version: "1";
@@ -166,6 +167,7 @@ export class UserServiceImpl {
/** If `deleteData` is false, then the user is only marked deleted and no data is actually deleted */ /** If `deleteData` is false, then the user is only marked deleted and no data is actually deleted */
async anonymizeAndDelete(pk: UserPrimaryKey, context?: ExecutionContext, deleteData?: boolean) { async anonymizeAndDelete(pk: UserPrimaryKey, context?: ExecutionContext, deleteData?: boolean) {
const user = await this.get(pk); const user = await this.get(pk);
logger.info({ user }, "Delete user data");
if (context.user.server_request || context.user.id === user.id) { if (context.user.server_request || context.user.id === user.id) {
const userCopy = getUserInstance(user); const userCopy = getUserInstance(user);
@@ -188,6 +190,8 @@ export class UserServiceImpl {
await gr.services.console.getClient().userWasDeletedForceLogout(user.id); await gr.services.console.getClient().userWasDeletedForceLogout(user.id);
await this.save(user); await this.save(user);
logger.info({ user }, "User was updated");
} }
localEventBus.publish<ResourceEventsPayload>("user:deleted", { localEventBus.publish<ResourceEventsPayload>("user:deleted", {