1
This commit is contained in:
parent
442c3ac229
commit
cf27afb5b2
@ -6,6 +6,39 @@ const metaFactory = require('../metadata/factory');
|
|||||||
const serviceFactory = require('../services/factory');
|
const serviceFactory = require('../services/factory');
|
||||||
|
|
||||||
async function webhooks(req, rsp) {
|
async function webhooks(req, rsp) {
|
||||||
|
console.log(req.body);
|
||||||
|
const idx = 0;
|
||||||
|
const dbKey = 'BcEventDb' + idx;
|
||||||
|
const {err, conn} = await app.getDbConn(dbKey);
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const body = req.body;
|
||||||
|
const messageType = body.Type;
|
||||||
|
const messageId = body.MessageId;
|
||||||
|
const eventName = body.Message.event_name;
|
||||||
|
const eventId = body.Message.event_id;
|
||||||
|
const chain = body.Message.chain;
|
||||||
|
conn.upsert(
|
||||||
|
't_webhook_event',
|
||||||
|
[
|
||||||
|
['event_id', eventId],
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
['message_type', messageType],
|
||||||
|
['message_id', messageId],
|
||||||
|
['event_name', eventName],
|
||||||
|
['event_id', eventId],
|
||||||
|
['chain', chain],
|
||||||
|
['raw_data', body],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
conn.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user