UNPKG

@coko/server

Version:

Reusable server for use by Coko's projects

22 lines 1.13 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.messagesBasedOnChatChannelIdsLoader = void 0; const logger_1 = __importDefault(require("../../logger")); const chatMessage_model_1 = __importDefault(require("./chatMessage.model")); const constants_1 = require("./constants"); const { CHAT_MESSAGE_LOADER } = constants_1.labels; const messagesBasedOnChatChannelIdsLoader = async (chatChannelIds) => { try { const chatChannelMessages = await chatMessage_model_1.default.query().whereIn('chatChannelId', chatChannelIds); return chatChannelIds.map(chatChannelId => chatChannelMessages.filter(chatMessage => chatMessage.chatChannelId === chatChannelId)); } catch (e) { logger_1.default.error(`${CHAT_MESSAGE_LOADER} messagesBasedOnChatChannelIdsLoader: ${e.message}`); throw e; } }; exports.messagesBasedOnChatChannelIdsLoader = messagesBasedOnChatChannelIdsLoader; //# sourceMappingURL=chatMessage.loaders.js.map