https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteContactCommandHandler = void 0;
const Logger_1 = require("../../Services/Logger");
class DeleteContactCommandHandler {
constructor(contactRepo) {
this.contactRepo = contactRepo;
}
async execute(cmd) {
try {
const existingContact = await this.contactRepo.findById(cmd.id);
if (!existingContact) {
throw new Error('Contact not found');
}
if (cmd.hard) {
// Permanent delete
await this.contactRepo.delete(cmd.id);
(0, Logger_1.logRequest)('Contact hard deleted', undefined, undefined, {
contactId: cmd.id,
contactEmail: existingContact.email,
deleteType: 'hard'
});
}
else {
// Soft delete (default)
await this.contactRepo.softDelete(cmd.id);
(0, Logger_1.logRequest)('Contact soft deleted', undefined, undefined, {
contactId: cmd.id,
contactEmail: existingContact.email,
deleteType: 'soft'
});
}
return true;
}
catch (error) {
if (error instanceof Error && error.message === 'Contact not found') {
throw error;
}
throw new Error('Failed to delete contact');
}
}
}
exports.DeleteContactCommandHandler = DeleteContactCommandHandler;
//# sourceMappingURL=DeleteContactCommandHandler.js.map