Skip to content

Commit dbc9643

Browse files
committed
fix: reverd useless changes
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 508ec66 commit dbc9643

5 files changed

Lines changed: 12 additions & 42 deletions

File tree

backend/src/api/member/memberExport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default async (req, res) => {
3232
args: [
3333
{
3434
tenantId: req.currentTenant.id,
35-
segmentIds: req.currentSegments.map((s: any) => s.id),
35+
segmentIds: req.body.segments,
3636
criteria: req.body,
3737
sendTo: [req.currentUser.email],
3838
} as ITriggerCSVExport,

backend/src/api/organization/organizationExport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default async (req, res) => {
3232
args: [
3333
{
3434
tenantId: req.currentTenant.id,
35-
segmentIds: req.currentSegments.map((s: any) => s.id),
35+
segmentIds: req.body.segments,
3636
criteria: req.body,
3737
sendTo: [req.currentUser.email],
3838
} as ITriggerCSVExport,

backend/src/api/segment/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { safeWrap } from '../../middlewares/errorMiddleware'
2-
import { segmentByIdMiddleware } from '../../middlewares/segmentMiddleware'
32

43
export default (app) => {
54
app.post(`/segment/projectGroup`, safeWrap(require('./segmentCreateProjectGroup').default))
@@ -21,14 +20,9 @@ export default (app) => {
2120
safeWrap(require('./segmentSubprojectQueryLite').default),
2221
)
2322

24-
// get/update segment by id — segmentByIdMiddleware overrides currentSegments with the target
25-
// segment so that permission checks validate against the actual resource being accessed
26-
app.get(`/segment/:segmentId`, segmentByIdMiddleware, safeWrap(require('./segmentFind').default))
27-
app.put(
28-
`/segment/:segmentId`,
29-
segmentByIdMiddleware,
30-
safeWrap(require('./segmentUpdate').default),
31-
)
23+
// get segment by id
24+
app.get(`/segment/:segmentId`, safeWrap(require('./segmentFind').default))
25+
app.put(`/segment/:segmentId`, safeWrap(require('./segmentUpdate').default))
3226
// Multiple ids
3327
app.post(`/segment/id`, safeWrap(require('./segmentByIds').default))
3428
}

backend/src/middlewares/segmentMiddleware.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,6 @@ import SegmentRepository from '../database/repositories/segmentRepository'
1111

1212
const log = getServiceChildLogger('segmentMiddleware')
1313

14-
/**
15-
* Route-specific middleware for endpoints with :segmentId param (e.g. PUT/GET /segment/:segmentId).
16-
*
17-
* The global segmentMiddleware runs via app.use() before Express matches routes, so req.params
18-
* is never populated there. This middleware is registered directly on the route handler, where
19-
* Express has already resolved :segmentId, and overrides req.currentSegments with the leaf
20-
* segments of the target segment so that permission checks validate against the actual resource
21-
* being accessed rather than whatever segments the caller chose to include in body/query.
22-
*/
23-
export async function segmentByIdMiddleware(req: Request, _res: Response, next: NextFunction) {
24-
try {
25-
const segmentId = req.params.segmentId
26-
if (segmentId) {
27-
const segmentRepository = new SegmentRepository(req as unknown as IRepositoryOptions)
28-
const resolved = await resolveToLeafSegments(segmentRepository, [segmentId], req)
29-
const options = req as unknown as IRepositoryOptions
30-
options.currentSegments = resolved
31-
}
32-
next()
33-
} catch (error) {
34-
next(error)
35-
}
36-
}
37-
3814
export async function segmentMiddleware(req: Request, _res: Response, next: NextFunction) {
3915
try {
4016
let segments: any = null

services/libs/data-access-layer/src/collections/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import { QueryOptions } from '../utils'
1616
export interface ICreateCollection {
1717
categoryId: string
1818
color?: string | null
19-
description?: string | null
19+
description?: string
2020
imageUrl?: string | null
2121
name: string
22-
slug?: string | null
22+
slug?: string
2323
starred: boolean
2424
isPrivate?: boolean
2525
ssoUserId?: string | null
@@ -139,12 +139,12 @@ export async function createCollection(
139139
collection: ICreateCollection,
140140
): Promise<ICollection> {
141141
const data = {
142+
description: null,
143+
slug: null,
144+
logoUrl: null,
145+
imageUrl: null,
146+
color: null,
142147
...collection,
143-
description: collection.description ?? null,
144-
slug: collection.slug ?? null,
145-
logoUrl: collection.logoUrl ?? null,
146-
imageUrl: collection.imageUrl ?? null,
147-
color: collection.color ?? null,
148148
}
149149
return qx.selectOne(
150150
`

0 commit comments

Comments
 (0)