Skip to content

Commit c68ac53

Browse files
authored
refactor: Remove global references to Meteor (RocketChat#39316)
1 parent 08c8d70 commit c68ac53

27 files changed

Lines changed: 39 additions & 5 deletions

File tree

apps/meteor/app/2fa/server/code/PasswordCheckFallback.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { IUser } from '@rocket.chat/core-typings';
22
import { Accounts } from 'meteor/accounts-base';
3+
import type { Meteor } from 'meteor/meteor';
34

45
import type { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck';
56
import { settings } from '../../../settings/server';

apps/meteor/app/lib/server/functions/joinDefaultChannels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Users } from '@rocket.chat/models';
2+
import { Meteor } from 'meteor/meteor';
23

34
import { addUserToDefaultChannels } from './addUserToDefaultChannels';
45

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { getPaginationItems } from '../../../../api/server/helpers/getPagination
1818
import { findInquiries, findOneInquiryByRoomId } from '../../../server/api/lib/inquiries';
1919
import { returnRoomAsInquiry } from '../../../server/lib/rooms';
2020
import { takeInquiry } from '../../../server/lib/takeInquiry';
21+
import { Meteor } from 'meteor/meteor';
2122

2223
API.v1.addRoute(
2324
'livechat/inquiries.list',

apps/meteor/app/livechat/server/api/v1/room.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from '@rocket.chat/rest-typings';
2929
import { isPOSTLivechatVisitorDepartmentTransferParams } from '@rocket.chat/rest-typings/src/v1/omnichannel';
3030
import { check } from 'meteor/check';
31+
import { Meteor } from 'meteor/meteor';
3132

3233
import { callbacks } from '../../../../../server/lib/callbacks';
3334
import { i18n } from '../../../../../server/lib/i18n';
@@ -67,7 +68,7 @@ API.v1.addRoute(
6768
agentId: Match.Maybe(String),
6869
});
6970

70-
check(this.queryParams, extraCheckParams as any);
71+
check(this.queryParams, extraCheckParams);
7172

7273
const { token, rid, agentId, ...extraParams } = this.queryParams;
7374

@@ -291,7 +292,7 @@ API.v1.addRoute(
291292
};
292293

293294
const room = await LivechatRooms.findOneById(this.bodyParams.roomId);
294-
if (!room || room.t !== 'l') {
295+
if (room?.t !== 'l') {
295296
throw new Error('error-invalid-room');
296297
}
297298

@@ -358,7 +359,7 @@ const livechatVisitorDepartmentTransfer = API.v1.post(
358359
}
359360
const room = await LivechatRooms.findOneById(rid);
360361

361-
if (!room || room.t !== 'l') {
362+
if (room?.t !== 'l') {
362363
return API.v1.failure('error-invalid-room');
363364
}
364365

@@ -463,7 +464,7 @@ API.v1.addRoute(
463464

464465
const firstError = result.find((item) => item.status === 'rejected');
465466
if (firstError) {
466-
throw new Error((firstError as PromiseRejectedResult).reason.error);
467+
throw new Error(firstError.reason.error);
467468
}
468469

469470
await callbacks.run('livechat.saveInfo', await LivechatRooms.findOneById(roomData._id), {

apps/meteor/app/livechat/server/lib/rooms.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
Users,
2222
ReadReceipts,
2323
} from '@rocket.chat/models';
24+
import { Meteor } from 'meteor/meteor';
2425

2526
import { normalizeTransferredByData } from './Helper';
2627
import { QueueManager } from './QueueManager';

apps/meteor/app/livechat/server/lib/sendTranscript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { MessageTypes } from '@rocket.chat/message-types';
1515
import { LivechatRooms, Messages, Uploads, Users } from '@rocket.chat/models';
1616
import createDOMPurify from 'dompurify';
1717
import { JSDOM } from 'jsdom';
18+
import { Meteor } from 'meteor/meteor';
1819
import moment from 'moment-timezone';
1920

2021
import { callbacks } from '../../../../server/lib/callbacks';

apps/meteor/app/slashcommands-leave/server/leave.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { api } from '@rocket.chat/core-services';
22
import type { SlashCommandCallbackParams } from '@rocket.chat/core-typings';
33
import { Users } from '@rocket.chat/models';
4+
import { Meteor } from 'meteor/meteor';
45

56
import { i18n } from '../../../server/lib/i18n';
67
import { leaveRoomMethod } from '../../lib/server/methods/leaveRoom';

apps/meteor/client/lib/2fa/overrideLoginMethod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Accounts } from 'meteor/accounts-base';
2+
import type { Meteor } from 'meteor/meteor';
23

34
import { isTotpInvalidError, isTotpMaxAttemptsError, isTotpRequiredError } from './utils';
45

apps/meteor/client/lib/2fa/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Meteor } from 'meteor/meteor';
2+
13
export const isTotpRequiredError = (
24
error: unknown,
35
): error is Meteor.Error & ({ error: 'totp-required' } | { errorType: 'totp-required' }) =>

apps/meteor/client/meteor/minimongo/DiffSequence.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Meteor } from 'meteor/meteor';
2+
13
import type { IdMap } from './IdMap';
24
import { clone, hasOwn, equals } from './common';
35
import type { Observer, OrderedObserver, UnorderedObserver } from './observers';

0 commit comments

Comments
 (0)