21 lines
793 B
JavaScript
21 lines
793 B
JavaScript
import { DATA_SUBSCRIBER_KEYS } from '../config/constants';
|
||
import assert from 'assert';
|
||
const triggers = [
|
||
{
|
||
name: '当account帐户的值发生变化时,向订阅者推送',
|
||
entity: 'account',
|
||
action: ['deposit', 'withdraw', 'withdrawBack', 'consume', 'loan', 'repay'],
|
||
check(operation) {
|
||
return operation.data.hasOwnProperty('total') || operation.data.hasOwnProperty('avail');
|
||
},
|
||
when: 'after',
|
||
fn: async ({ operation }, context, option) => {
|
||
const { id, filter } = operation;
|
||
assert(typeof filter?.id === 'string');
|
||
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${filter.id}`);
|
||
return 1;
|
||
},
|
||
},
|
||
];
|
||
export default triggers;
|