This commit is contained in:
aozhiwei 2024-06-11 11:24:19 +08:00
parent 442c3ac229
commit cf27afb5b2

View File

@ -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() {