유명현

EDIT: 12 mamuls in one Carousel

......@@ -26,7 +26,7 @@ const checkMamul = (client, userId) => {
db.getKeywordsByUserId(userId).then((keywords) => {
for (let i = 0, pending = Promise.resolve(); i < keywords.length; i++) {
pending = marketMultiSearch(keywords[i]).then((res) => {
client.multicast([userId], [setCarouselMessage(res, keywords[i])]);
client.pushMessage(userId, setCarouselMessage(res, keywords[i]));
});
}
});
......
......@@ -4,9 +4,19 @@ function setCarouselMessage(mamuls, keyword) {
let flexMessages = [];
let flexMessage = {};
if (
mamuls[0] == undefined &&
mamuls[1] == undefined &&
mamuls[2] == undefined
mamuls[0] == undefined
// &&
// mamuls[1] == undefined &&
// mamuls[2] == undefined &&
// mamuls[3] == undefined &&
// mamuls[4] == undefined &&
// mamuls[5] == undefined &&
// mamuls[6] == undefined &&
// mamuls[7] == undefined &&
// mamuls[8] == undefined &&
// mamuls[9] == undefined &&
// mamuls[10] == undefined &&
// mamuls[11] == undefined
) {
let nonMamulMessage = {
type: "flex",
......
const { daangnSingleSearch } = require("./daangnSearch");
const { bunjangSingleSearch } = require("./bunjangSearch");
const { joongnaSingleSearch } = require("./joongnaSearch");
const { daangnMultiSearch } = require("./daangnSearch");
const { bunjangMultiSearch } = require("./bunjangSearch");
const { joongnaMultiSearch } = require("./joongnaSearch");
const setCarouselMessage = require("../message/setCarouselMessage");
const marketMultiSearch = (keyword) => {
const result = [];
return new Promise((resolve, reject) => {
daangnSingleSearch(keyword).then((res) => {
result.push(res);
bunjangSingleSearch(keyword).then((res) => {
result.push(res);
joongnaSingleSearch(keyword).then((res) => {
result.push(res);
daangnMultiSearch(keyword).then((res) => {
if (res !== undefined) {
for (let i = 0; i < res.length && i < 4; i++) {
result.push(res[i]);
}
}
bunjangMultiSearch(keyword).then((res) => {
if (res !== undefined) {
for (let i = 0; i < res.length && i < 4; i++) {
result.push(res[i]);
}
}
joongnaMultiSearch(keyword).then((res) => {
if (res !== undefined) {
for (let i = 0; i < res.length && i < 4; i++) {
result.push(res[i]);
}
}
resolve(result);
});
});
......