Skip to content

Commit 1619cc9

Browse files
Merge branch 'develop' into bump-webpack
2 parents db4bf47 + 1198e51 commit 1619cc9

File tree

9 files changed

+33
-29
lines changed

9 files changed

+33
-29
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Logger } from '@rocket.chat/logger';
33
import { Users } from '@rocket.chat/models';
44
import { Random } from '@rocket.chat/random';
55
import type { JoinPathPattern, Method } from '@rocket.chat/rest-typings';
6+
import { wrapExceptions } from '@rocket.chat/tools';
67
import express from 'express';
78
import type { Request, Response } from 'express';
89
import { Accounts } from 'meteor/accounts-base';
@@ -404,10 +405,14 @@ export class APIClass<TBasePath extends string = ''> {
404405
public reloadRoutesToRefreshRateLimiter(): void {
405406
this._routes.forEach((route) => {
406407
if (this.shouldAddRateLimitToRoute(route.options)) {
407-
this.addRateLimiterRuleForRoutes({
408-
routes: [route.path],
409-
rateLimiterOptions: route.options.rateLimiterOptions || defaultRateLimiterOptions,
410-
endpoints: Object.keys(route.endpoints).filter((endpoint) => endpoint !== 'options'),
408+
wrapExceptions(() =>
409+
this.addRateLimiterRuleForRoutes({
410+
routes: [route.path],
411+
rateLimiterOptions: route.options.rateLimiterOptions || defaultRateLimiterOptions,
412+
endpoints: Object.keys(route.endpoints).filter((endpoint) => endpoint !== 'options'),
413+
}),
414+
).catch((error) => {
415+
console.error(error.message);
411416
});
412417
}
413418
});
@@ -426,10 +431,10 @@ export class APIClass<TBasePath extends string = ''> {
426431
throw new Meteor.Error('"rateLimiterOptions" must be an object');
427432
}
428433
if (!rateLimiterOptions.numRequestsAllowed) {
429-
throw new Meteor.Error('You must set "numRequestsAllowed" property in rateLimiter for REST API endpoint');
434+
throw new Meteor.Error(`You must set "numRequestsAllowed" property in rateLimiter for REST API endpoint: ${routes}`);
430435
}
431436
if (!rateLimiterOptions.intervalTimeInMS) {
432-
throw new Meteor.Error('You must set "intervalTimeInMS" property in rateLimiter for REST API endpoint');
437+
throw new Meteor.Error(`You must set "intervalTimeInMS" property in rateLimiter for REST API endpoint: ${routes}`);
433438
}
434439
const addRateLimitRuleToEveryRoute = (routes: string[]) => {
435440
routes.forEach((route) => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ API.v1.addRoute(
623623
authRequired: false,
624624
rateLimiterOptions: {
625625
numRequestsAllowed: settings.get('Rate_Limiter_Limit_RegisterUser') ?? 1,
626-
intervalTimeInMS: settings.get('API_Enable_Rate_Limiter_Limit_Time_Default'),
626+
intervalTimeInMS: settings.get('API_Enable_Rate_Limiter_Limit_Time_Default') ?? 600000,
627627
},
628628
validateParams: isUserRegisterParamsPOST,
629629
},

apps/meteor/app/lib/client/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import './startup/settingsOnLoadSiteUrl';
21
import '../lib/MessageTypes';
32
import './OAuthProxy';
43
import './methods/sendMessage';

apps/meteor/app/lib/client/startup/settingsOnLoadSiteUrl.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

apps/meteor/client/views/room/Header/RoomToolbox/hooks/useRoomToolboxActions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const useRoomToolboxActions = ({ actions, openTab }: Pick<RoomToolboxCont
2121
const hiddenActions = (!roomToolboxExpanded ? actions : [...appsActions, ...normalActions.slice(6)])
2222
.filter((item) => !item.disabled && !item.featured)
2323
.map((item) => ({
24-
'key': item.id,
2524
'content': t(item.title),
2625
'onClick':
2726
item.action ??
@@ -39,7 +38,7 @@ export const useRoomToolboxActions = ({ actions, openTab }: Pick<RoomToolboxCont
3938
return acc;
4039
}
4140

42-
const newSection = { id: group, key: item.key, title: group === 'apps' ? t('Apps') : '', items: [item] };
41+
const newSection = { id: group, title: group === 'apps' ? t('Apps') : '', items: [item] };
4342
acc.push(newSection);
4443

4544
return acc;

apps/meteor/client/views/room/HeaderV2/RoomToolbox/hooks/useRoomToolboxActions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const useRoomToolboxActions = ({ actions, openTab }: Pick<RoomToolboxCont
2121
const hiddenActions = (!roomToolboxExpanded ? actions : [...appsActions, ...normalActions.slice(6)])
2222
.filter((item) => !item.disabled && !item.featured)
2323
.map((item) => ({
24-
'key': item.id,
2524
'content': t(item.title),
2625
'onClick':
2726
item.action ??
@@ -39,7 +38,7 @@ export const useRoomToolboxActions = ({ actions, openTab }: Pick<RoomToolboxCont
3938
return acc;
4039
}
4140

42-
const newSection = { id: group, key: item.key, title: group === 'apps' ? t('Apps') : '', items: [item] };
41+
const newSection = { id: group, title: group === 'apps' ? t('Apps') : '', items: [item] };
4342
acc.push(newSection);
4443

4544
return acc;

apps/meteor/client/views/room/contextualBar/VideoConference/VideoConfPopups/VideoConfPopups.spec.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mockAppRoot } from '@rocket.chat/mock-providers';
2-
import { render, screen } from '@testing-library/react';
2+
import { render, screen, waitFor } from '@testing-library/react';
33

44
import VideoConfPopups from './VideoConfPopups';
55
import { createFakeRoom } from '../../../../../../tests/mocks/data';
@@ -18,5 +18,6 @@ test('should render video conference incoming popup', async () => {
1818
.build(),
1919
});
2020

21-
expect(await screen.findByRole('dialog')).toBeInTheDocument();
21+
await waitFor(() => screen.findByRole('dialog'));
22+
expect(screen.getByRole('dialog')).toBeInTheDocument();
2223
});

apps/meteor/client/views/root/AppLayout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PageLoading from './PageLoading';
55
import { useEscapeKeyStroke } from './hooks/useEscapeKeyStroke';
66
import { useGoogleTagManager } from './hooks/useGoogleTagManager';
77
import { useMessageLinkClicks } from './hooks/useMessageLinkClicks';
8+
import { useSettingsOnLoadSiteUrl } from './hooks/useSettingsOnLoadSiteUrl';
89
import { useAnalytics } from '../../../app/analytics/client/loadScript';
910
import { useLivechatEnterprise } from '../../../app/livechat-enterprise/hooks/useLivechatEnterprise';
1011
import { useNextcloud } from '../../../app/nextcloud/client/useNextcloud';
@@ -29,7 +30,7 @@ const AppLayout = () => {
2930
useAnalyticsEventTracking();
3031
useLoadRoomForAllowedAnonymousRead();
3132
useNotifyUser();
32-
33+
useSettingsOnLoadSiteUrl();
3334
useLivechatEnterprise();
3435
useNextcloud();
3536

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { useSetting } from '@rocket.chat/ui-contexts';
2+
import { useEffect } from 'react';
3+
4+
export const useSettingsOnLoadSiteUrl = () => {
5+
const siteUrl = useSetting('Site_Url') as string;
6+
7+
useEffect(() => {
8+
const value = siteUrl;
9+
if (value == null || value.trim() === '') {
10+
return;
11+
}
12+
(window as any).__meteor_runtime_config__.ROOT_URL = value;
13+
}, [siteUrl]);
14+
};

0 commit comments

Comments
 (0)