|
|
@ -68,9 +68,11 @@ const getMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () |
|
|
|
}); |
|
|
|
exports.getMessages = getMessages; |
|
|
|
const getAllMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* () { |
|
|
|
const messages = yield models_1.models.Message.findAll({ order: [['id', 'asc']] }); |
|
|
|
const limit = (req.query.limit && parseInt(req.query.limit)) || 1000; |
|
|
|
const offset = (req.query.offset && parseInt(req.query.offset)) || 0; |
|
|
|
const messages = yield models_1.models.Message.findAll({ order: [['id', 'asc']], limit, offset }); |
|
|
|
const chatIds = messages.map(m => m.chatId); |
|
|
|
console.log('=> getAllMessages, chatIds', chatIds); |
|
|
|
console.log(`=> getAllMessages, limit: ${limit}, offset: ${offset}`); |
|
|
|
let chats = chatIds.length > 0 ? yield models_1.models.Chat.findAll({ where: { deleted: false, id: chatIds } }) : []; |
|
|
|
const chatsById = underscore_1.indexBy(chats, 'id'); |
|
|
|
res_1.success(res, { |
|
|
@ -78,6 +80,7 @@ const getAllMessages = (req, res) => __awaiter(void 0, void 0, void 0, function* |
|
|
|
confirmed_messages: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
exports.getAllMessages = getAllMessages; |
|
|
|
function deleteMessage(req, res) { |
|
|
|
return __awaiter(this, void 0, void 0, function* () { |
|
|
|
const id = req.params.id; |
|
|
|