fix(plugin-workflow): defend unimplemented trigger type (#3263)

This commit is contained in:
Junyi 2023-12-25 23:59:45 +08:00 committed by GitHub
parent 28759aac07
commit b68fde9d47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -235,6 +235,10 @@ export default class WorkflowPlugin extends Plugin {
toggle(workflow: WorkflowModel, enable?: boolean) {
const type = workflow.get('type');
const trigger = this.triggers.get(type);
if (!trigger) {
this.getLogger(workflow.id).error(`trigger type ${workflow.type} of workflow ${workflow.id} is not implemented`);
return;
}
if (typeof enable !== 'undefined' ? enable : workflow.get('enabled')) {
// NOTE: remove previous listener if config updated
const prev = workflow.previous();