feat: return sharees when returning a workflow (#4312) (no-changelog)
This commit is contained in:
@@ -6,6 +6,7 @@ import { WorkflowEntity } from '../databases/entities/WorkflowEntity';
|
||||
import { RoleService } from '../role/role.service';
|
||||
import { UserService } from '../user/user.service';
|
||||
import { WorkflowsService } from './workflows.services';
|
||||
import { WorkflowWithSharings } from './workflows.types';
|
||||
|
||||
export class EEWorkflowsService extends WorkflowsService {
|
||||
static async isOwned(
|
||||
@@ -70,4 +71,27 @@ export class EEWorkflowsService extends WorkflowsService {
|
||||
|
||||
return transaction.save(newSharedWorkflows);
|
||||
}
|
||||
|
||||
static addOwnerAndSharings(
|
||||
workflow: WorkflowEntity & WorkflowWithSharings,
|
||||
): WorkflowEntity & WorkflowWithSharings {
|
||||
workflow.ownedBy = null;
|
||||
workflow.sharedWith = [];
|
||||
|
||||
workflow.shared?.forEach(({ user, role }) => {
|
||||
const { id, email, firstName, lastName } = user;
|
||||
|
||||
if (role.name === 'owner') {
|
||||
workflow.ownedBy = { id, email, firstName, lastName };
|
||||
return;
|
||||
}
|
||||
|
||||
workflow.sharedWith?.push({ id, email, firstName, lastName });
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
delete workflow.shared;
|
||||
|
||||
return workflow;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user