This commit is contained in:
aozhiwei 2024-06-11 17:00:31 +08:00
parent 7b9823531c
commit 4d2538531f
2 changed files with 2 additions and 12 deletions

View File

@ -407,8 +407,6 @@ DROP TABLE IF EXISTS `t_webhook_event`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_webhook_event` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`message_type` varchar(255) NOT NULL DEFAULT '' COMMENT 'message_type',
`message_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'message_id',
`event_name` varchar(255) NOT NULL DEFAULT '' COMMENT 'event_name',
`event_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'event_id',
`chain` varchar(255) NOT NULL DEFAULT '' COMMENT 'chain',
@ -419,8 +417,6 @@ CREATE TABLE `t_webhook_event` (
UNIQUE KEY `event_id` (`event_id`),
KEY `idx_event_name` (`event_name`),
KEY `idx_chain` (`chain`),
KEY `idx_message_id` (`message_id`),
KEY `idx_message_type` (`message_type`),
KEY `idx_event_name_chain` (`event_name`, `chain`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@ -12,18 +12,17 @@ async function procEvent(req, rsp) {
async function webhooks(req, rsp) {
console.log(req.body);
const events = [];
await webhook.handle( // this method will handle the subscription confirmation and signature & sender verification
req.body,
config.Environment.SANDBOX, // or config.Environment.PRODUCTION
{
all: (event) => { // all events will trigger this handler, even if they have a specific handler already.
console.log(111111, event);
events.push(event);
}
}
);
rsp.send(utils.jsonEncode({"status": "ok"}));
/*
const idx = 0;
const dbKey = 'BcEventDb' + idx;
const {err, conn} = await app.getDbConn(dbKey);
@ -34,8 +33,6 @@ async function webhooks(req, rsp) {
}
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;
@ -46,8 +43,6 @@ async function webhooks(req, rsp) {
],
[],
[
['message_type', messageType],
['message_id', messageId],
['event_name', eventName],
['event_id', eventId],
['chain', chain],
@ -61,7 +56,6 @@ async function webhooks(req, rsp) {
} finally {
conn.release();
}
*/
}
function init() {