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,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RestoreChatCommandHandler = exports.ArchiveChatCommandHandler = void 0;
const ChatAggregate_1 = require("../../../Domain/Chat/ChatAggregate");
const Logger_1 = require("../../Services/Logger");
class ArchiveChatCommandHandler {
constructor(chatRepository) {
this.chatRepository = chatRepository;
}
async execute(command) {
try {
const chat = await this.chatRepository.findById(command.chatId);
if (!chat) {
throw new Error('Chat not found');
}
await this.chatRepository.archiveChat(chat);
(0, Logger_1.logAuth)('Chat archived manually', undefined, {
chatId: command.chatId,
chatType: chat.type,
messageCount: chat.messages.length
});
return true;
}
catch (error) {
(0, Logger_1.logError)('ArchiveChatCommandHandler error', error);
return false;
}
}
}
exports.ArchiveChatCommandHandler = ArchiveChatCommandHandler;
class RestoreChatCommandHandler {
constructor(chatRepository) {
this.chatRepository = chatRepository;
}
async execute(command) {
try {
const archive = await this.chatRepository.getArchivedChat(command.chatId);
if (!archive) {
throw new Error('Archived chat not found');
}
// Game chats cannot be restored, only viewed
if (archive.chatType === ChatAggregate_1.ChatType.GAME) {
(0, Logger_1.logWarning)('Attempt to restore game chat blocked', {
chatId: command.chatId,
chatType: archive.chatType
});
return false;
}
const restoredChat = await this.chatRepository.restoreFromArchive(command.chatId);
if (!restoredChat) {
throw new Error('Failed to restore chat from archive');
}
(0, Logger_1.logAuth)('Chat restored from archive', undefined, {
chatId: command.chatId,
messageCount: archive.archivedMessages.length
});
return true;
}
catch (error) {
(0, Logger_1.logError)('RestoreChatCommandHandler error', error);
return false;
}
}
}
exports.RestoreChatCommandHandler = RestoreChatCommandHandler;
//# sourceMappingURL=ChatArchiveCommandHandlers.js.map