Skip to content

Commit 0b2adfd

Browse files
ggazzoclaude
andcommitted
fix(api): use forbidden() without args to preserve original error messages
The migrated endpoints were using forbidden('error-not-allowed') as a type workaround, but this changed the error response from 'unauthorized' to 'error-not-allowed', breaking existing tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 55583e9 commit 0b2adfd

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

apps/meteor/app/api/server/v1/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ API.v1.post(
391391
}
392392

393393
if (!(await canAccessRoomIdAsync(body.roomId, this.userId))) {
394-
return API.v1.forbidden('Not allowed');
394+
return API.v1.forbidden();
395395
}
396396

397397
const params = body.params ? body.params : '';
@@ -439,7 +439,7 @@ API.v1.get(
439439
}
440440

441441
if (!(await canAccessRoomIdAsync(query.roomId, this.userId))) {
442-
return API.v1.forbidden('Not allowed');
442+
return API.v1.forbidden();
443443
}
444444

445445
const params = query.params ? query.params : '';
@@ -477,7 +477,7 @@ API.v1.post(
477477
}
478478

479479
if (!(await canAccessRoomIdAsync(body.roomId, this.userId))) {
480-
return API.v1.forbidden('Not allowed');
480+
return API.v1.forbidden();
481481
}
482482

483483
const { params = '' } = body;

apps/meteor/app/api/server/v1/im.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const dmCloseAction = <Path extends string>(_path: Path): TypedAction<typeof dmC
198198
} else {
199199
const canAccess = await canAccessRoomIdAsync(roomId, this.userId);
200200
if (!canAccess) {
201-
return API.v1.forbidden('error-not-allowed');
201+
return API.v1.forbidden();
202202
}
203203

204204
const { subscription: subs } = await findDirectMessageRoom({ roomId }, this.userId);
@@ -247,7 +247,7 @@ const dmOpenAction = <Path extends string>(_path: Path): TypedAction<typeof dmOp
247247
const { roomId } = this.bodyParams;
248248
const canAccess = await canAccessRoomIdAsync(roomId, this.userId);
249249
if (!canAccess) {
250-
return API.v1.forbidden('error-not-allowed');
250+
return API.v1.forbidden();
251251
}
252252

253253
const { room, subscription } = await findDirectMessageRoom({ roomId }, this.userId);
@@ -302,7 +302,7 @@ const dmSetTopicAction = <Path extends string>(_path: Path): TypedAction<typeof
302302

303303
const canAccess = await canAccessRoomIdAsync(roomId, this.userId);
304304
if (!canAccess) {
305-
return API.v1.forbidden('error-not-allowed');
305+
return API.v1.forbidden();
306306
}
307307

308308
const { room } = await findDirectMessageRoom({ roomId }, this.userId);
@@ -387,14 +387,14 @@ const dmCountersAction = <Path extends string>(_path: Path): TypedAction<typeof
387387

388388
if (ruserId) {
389389
if (!access) {
390-
return API.v1.forbidden('error-not-allowed');
390+
return API.v1.forbidden();
391391
}
392392
user = ruserId;
393393
}
394394
const canAccess = await canAccessRoomIdAsync(roomId, user);
395395

396396
if (!canAccess) {
397-
return API.v1.forbidden('error-not-allowed');
397+
return API.v1.forbidden();
398398
}
399399

400400
const { room, subscription } = await findDirectMessageRoom({ roomId }, user);
@@ -466,7 +466,7 @@ const dmFilesAction = <Path extends string>(_path: Path): TypedAction<typeof dmF
466466

467467
const canAccess = await canAccessRoomIdAsync(room._id, this.userId);
468468
if (!canAccess) {
469-
return API.v1.forbidden('error-not-allowed');
469+
return API.v1.forbidden();
470470
}
471471

472472
const filter = {
@@ -528,7 +528,7 @@ const dmMembersAction = <Path extends string>(_path: Path): TypedAction<typeof d
528528

529529
const canAccess = await canAccessRoomIdAsync(room._id, this.userId);
530530
if (!canAccess) {
531-
return API.v1.forbidden('error-not-allowed');
531+
return API.v1.forbidden();
532532
}
533533

534534
const { offset, count } = await getPaginationItems(this.queryParams);
@@ -641,7 +641,7 @@ const dmMessagesAction = <Path extends string>(_path: Path): TypedAction<typeof
641641

642642
const canAccess = await canAccessRoomIdAsync(room._id, this.userId);
643643
if (!canAccess) {
644-
return API.v1.forbidden('error-not-allowed');
644+
return API.v1.forbidden();
645645
}
646646

647647
const { offset, count } = await getPaginationItems(this.queryParams);
@@ -727,7 +727,7 @@ const dmHistoryAction = <Path extends string>(_path: Path): TypedAction<typeof d
727727
const result = await getChannelHistory(objectParams);
728728

729729
if (!result) {
730-
return API.v1.forbidden('error-not-allowed');
730+
return API.v1.forbidden();
731731
}
732732

733733
return API.v1.success(result as Record<string, unknown>);

0 commit comments

Comments
 (0)