유명현

EDIT: 12 mamuls in one Carousel

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