oak-general-business/lib/triggers/wechatMpJump.js

35 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = require("oak-domain/lib/utils/assert");
const wechatMpJump_1 = require("../aspects/wechatMpJump");
const triggers = [
{
name: '当创建WechatMpJump时生成openlink',
entity: 'wechatMpJump',
action: 'create',
when: 'before',
fn: async ({ operation }, context, params) => {
const { data, filter } = operation;
const fn = async (wechatMpJumpData) => {
const { jump_wxa, expiresAt, expireType, expireInterval } = wechatMpJumpData;
const applicationId = context.getApplicationId();
(0, assert_1.assert)(applicationId);
const openlink = await (0, wechatMpJump_1.wechatMpJump)({ applicationId, jump_wxa: jump_wxa, expiresAt: expiresAt, expireType: expireType, expireInterval: expireInterval }, context);
Object.assign(wechatMpJumpData, {
openlink
});
};
if (data instanceof Array) {
for (const ele of data) {
await fn(ele);
}
}
else {
await fn(data);
}
return 0;
},
},
];
exports.default = triggers;