Commit bf38471a by 庄冰

feishu notifu

parent 3705d4b2
...@@ -12,12 +12,32 @@ class UtilsFeishuService{ ...@@ -12,12 +12,32 @@ class UtilsFeishuService{
app_secret:"zL1uRrWFzwhFbLWZrmSuCh72JGjJXQg0" app_secret:"zL1uRrWFzwhFbLWZrmSuCh72JGjJXQg0"
} }
}; };
//飞书通知
async notify(pobj){
if(!pobj || !pobj.type){
return system.getResultFail("参数错误");
}
if(pobj.type=="url_verification"){//表示这是一个验证请求
return this.subscribeVerification(pobj);
}
if(pobj.type=="event_callback"){//事件回调
if(!pobj.event){
return system.getResultFail("event参数错误");
}
var event = pobj.event;
if(event.type=="app_ticket"){//app_ticket 事件
return this.receiveAppTicket(pobj);
}else{
return system.getResultFail("未知事件");
}
}
}
//订阅验证 //订阅验证
async subscribeVerification(pobj){ async subscribeVerification(pobj){
if(pobj && pobj.challenge){ if(pobj && pobj.challenge){
return system.getResultSuccess(pobj.challenge); return {"challenge":pobj.challenge};
}else{ }else{
return system.getResultFail(); return {};
} }
} }
//接收app_ticket //接收app_ticket
......
...@@ -378,6 +378,28 @@ module.exports = function (app) { ...@@ -378,6 +378,28 @@ module.exports = function (app) {
}); });
} }
}); });
//飞书通知
app.use('/feishu/notify', async function (req, res) {
try {
var client_ip = system.get_client_ip(req);
var result = await utilsFeishuSve.notify(req.body);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "飞书小程序记录回调处理结果,method=notify",
op: "app/config/routes/api.js/feishu/notify",
content: "回调参数:" + JSON.stringify(req.body) + "回调结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
var returnObj = JSON.stringify(result);
return res.end(returnObj);
} catch (error) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "飞书小程序记录回调处理结果异常:,method=notify",
op: "app/config/routes/api.js/feishu/notify",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
}
});
//----------------------飞书小程序---------------------------------------------结束 //----------------------飞书小程序---------------------------------------------结束
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment