feat: Implement isOwner flag for get flows API endpoint
This commit is contained in:
@@ -537,6 +537,8 @@ class User extends Base {
|
||||
.withGraphFetched({
|
||||
steps: true,
|
||||
})
|
||||
.select('flows.*')
|
||||
.select(Flow.raw('flows.user_id = ? as "isOwner"', [this.id]))
|
||||
.where((builder) => {
|
||||
if (name) {
|
||||
builder.where('flows.name', 'ilike', `%${name}%`);
|
||||
|
||||
@@ -1333,6 +1333,23 @@ describe('User model', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should return isOwner false if the flow is owned by another user', async () => {
|
||||
const anotherUser = await createUser();
|
||||
|
||||
await createFlow({
|
||||
userId: anotherUser.id,
|
||||
folderId: folder.id,
|
||||
active: true,
|
||||
name: 'Another User Flow One',
|
||||
});
|
||||
|
||||
const flows = await currentUser.getFlows({ onlyOwnedFlows: false }, [
|
||||
folder.id,
|
||||
]);
|
||||
|
||||
expect(flows[0].isOwner).toBe(false);
|
||||
});
|
||||
|
||||
it('should return specified flows with all filters together', async () => {
|
||||
const flows = await currentUser.getFlows(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user