박찬수

Push 한 사용자에게만 가도록 수정

......@@ -7,30 +7,36 @@ const TOKEN = 'XOyIf8jsoQKq3b1zqxE4wawAoFU2Hz433AO3w8/ye+i6+2KrXpyfFwY0Dk/xhHQLP
const USER_ID = 'Uc4258407a7677769f74ba184ec036651'
//Single User
// request.post(
// {
// url: TARGET_URL,
// headers: {
// 'Authorization': `Bearer ${TOKEN}`
// },
// json: {
// "to": `${USER_ID}`,
// "messages":[
// {
// "type":"text",
// "text":"Hello, user"
// },
// {
// "type":"text",
// "text":"May I help you?"
// }
// ]
// }
// },(error, response, body) => {
// console.log(body)
// });
function SingleCast(sendMsg, destination){
USER_ID = destination;
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"to": `${USER_ID}`,
"messages":[
{
"type":"text",
"text":sendMsg
},
{
"type":"text",
"text":"May I help you?"
}
]
}
},(error, response, body) => {
console.log(body)
});
}
// Multicast User
function Multicast(sendMsg){
......@@ -78,6 +84,6 @@ function Broadcast(msg){
});
}
exports.SendMessage = function(sendMessage){
Broadcast(sendMessage);
exports.SendMessage = function(sendMessage, destination){
SingleCast(sendMessage, destination);
}
\ No newline at end of file
......
......@@ -24,7 +24,7 @@ var step = 0;
var currentLeagueID = 0;
var currentTeamID = 0;
push.SendMessage(DefaultSelectMessage());
//push.SendMessage(DefaultSelectMessage());
data.SetData();
......@@ -211,7 +211,7 @@ function SelectLeagueInfo(eventObj, inputNum){
});
break;
case 4: // 처음으로
SetDefault();
SetDefault(eventObj.source.userId);
break;
default:
break;
......@@ -219,9 +219,9 @@ function SelectLeagueInfo(eventObj, inputNum){
return returnMsg;
}
function SetDefault(){
function SetDefault(userID){
step = 0;
push.SendMessage(DefaultSelectMessage());
push.SendMessage(DefaultSelectMessage(), userID);
}
function MakeReplyMessage(title, keys, values){
......