Skip to content

Commit 02e1b50

Browse files
authored
Merge branch 'develop' into fix/user-data-download-cron-identifier
2 parents 22e0b04 + 2c23512 commit 02e1b50

File tree

5 files changed

+461
-25
lines changed

5 files changed

+461
-25
lines changed

.changeset/tame-dolphins-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rocket.chat/meteor": patch
3+
---
4+
5+
Fixes `inquiries.take` not failing when attempting to take a chat while over chat limits

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

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,29 +306,53 @@ API.v1.addRoute(
306306
},
307307
);
308308

309-
API.v1.addRoute(
310-
'rooms.saveNotification',
311-
{ authRequired: true },
312-
{
313-
async post() {
314-
const { roomId, notifications } = this.bodyParams;
309+
const saveNotificationBodySchema = ajv.compile<{
310+
roomId: string;
311+
notifications: Record<string, string>;
312+
}>({
313+
type: 'object',
314+
properties: {
315+
roomId: { type: 'string', minLength: 1 },
316+
notifications: {
317+
type: 'object',
318+
minProperties: 1,
319+
additionalProperties: { type: 'string' },
320+
},
321+
},
322+
required: ['roomId', 'notifications'],
323+
additionalProperties: false,
324+
});
315325

316-
if (!roomId) {
317-
return API.v1.failure("The 'roomId' param is required");
318-
}
326+
const saveNotificationResponseSchema = ajv.compile({
327+
type: 'object',
328+
properties: {
329+
success: { type: 'boolean', enum: [true] },
330+
},
331+
required: ['success'],
332+
additionalProperties: false,
333+
});
319334

320-
if (!notifications || Object.keys(notifications).length === 0) {
321-
return API.v1.failure("The 'notifications' param is required");
322-
}
335+
const roomsSaveNotificationEndpoint = API.v1.post(
336+
'rooms.saveNotification',
337+
{
338+
authRequired: true,
339+
body: saveNotificationBodySchema,
340+
response: {
341+
200: saveNotificationResponseSchema,
342+
400: validateBadRequestErrorResponse,
343+
401: validateUnauthorizedErrorResponse,
344+
},
345+
},
346+
async function action() {
347+
const { roomId, notifications } = this.bodyParams;
323348

324-
await Promise.all(
325-
Object.entries(notifications as Notifications).map(async ([notificationKey, notificationValue]) =>
326-
saveNotificationSettingsMethod(this.userId, roomId, notificationKey as NotificationFieldType, notificationValue),
327-
),
328-
);
349+
await Promise.all(
350+
Object.entries(notifications as Notifications).map(async ([notificationKey, notificationValue]) =>
351+
saveNotificationSettingsMethod(this.userId, roomId, notificationKey as NotificationFieldType, notificationValue),
352+
),
353+
);
329354

330-
return API.v1.success();
331-
},
355+
return API.v1.success({ success: true });
332356
},
333357
);
334358

@@ -1213,7 +1237,8 @@ export const roomEndpoints = API.v1
12131237

12141238
type RoomEndpoints = ExtractRoutesFromAPI<typeof roomEndpoints> &
12151239
ExtractRoutesFromAPI<typeof roomEndpoints> &
1216-
ExtractRoutesFromAPI<typeof roomDeleteEndpoint>;
1240+
ExtractRoutesFromAPI<typeof roomDeleteEndpoint> &
1241+
ExtractRoutesFromAPI<typeof roomsSaveNotificationEndpoint>;
12171242

12181243
declare module '@rocket.chat/rest-typings' {
12191244
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface

apps/meteor/app/livechat/imports/server/rest/inquiries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ API.v1.addRoute(
6969
return API.v1.failure('The user is invalid');
7070
}
7171
return API.v1.success({
72-
inquiry: await takeInquiry(this.bodyParams.userId || this.userId, this.bodyParams.inquiryId),
72+
inquiry: await takeInquiry(this.bodyParams.userId || this.userId, this.bodyParams.inquiryId, this.bodyParams.options),
7373
});
7474
},
7575
},

0 commit comments

Comments
 (0)