fix(plugin-workflow-manual): flatten assignees, assignees parsing bug (#837)

Reviewed-on: daoyoucloud/tachybase#837
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
bai.zixv 2024-04-24 18:23:09 +08:00 committed by sealday
parent 021c8a9a16
commit 8dc7a09d29
2 changed files with 8 additions and 3 deletions

View File

@ -93,7 +93,7 @@ export default class extends Instruction {
async run(node, prevJob, processor: Processor) {
const { mode, ...config } = node.config as ManualConfig;
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id) || [])];
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id).flat().filter(Boolean))];
const job = await processor.saveJob({
status: JOB_STATUS.PENDING,
@ -124,7 +124,9 @@ export default class extends Instruction {
async resume(node, job, processor: Processor) {
// NOTE: check all users jobs related if all done then continue as parallel
const { assignees = [], mode } = node.config as ManualConfig;
const { mode } = node.config as ManualConfig;
const assignees = [...new Set(processor.getParsedValue(node.config.assignees, node.id).flat().filter(Boolean))];
const UserJobModel = this.workflow.app.db.getModel('users_jobs');
const distribution = await UserJobModel.count({

View File

@ -50,7 +50,10 @@ export async function submit(context: Context, next) {
await processor.prepare();
// NOTE: validate assignee
const assignees = processor.getParsedValue(userJob.node.config.assignees ?? [], userJob.nodeId);
const assignees = processor
.getParsedValue(userJob.node.config.assignees ?? [], userJob.nodeId)
.flat()
.filter(Boolean);
if (!assignees.includes(currentUser.id) || userJob.userId !== currentUser.id) {
return context.throw(403);
}