'use strict'; class CustomizeWebhookDriver { constructor(ctx, options = {}) { this.ctx = ctx; this.options = options; } async send({ hook, payload }) { const requestOptions = { method: 'POST', headers: { 'content-type': 'application/json', }, timeout: 5000, dataType: 'json', contentType: 'json', data: payload, }; this.ctx.logger.info('[CustomizeWebhookDriver.send] 发送内容', { hookUrl: String(hook && hook.hook_url || '').substring(0, 80), hookType: String(hook && hook.hook_type || 'customize'), payloadKeys: Object.keys(payload || {}), }); const response = await this.ctx.curl(String(hook.hook_url || ''), requestOptions); return { hookId: Number(hook && hook.id) || 0, hookType: String(hook && hook.hook_type || this.options.hookType || 'customize'), hookUrl: String(hook && hook.hook_url || ''), status: Number(response && response.status) || 200, response: response && response.data !== undefined ? response.data : null, }; } } module.exports = CustomizeWebhookDriver;