feat: Implement isOwner flag for connections get flows API endpoint
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { renderObject } from '../../../../helpers/renderer.js';
|
||||
import paginateRest from '../../../../helpers/pagination.js';
|
||||
import Flow from '../../../../models/flow.js';
|
||||
|
||||
export default async (request, response) => {
|
||||
const flowsQuery = request.currentUser.authorizedFlows
|
||||
@@ -11,6 +12,10 @@ export default async (request, response) => {
|
||||
.withGraphFetched({
|
||||
steps: true,
|
||||
})
|
||||
.select('flows.*')
|
||||
.select(
|
||||
Flow.raw('flows.user_id = ? as "isOwner"', [request.currentUser.id])
|
||||
)
|
||||
.where('steps.connection_id', request.params.connectionId)
|
||||
.orderBy('active', 'desc')
|
||||
.orderBy('updated_at', 'desc');
|
||||
|
||||
@@ -66,7 +66,8 @@ describe('GET /api/v1/connections/:connectionId/flows', () => {
|
||||
|
||||
const expectedPayload = await getFlowsMock(
|
||||
[currentUserFlowOne],
|
||||
[triggerStepFlowOne, actionStepFlowOne]
|
||||
[triggerStepFlowOne, actionStepFlowOne],
|
||||
currentUser.id
|
||||
);
|
||||
|
||||
expect(response.body).toStrictEqual(expectedPayload);
|
||||
@@ -120,7 +121,8 @@ describe('GET /api/v1/connections/:connectionId/flows', () => {
|
||||
|
||||
const expectedPayload = await getFlowsMock(
|
||||
[anotherUserFlowOne],
|
||||
[triggerStepFlowOne, actionStepFlowOne]
|
||||
[triggerStepFlowOne, actionStepFlowOne],
|
||||
currentUser.id
|
||||
);
|
||||
|
||||
expect(response.body).toStrictEqual(expectedPayload);
|
||||
|
||||
Reference in New Issue
Block a user