mirror of
https://github.com/RocketChat/Rocket.Chat.git
synced 2025-12-28 06:47:25 +00:00
Chore: ESLint warnings (#26504)
This commit is contained in:
parent
f45b9563f4
commit
f74ba4e587
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -7,6 +7,10 @@
|
||||
{
|
||||
"pattern": "apps/*",
|
||||
"changeProcessCWD": true
|
||||
},
|
||||
{
|
||||
"pattern": "ee/apps/*",
|
||||
"changeProcessCWD": true
|
||||
}
|
||||
],
|
||||
"typescript.tsdk": "./node_modules/typescript/lib",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { spawn, SpawnOptions } from 'child_process';
|
||||
import type { SpawnOptions } from 'child_process';
|
||||
import { spawn } from 'child_process';
|
||||
import * as path from 'path';
|
||||
|
||||
enum ModeParam {
|
||||
|
||||
@ -7,7 +7,7 @@ import type { IUser } from '@rocket.chat/core-typings';
|
||||
import { settings } from '../../../settings/server';
|
||||
import * as Mailer from '../../../mailer';
|
||||
import { Users } from '../../../models/server';
|
||||
import { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck';
|
||||
import type { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck';
|
||||
|
||||
export class EmailCheck implements ICodeCheck {
|
||||
public readonly name = 'email';
|
||||
|
||||
@ -2,7 +2,7 @@ import { Accounts } from 'meteor/accounts-base';
|
||||
import type { IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { settings } from '../../../settings/server';
|
||||
import { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck';
|
||||
import type { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck';
|
||||
|
||||
export class PasswordCheckFallback implements ICodeCheck {
|
||||
public readonly name = 'password';
|
||||
|
||||
@ -2,7 +2,7 @@ import type { IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { TOTP } from '../lib/totp';
|
||||
import { settings } from '../../../settings/server';
|
||||
import { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck';
|
||||
import type { ICodeCheck, IProcessInvalidCodeResult } from './ICodeCheck';
|
||||
|
||||
export class TOTPCheck implements ICodeCheck {
|
||||
public readonly name = 'totp';
|
||||
|
||||
@ -8,7 +8,7 @@ import { settings } from '../../../settings/server';
|
||||
import { TOTPCheck } from './TOTPCheck';
|
||||
import { EmailCheck } from './EmailCheck';
|
||||
import { PasswordCheckFallback } from './PasswordCheckFallback';
|
||||
import { ICodeCheck } from './ICodeCheck';
|
||||
import type { ICodeCheck } from './ICodeCheck';
|
||||
import { Users } from '../../../models/server';
|
||||
|
||||
export interface ITwoFactorOptions {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
import { checkCodeForUser, ITwoFactorOptions } from './code/index';
|
||||
import type { ITwoFactorOptions } from './code/index';
|
||||
import { checkCodeForUser } from './code/index';
|
||||
|
||||
export function twoFactorRequired<TFunction extends (this: Meteor.MethodThisType, ...args: any[]) => any>(
|
||||
fn: TFunction,
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { IMessage } from '@rocket.chat/core-typings';
|
||||
import type { IMessage } from '@rocket.chat/core-typings';
|
||||
|
||||
import { handleError } from '../../../../client/lib/utils/handleError';
|
||||
|
||||
// Action Links namespace creation.
|
||||
export const actionLinks = {
|
||||
actions: new Map<string, Function>(),
|
||||
register(name: string, fn: Function): void {
|
||||
actions: new Map<
|
||||
string,
|
||||
(message: IMessage, params: string, instance?: Blaze.TemplateInstance | ((actionId: string, context: string) => void)) => void
|
||||
>(),
|
||||
register(
|
||||
name: string,
|
||||
fn: (message: IMessage, params: string, instance?: Blaze.TemplateInstance | ((actionId: string, context: string) => void)) => void,
|
||||
): void {
|
||||
actionLinks.actions.set(name, fn);
|
||||
},
|
||||
// getMessage(name, messageId) {
|
||||
@ -42,8 +48,8 @@ export const actionLinks = {
|
||||
|
||||
// return message;
|
||||
// },
|
||||
run(method: string, message: IMessage, instance?: Blaze.TemplateInstance | Function): void {
|
||||
const actionLink = message.actionLinks && message.actionLinks.find((action) => action.method_id === method);
|
||||
run(method: string, message: IMessage, instance?: Blaze.TemplateInstance | ((actionId: string, context: string) => void)): void {
|
||||
const actionLink = message.actionLinks?.find((action) => action.method_id === method);
|
||||
|
||||
if (!actionLink) {
|
||||
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link');
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IMessage } from '@rocket.chat/core-typings';
|
||||
import type { IMessage } from '@rocket.chat/core-typings';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
import { getMessageForUser } from '../../../../server/lib/messages/getMessageForUser';
|
||||
|
||||
11
apps/meteor/app/api/server/api.d.ts
vendored
11
apps/meteor/app/api/server/api.d.ts
vendored
@ -11,7 +11,7 @@ import type { IUser, IMethodConnection, IRoom } from '@rocket.chat/core-typings'
|
||||
import type { ValidateFunction } from 'ajv';
|
||||
import type { Request, Response } from 'express';
|
||||
|
||||
import { ITwoFactorOptions } from '../../2fa/server/code';
|
||||
import type { ITwoFactorOptions } from '../../2fa/server/code';
|
||||
|
||||
type SuccessResult<T> = {
|
||||
statusCode: 200;
|
||||
@ -28,8 +28,8 @@ type FailureResult<T, TStack = undefined, TErrorType = undefined, TErrorDetails
|
||||
stack: TStack;
|
||||
errorType: TErrorType;
|
||||
details: TErrorDetails;
|
||||
} & (undefined extends TErrorType ? {} : { errorType: TErrorType }) &
|
||||
(undefined extends TErrorDetails ? {} : { details: TErrorDetails extends string ? unknown : TErrorDetails });
|
||||
} & (undefined extends TErrorType ? object : { errorType: TErrorType }) &
|
||||
(undefined extends TErrorDetails ? object : { details: TErrorDetails extends string ? unknown : TErrorDetails });
|
||||
};
|
||||
|
||||
type UnauthorizedResult<T> = {
|
||||
@ -80,7 +80,7 @@ type PartialThis = {
|
||||
type UserInfo = IUser & {
|
||||
email?: string;
|
||||
settings: {
|
||||
profile: {};
|
||||
profile: object;
|
||||
preferences: unknown;
|
||||
};
|
||||
avatarUrl: string;
|
||||
@ -167,7 +167,7 @@ type Operation<TMethod extends Method, TPathPattern extends PathPattern, TEndpoi
|
||||
action: Action<TMethod, TPathPattern, TEndpointOptions>;
|
||||
} & { twoFactorRequired: boolean });
|
||||
|
||||
type Operations<TPathPattern extends PathPattern, TOptions extends Options = {}> = {
|
||||
type Operations<TPathPattern extends PathPattern, TOptions extends Options = object> = {
|
||||
[M in MethodOf<TPathPattern> as Lowercase<M>]: Operation<Uppercase<M>, TPathPattern, TOptions>;
|
||||
};
|
||||
|
||||
@ -252,6 +252,7 @@ export declare const API: {
|
||||
v1: APIClass<'/v1'>;
|
||||
default: APIClass;
|
||||
helperMethods: Map<string, (...args: any[]) => unknown>;
|
||||
ApiClass: APIClass;
|
||||
};
|
||||
|
||||
export declare const defaultRateLimiterOptions: {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IUpload, IUser } from '@rocket.chat/core-typings';
|
||||
import type { IUpload, IUser } from '@rocket.chat/core-typings';
|
||||
import { Users } from '@rocket.chat/models';
|
||||
|
||||
export async function addUserToFileObj(files: IUpload[]): Promise<(IUpload & { user?: Pick<IUser, '_id' | 'name' | 'username'> })[]> {
|
||||
|
||||
@ -9,11 +9,11 @@ API.helperMethods.set('getUserFromParams', function _getUserFromParams(this: any
|
||||
let user;
|
||||
const params = this.requestParams();
|
||||
|
||||
if (params.userId && params.userId.trim()) {
|
||||
if (params.userId?.trim()) {
|
||||
user = Users.findOneById(params.userId) || doesntExist;
|
||||
} else if (params.username && params.username.trim()) {
|
||||
} else if (params.username?.trim()) {
|
||||
user = Users.findOneByUsernameIgnoringCase(params.username) || doesntExist;
|
||||
} else if (params.user && params.user.trim()) {
|
||||
} else if (params.user?.trim()) {
|
||||
user = Users.findOneByUsernameIgnoringCase(params.user) || doesntExist;
|
||||
} else {
|
||||
throw new Meteor.Error('error-user-param-not-provided', 'The required "userId" or "username" param was not provided');
|
||||
|
||||
@ -25,7 +25,7 @@ const getUserPreferences = (me: IUser): Record<string, unknown> => {
|
||||
API.helperMethods.set('getUserInfo', function _getUserInfo(me: IUser) {
|
||||
const verifiedEmail = isVerifiedEmail(me);
|
||||
|
||||
const userPreferences = (me.settings && me.settings.preferences) || {};
|
||||
const userPreferences = me.settings?.preferences ?? {};
|
||||
|
||||
return {
|
||||
...me,
|
||||
|
||||
@ -3,7 +3,7 @@ import { parse } from 'cookie';
|
||||
import { API } from '../api';
|
||||
|
||||
API.helperMethods.set('isWidget', function _isWidget() {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error 'this' implicitly has type 'any' because it does not have a type annotation.
|
||||
const { headers } = this.request;
|
||||
|
||||
const { rc_room_type: roomType, rc_is_widget: isWidget } = parse(headers.cookie || '');
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IEmailInbox } from '@rocket.chat/core-typings';
|
||||
import { InsertOneResult, UpdateResult, WithId } from 'mongodb';
|
||||
import type { IEmailInbox } from '@rocket.chat/core-typings';
|
||||
import type { Filter, InsertOneResult, Sort, UpdateResult, WithId } from 'mongodb';
|
||||
import { EmailInbox } from '@rocket.chat/models';
|
||||
|
||||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
|
||||
@ -11,11 +11,11 @@ export const findEmailInboxes = async ({
|
||||
pagination: { offset, count, sort },
|
||||
}: {
|
||||
userId: string;
|
||||
query?: {};
|
||||
query?: Filter<IEmailInbox>;
|
||||
pagination: {
|
||||
offset: number;
|
||||
count: number;
|
||||
sort?: {};
|
||||
sort?: Sort;
|
||||
};
|
||||
}): Promise<{
|
||||
emailInboxes: IEmailInbox[];
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IEmojiCustom } from '@rocket.chat/core-typings';
|
||||
import { Filter, FindOptions } from 'mongodb';
|
||||
import type { IEmojiCustom } from '@rocket.chat/core-typings';
|
||||
import type { Filter, FindOptions } from 'mongodb';
|
||||
import { EmojiCustom } from '@rocket.chat/models';
|
||||
|
||||
export async function findEmojisCustom({
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { Readable } from 'stream';
|
||||
import type { Readable } from 'stream';
|
||||
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import type { Request } from 'express';
|
||||
import busboy from 'busboy';
|
||||
import { ValidateFunction } from 'ajv';
|
||||
import type { ValidateFunction } from 'ajv';
|
||||
|
||||
type UploadResult = {
|
||||
file: Readable;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IRoom, ISubscription } from '@rocket.chat/core-typings';
|
||||
import type { IRoom, ISubscription } from '@rocket.chat/core-typings';
|
||||
import { Rooms } from '@rocket.chat/models';
|
||||
|
||||
import { hasPermissionAsync, hasAtLeastOnePermissionAsync } from '../../../authorization/server/functions/hasPermission';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { escapeRegExp } from '@rocket.chat/string-helpers';
|
||||
import { IUser } from '@rocket.chat/core-typings';
|
||||
import { Filter } from 'mongodb';
|
||||
import type { IUser } from '@rocket.chat/core-typings';
|
||||
import type { Filter } from 'mongodb';
|
||||
import { Users } from '@rocket.chat/models';
|
||||
import type { Mongo } from 'meteor/mongo';
|
||||
|
||||
@ -53,9 +53,8 @@ export async function findUsersToAutocomplete({
|
||||
|
||||
/**
|
||||
* Returns a new query object with the inclusive fields only
|
||||
* @param {Object} query search query for matching rows
|
||||
*/
|
||||
export function getInclusiveFields(query: { [k: string]: 1 }): {} {
|
||||
export function getInclusiveFields(query: Record<string, 1 | 0>): Record<string, 1> {
|
||||
const newQuery = Object.create(null);
|
||||
|
||||
for (const [key, value] of Object.entries(query)) {
|
||||
@ -69,9 +68,9 @@ export function getInclusiveFields(query: { [k: string]: 1 }): {} {
|
||||
|
||||
/**
|
||||
* get the default fields if **fields** are empty (`{}`) or `undefined`/`null`
|
||||
* @param {Object|null|undefined} fields the fields from parsed jsonQuery
|
||||
* @param fields the fields from parsed jsonQuery
|
||||
*/
|
||||
export function getNonEmptyFields(fields: { [k: string]: 1 | 0 }): { [k: string]: 1 } {
|
||||
export function getNonEmptyFields(fields: Record<string, 1 | 0>): Record<string, 1 | 0> {
|
||||
const defaultFields = {
|
||||
name: 1,
|
||||
username: 1,
|
||||
@ -93,7 +92,7 @@ export function getNonEmptyFields(fields: { [k: string]: 1 | 0 }): { [k: string]
|
||||
|
||||
/**
|
||||
* get the default query if **query** is empty (`{}`) or `undefined`/`null`
|
||||
* @param {Object|null|undefined} query the query from parsed jsonQuery
|
||||
* @param query the query from parsed jsonQuery
|
||||
*/
|
||||
export function getNonEmptyQuery<T extends IUser>(query: Mongo.Query<T> | undefined | null, canSeeAllUserInfo?: boolean): Mongo.Query<T> {
|
||||
const defaultQuery: Mongo.Query<IUser> = {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import type { Request, Response, NextFunction } from 'express';
|
||||
|
||||
import { Users } from '../../../models/server';
|
||||
import { oAuth2ServerAuth } from '../../../oauth2-server-config/server/oauth/oauth2-server';
|
||||
|
||||
@ -485,7 +485,7 @@ API.v1.addRoute(
|
||||
fields: { 'u._id': 1 },
|
||||
});
|
||||
|
||||
const members = subscriptions.fetch().map((s: ISubscription) => s.u && s.u._id);
|
||||
const members = subscriptions.fetch().map((s: ISubscription) => s.u?._id);
|
||||
|
||||
const teamData = {
|
||||
team: {
|
||||
|
||||
@ -5,7 +5,7 @@ import {
|
||||
ise2eSetUserPublicAndPrivateKeysParamsPOST,
|
||||
ise2eUpdateGroupKeyParamsPOST,
|
||||
} from '@rocket.chat/rest-typings';
|
||||
import { IUser } from '@rocket.chat/core-typings';
|
||||
import type { IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { API } from '../api';
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Match, check } from 'meteor/check';
|
||||
import { IIntegration } from '@rocket.chat/core-typings';
|
||||
import type { IIntegration } from '@rocket.chat/core-typings';
|
||||
import {
|
||||
isIntegrationsCreateProps,
|
||||
isIntegrationsHistoryProps,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import { IInvite } from '@rocket.chat/core-typings';
|
||||
import type { IInvite } from '@rocket.chat/core-typings';
|
||||
import { isFindOrCreateInviteParams, isUseInviteTokenProps, isValidateInviteTokenProps } from '@rocket.chat/rest-typings';
|
||||
|
||||
import { API } from '../api';
|
||||
|
||||
@ -14,7 +14,7 @@ import {
|
||||
isMethodCallAnonProps,
|
||||
isMeteorCall,
|
||||
} from '@rocket.chat/rest-typings';
|
||||
import { IUser } from '@rocket.chat/core-typings';
|
||||
import type { IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { hasPermission } from '../../../authorization/server';
|
||||
import { Users } from '../../../models/server';
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { ServiceConfiguration } from 'meteor/service-configuration';
|
||||
import _ from 'underscore';
|
||||
import { ISetting, ISettingColor, isSettingAction, isSettingColor } from '@rocket.chat/core-typings';
|
||||
import type { ISetting, ISettingColor } from '@rocket.chat/core-typings';
|
||||
import { isSettingAction, isSettingColor } from '@rocket.chat/core-typings';
|
||||
import {
|
||||
isOauthCustomConfiguration,
|
||||
isSettingsUpdatePropDefault,
|
||||
@ -12,7 +13,8 @@ import { Settings } from '@rocket.chat/models';
|
||||
import type { FindOptions } from 'mongodb';
|
||||
|
||||
import { hasPermission } from '../../../authorization/server';
|
||||
import { API, ResultFor } from '../api';
|
||||
import type { ResultFor } from '../api';
|
||||
import { API } from '../api';
|
||||
import { SettingsEvents, settings } from '../../../settings/server';
|
||||
import { setValue } from '../../../settings/server/raw';
|
||||
|
||||
|
||||
@ -49,14 +49,14 @@ API.v1.addRoute(
|
||||
},
|
||||
{
|
||||
async get() {
|
||||
const { roomId }: { [roomId: string]: {} } | Record<string, string> = this.queryParams;
|
||||
const { roomId } = this.queryParams;
|
||||
|
||||
if (!roomId) {
|
||||
return API.v1.failure("The 'roomId' param is required");
|
||||
}
|
||||
|
||||
return API.v1.success({
|
||||
subscription: await Subscriptions.findOneByRoomIdAndUserId(roomId as string, this.userId),
|
||||
subscription: await Subscriptions.findOneByRoomIdAndUserId(roomId, this.userId),
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@ -11,7 +11,8 @@ import {
|
||||
isTeamsLeaveProps,
|
||||
isTeamsUpdateProps,
|
||||
} from '@rocket.chat/rest-typings';
|
||||
import { ITeam, TEAM_TYPE } from '@rocket.chat/core-typings';
|
||||
import type { ITeam } from '@rocket.chat/core-typings';
|
||||
import { TEAM_TYPE } from '@rocket.chat/core-typings';
|
||||
|
||||
import { removeUserFromRoom } from '../../../lib/server/functions/removeUserFromRoom';
|
||||
import { Users } from '../../../models/server';
|
||||
|
||||
@ -16,7 +16,7 @@ import { Meteor } from 'meteor/meteor';
|
||||
import { Accounts } from 'meteor/accounts-base';
|
||||
import { Match, check } from 'meteor/check';
|
||||
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
|
||||
import { IExportOperation, IPersonalAccessToken, IUser } from '@rocket.chat/core-typings';
|
||||
import type { IExportOperation, IPersonalAccessToken, IUser } from '@rocket.chat/core-typings';
|
||||
import { Users as UsersRaw } from '@rocket.chat/models';
|
||||
|
||||
import { Users, Subscriptions } from '../../../models/server';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Match, check } from 'meteor/check';
|
||||
import { IUser, IVoipExtensionWithAgentInfo } from '@rocket.chat/core-typings';
|
||||
import type { IUser, IVoipExtensionWithAgentInfo } from '@rocket.chat/core-typings';
|
||||
import { Users } from '@rocket.chat/models';
|
||||
|
||||
import { API } from '../../api';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ISetting } from '@rocket.chat/apps-engine/definition/settings/ISetting';
|
||||
import { App } from '@rocket.chat/core-typings';
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings/ISetting';
|
||||
import type { App } from '@rocket.chat/core-typings';
|
||||
|
||||
export interface IDetailedDescription {
|
||||
raw: string;
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import { AppClientManager } from '@rocket.chat/apps-engine/client/AppClientManager';
|
||||
import { IApiEndpointMetadata } from '@rocket.chat/apps-engine/definition/api';
|
||||
import type { IApiEndpointMetadata } from '@rocket.chat/apps-engine/definition/api';
|
||||
import { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import { IPermission } from '@rocket.chat/apps-engine/definition/permissions/IPermission';
|
||||
import { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage/IAppStorageItem';
|
||||
import type { IPermission } from '@rocket.chat/apps-engine/definition/permissions/IPermission';
|
||||
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage/IAppStorageItem';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import { AppScreenshot, Serialized } from '@rocket.chat/core-typings';
|
||||
import type { AppScreenshot, Serialized } from '@rocket.chat/core-typings';
|
||||
|
||||
import { App } from '../../../client/views/admin/apps/types';
|
||||
import type { App } from '../../../client/views/admin/apps/types';
|
||||
import { dispatchToastMessage } from '../../../client/lib/toast';
|
||||
import { settings } from '../../settings/client';
|
||||
import { CachedCollectionManager } from '../../ui-cached-collection';
|
||||
import { createDeferredValue } from '../lib/misc/DeferredValue';
|
||||
import {
|
||||
import type {
|
||||
// IAppFromMarketplace,
|
||||
IAppLanguage,
|
||||
IAppExternalURL,
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
|
||||
import { AppLicenseValidationResult } from '@rocket.chat/apps-engine/server/marketplace/license';
|
||||
import { ProxiedApp } from '@rocket.chat/apps-engine/server/ProxiedApp';
|
||||
import { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import type { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';
|
||||
import type { AppLicenseValidationResult } from '@rocket.chat/apps-engine/server/marketplace/license';
|
||||
import type { ProxiedApp } from '@rocket.chat/apps-engine/server/ProxiedApp';
|
||||
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
|
||||
export interface IAppInfoRest extends IAppInfo {
|
||||
status: AppStatus;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { AppActivationBridge as ActivationBridge } from '@rocket.chat/apps-engine/server/bridges/AppActivationBridge';
|
||||
import { ProxiedApp } from '@rocket.chat/apps-engine/server/ProxiedApp';
|
||||
import { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import type { ProxiedApp } from '@rocket.chat/apps-engine/server/ProxiedApp';
|
||||
import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import { Users } from '@rocket.chat/models';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppActivationBridge extends ActivationBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import express, { Response, Request, IRouter, RequestHandler } from 'express';
|
||||
import type { Response, Request, IRouter, RequestHandler } from 'express';
|
||||
import express from 'express';
|
||||
import { WebApp } from 'meteor/webapp';
|
||||
import { ApiBridge } from '@rocket.chat/apps-engine/server/bridges/ApiBridge';
|
||||
import { IApiRequest, IApiEndpoint, IApi } from '@rocket.chat/apps-engine/definition/api';
|
||||
import { AppApi } from '@rocket.chat/apps-engine/server/managers/AppApi';
|
||||
import { RequestMethod } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
import type { IApiRequest, IApiEndpoint, IApi } from '@rocket.chat/apps-engine/definition/api';
|
||||
import type { AppApi } from '@rocket.chat/apps-engine/server/managers/AppApi';
|
||||
import type { RequestMethod } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
import { authenticationMiddleware } from '../../../api/server/middlewares/authentication';
|
||||
|
||||
const apiServer = express();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { CloudWorkspaceBridge } from '@rocket.chat/apps-engine/server/bridges/CloudWorkspaceBridge';
|
||||
import { IWorkspaceToken } from '@rocket.chat/apps-engine/definition/cloud/IWorkspaceToken';
|
||||
import type { IWorkspaceToken } from '@rocket.chat/apps-engine/definition/cloud/IWorkspaceToken';
|
||||
|
||||
import { getWorkspaceAccessTokenWithScope } from '../../../cloud/server';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
const boundGetWorkspaceAccessToken = Meteor.bindEnvironment(getWorkspaceAccessTokenWithScope);
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { SlashCommandContext, ISlashCommand, ISlashCommandPreviewItem } from '@rocket.chat/apps-engine/definition/slashcommands';
|
||||
import type { ISlashCommand, ISlashCommandPreviewItem } from '@rocket.chat/apps-engine/definition/slashcommands';
|
||||
import { SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands';
|
||||
import { CommandBridge } from '@rocket.chat/apps-engine/server/bridges/CommandBridge';
|
||||
import type { IMessage, RequiredField, SlashCommand } from '@rocket.chat/core-typings';
|
||||
|
||||
import { slashCommands } from '../../../utils/server';
|
||||
import { Utilities } from '../../lib/misc/Utilities';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
import { parseParameters } from '../../../../lib/utils/parseParameters';
|
||||
|
||||
export class AppCommandsBridge extends CommandBridge {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import { AppDetailChangesBridge as DetailChangesBridge } from '@rocket.chat/apps-engine/server/bridges/AppDetailChangesBridge';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppDetailChangesBridge extends DetailChangesBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { EnvironmentalVariableBridge } from '@rocket.chat/apps-engine/server/bridges/EnvironmentalVariableBridge';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppEnvironmentalVariableBridge extends EnvironmentalVariableBridge {
|
||||
allowed: Array<string>;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { HttpBridge } from '@rocket.chat/apps-engine/server/bridges/HttpBridge';
|
||||
import { IHttpResponse } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
import { IHttpBridgeRequestInfo } from '@rocket.chat/apps-engine/server/bridges';
|
||||
import type { IHttpResponse } from '@rocket.chat/apps-engine/definition/accessors';
|
||||
import type { IHttpBridgeRequestInfo } from '@rocket.chat/apps-engine/server/bridges';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
import { fetch } from '../../../../server/lib/http/fetch';
|
||||
|
||||
const isGetOrHead = (method: string): boolean => ['GET', 'HEAD'].includes(method.toUpperCase());
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { InternalBridge } from '@rocket.chat/apps-engine/server/bridges/InternalBridge';
|
||||
import { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import type { ISubscription } from '@rocket.chat/core-typings';
|
||||
import { Settings } from '@rocket.chat/models';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
import { Subscriptions } from '../../../models/server';
|
||||
|
||||
export class AppInternalBridge extends InternalBridge {
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
import { Random } from 'meteor/random';
|
||||
import { LivechatBridge } from '@rocket.chat/apps-engine/server/bridges/LivechatBridge';
|
||||
import {
|
||||
import type {
|
||||
ILivechatMessage,
|
||||
IVisitor,
|
||||
ILivechatRoom,
|
||||
ILivechatTransferData,
|
||||
IDepartment,
|
||||
} from '@rocket.chat/apps-engine/definition/livechat';
|
||||
import { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import { IExtraRoomParams } from '@rocket.chat/apps-engine/definition/accessors/ILivechatCreator';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type { IExtraRoomParams } from '@rocket.chat/apps-engine/definition/accessors/ILivechatCreator';
|
||||
import { OmnichannelSourceType } from '@rocket.chat/core-typings';
|
||||
import { LivechatVisitors } from '@rocket.chat/models';
|
||||
|
||||
import { getRoom } from '../../../livechat/server/api/lib/livechat';
|
||||
import { Livechat } from '../../../livechat/server/lib/Livechat';
|
||||
import { Users, LivechatDepartment, LivechatRooms } from '../../../models/server';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppLivechatBridge extends LivechatBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
@ -157,11 +157,11 @@ export class AppLivechatBridge extends LivechatBridge {
|
||||
id: visitor.id,
|
||||
};
|
||||
|
||||
if (visitor.visitorEmails && visitor.visitorEmails.length) {
|
||||
if (visitor.visitorEmails?.length) {
|
||||
registerData.email = visitor.visitorEmails[0].address;
|
||||
}
|
||||
|
||||
if (visitor.phone && visitor.phone.length) {
|
||||
if (visitor.phone?.length) {
|
||||
(registerData as any).phone = { number: visitor.phone[0].phoneNumber };
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { ITypingDescriptor, MessageBridge } from '@rocket.chat/apps-engine/server/bridges/MessageBridge';
|
||||
import { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import { IRoom } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import type { ITypingDescriptor } from '@rocket.chat/apps-engine/server/bridges/MessageBridge';
|
||||
import { MessageBridge } from '@rocket.chat/apps-engine/server/bridges/MessageBridge';
|
||||
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import type { ISubscription } from '@rocket.chat/core-typings';
|
||||
|
||||
import { Messages, Users, Subscriptions } from '../../../models/server';
|
||||
@ -9,7 +10,7 @@ import { updateMessage } from '../../../lib/server/functions/updateMessage';
|
||||
import { executeSendMessage } from '../../../lib/server/methods/sendMessage';
|
||||
import { api } from '../../../../server/sdk/api';
|
||||
import notifications from '../../../notifications/server/lib/Notifications';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppMessageBridge extends MessageBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { PersistenceBridge } from '@rocket.chat/apps-engine/server/bridges/PersistenceBridge';
|
||||
import { RocketChatAssociationRecord } from '@rocket.chat/apps-engine/definition/metadata';
|
||||
import type { RocketChatAssociationRecord } from '@rocket.chat/apps-engine/definition/metadata';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppPersistenceBridge extends PersistenceBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { RoomType, IRoom } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import { RoomBridge } from '@rocket.chat/apps-engine/server/bridges/RoomBridge';
|
||||
import { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import type { IMessage } from '@rocket.chat/apps-engine/definition/messages';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import type { ISubscription } from '@rocket.chat/core-typings';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
import { Rooms, Subscriptions, Users } from '../../../models/server';
|
||||
import { addUserToRoom } from '../../../lib/server/functions/addUserToRoom';
|
||||
|
||||
@ -93,12 +94,7 @@ export class AppRoomBridge extends RoomBridge {
|
||||
protected async getMembers(roomId: string, appId: string): Promise<Array<IUser>> {
|
||||
this.orch.debugLog(`The App ${appId} is getting the room's members by room id: "${roomId}"`);
|
||||
const subscriptions = await Subscriptions.findByRoomId(roomId, {});
|
||||
return subscriptions.map((sub: ISubscription) =>
|
||||
this.orch
|
||||
.getConverters()
|
||||
?.get('users')
|
||||
.convertById(sub.u && sub.u._id),
|
||||
);
|
||||
return subscriptions.map((sub: ISubscription) => this.orch.getConverters()?.get('users').convertById(sub.u?._id));
|
||||
}
|
||||
|
||||
protected async getDirectByUsernames(usernames: Array<string>, appId: string): Promise<IRoom | undefined> {
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
import { Agenda, Job } from '@rocket.chat/agenda';
|
||||
import type { Job } from '@rocket.chat/agenda';
|
||||
import { Agenda } from '@rocket.chat/agenda';
|
||||
import { ObjectID } from 'bson';
|
||||
import { MongoInternals } from 'meteor/mongo';
|
||||
import { StartupType, IProcessor, IOnetimeSchedule, IRecurringSchedule } from '@rocket.chat/apps-engine/definition/scheduler';
|
||||
import type { IProcessor, IOnetimeSchedule, IRecurringSchedule, IJobContext } from '@rocket.chat/apps-engine/definition/scheduler';
|
||||
import { StartupType } from '@rocket.chat/apps-engine/definition/scheduler';
|
||||
import { SchedulerBridge } from '@rocket.chat/apps-engine/server/bridges/SchedulerBridge';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
function _callProcessor(processor: Function): (job: Job) => void {
|
||||
return (job): void => {
|
||||
function _callProcessor(processor: IProcessor['processor']): (job: Job) => Promise<void> {
|
||||
return (job) => {
|
||||
const data = job?.attrs?.data || {};
|
||||
|
||||
// This field is for internal use, no need to leak to app processor
|
||||
@ -15,7 +17,7 @@ function _callProcessor(processor: Function): (job: Job) => void {
|
||||
|
||||
data.jobId = job.attrs._id.toString();
|
||||
|
||||
return processor(data);
|
||||
return (processor as (jobContext: IJobContext) => Promise<void>)(data);
|
||||
};
|
||||
}
|
||||
|
||||
@ -40,33 +42,13 @@ export class AppSchedulerBridge extends SchedulerBridge {
|
||||
this.isConnected = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity that will be run in a job.
|
||||
* @typedef {Object} Processor
|
||||
* @property {string} id The processor's identifier
|
||||
* @property {function} processor The function that will be run on a given schedule
|
||||
* @property {IOnetimeStartup|IRecurrentStartup} [startupSetting] If provided, the processor will be configured with the setting as soon as it gets registered
|
||||
|
||||
* Processor setting for running once after being registered
|
||||
* @typedef {Object} IOnetimeStartup
|
||||
* @property {string} type=onetime
|
||||
* @property {string} when When the processor will be executed
|
||||
* @property {Object} [data] An optional object that is passed to the processor
|
||||
*
|
||||
* Processor setting for running recurringly after being registered
|
||||
* @typedef {Object} IRecurrentStartup
|
||||
* @property {string} type=recurring
|
||||
* @property {string} interval When the processor will be re executed
|
||||
* @property {Object} [data] An optional object that is passed to the processor
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register processors that can be scheduled to run
|
||||
*
|
||||
* @param {Array.<Processor>} processors An array of processors
|
||||
* @param {string} appId
|
||||
* @param processors An array of processors
|
||||
* @param appId
|
||||
*
|
||||
* @returns {string[]} List of task ids run at startup, or void no startup run is set
|
||||
* @returns List of task ids run at startup, or void no startup run is set
|
||||
*/
|
||||
protected async registerProcessors(processors: Array<IProcessor> = [], appId: string): Promise<void | Array<string>> {
|
||||
const runAfterRegister: Promise<string>[] = [];
|
||||
@ -112,14 +94,6 @@ export class AppSchedulerBridge extends SchedulerBridge {
|
||||
|
||||
/**
|
||||
* Schedules a registered processor to run _once_.
|
||||
*
|
||||
* @param {Object} job
|
||||
* @param {string} job.id The processor's id
|
||||
* @param {string} job.when When the processor will be executed
|
||||
* @param {Object} [job.data] An optional object that is passed to the processor
|
||||
* @param {string} appId
|
||||
*
|
||||
* @returns {string} taskid
|
||||
*/
|
||||
protected async scheduleOnce({ id, when, data }: IOnetimeSchedule, appId: string): Promise<void | string> {
|
||||
this.orch.debugLog(`The App ${appId} is scheduling an onetime job (processor ${id})`);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
|
||||
import { ServerSettingBridge } from '@rocket.chat/apps-engine/server/bridges/ServerSettingBridge';
|
||||
import { Settings } from '@rocket.chat/models';
|
||||
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppSettingBridge extends ServerSettingBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { UiInteractionBridge as UiIntBridge } from '@rocket.chat/apps-engine/server/bridges/UiInteractionBridge';
|
||||
import { IUIKitInteraction } from '@rocket.chat/apps-engine/definition/uikit';
|
||||
import { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import type { IUIKitInteraction } from '@rocket.chat/apps-engine/definition/uikit';
|
||||
import type { IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
|
||||
import { api } from '../../../../server/sdk/api';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class UiInteractionBridge extends UiIntBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { UploadBridge } from '@rocket.chat/apps-engine/server/bridges/UploadBridge';
|
||||
import { IUpload } from '@rocket.chat/apps-engine/definition/uploads';
|
||||
import { IUploadDetails } from '@rocket.chat/apps-engine/definition/uploads/IUploadDetails';
|
||||
import type { IUpload } from '@rocket.chat/apps-engine/definition/uploads';
|
||||
import type { IUploadDetails } from '@rocket.chat/apps-engine/definition/uploads/IUploadDetails';
|
||||
|
||||
import { FileUpload } from '../../../file-upload/server';
|
||||
import { determineFileType } from '../../lib/misc/determineFileType';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
const getUploadDetails = (details: IUploadDetails): Partial<IUploadDetails> => {
|
||||
if (details.visitorToken) {
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { Random } from 'meteor/random';
|
||||
import { UserPresence } from 'meteor/konecty:user-presence';
|
||||
import { UserBridge } from '@rocket.chat/apps-engine/server/bridges/UserBridge';
|
||||
import { IUserCreationOptions, IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import type { IUserCreationOptions, IUser } from '@rocket.chat/apps-engine/definition/users';
|
||||
import { Subscriptions, Users as UsersRaw } from '@rocket.chat/models';
|
||||
|
||||
import { setUserAvatar, checkUsernameAvailability, deleteUser } from '../../../lib/server/functions';
|
||||
import { Users } from '../../../models/server';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppUserBridge extends UserBridge {
|
||||
// eslint-disable-next-line no-empty-function
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { VideoConferenceBridge } from '@rocket.chat/apps-engine/server/bridges/VideoConferenceBridge';
|
||||
import { AppVideoConference, VideoConference } from '@rocket.chat/apps-engine/definition/videoConferences';
|
||||
import { IVideoConfProvider } from '@rocket.chat/apps-engine/definition/videoConfProviders';
|
||||
import type { AppVideoConference, VideoConference } from '@rocket.chat/apps-engine/definition/videoConferences';
|
||||
import type { IVideoConfProvider } from '@rocket.chat/apps-engine/definition/videoConfProviders';
|
||||
|
||||
import { VideoConf } from '../../../../server/sdk';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
import { videoConfProviders } from '../../../../server/lib/videoConfProviders';
|
||||
import type { AppVideoConferencesConverter } from '../converters/videoConferences';
|
||||
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
import { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
|
||||
import type { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
|
||||
|
||||
import { API } from '../../../../api/server';
|
||||
import { AppsRestApi } from '../rest';
|
||||
import type { AppsRestApi } from '../rest';
|
||||
|
||||
export const actionButtonsHandler = (apiManager: AppsRestApi): [Record<string, any>, Record<string, Function>] => [
|
||||
{
|
||||
authRequired: false,
|
||||
},
|
||||
{
|
||||
get(): any {
|
||||
const manager = apiManager._manager as AppManager;
|
||||
|
||||
const buttons = manager.getUIActionButtonManager().getAllActionButtons();
|
||||
|
||||
return API.v1.success(buttons);
|
||||
export const actionButtonsHandler = (apiManager: AppsRestApi) =>
|
||||
[
|
||||
{
|
||||
authRequired: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
{
|
||||
get(): any {
|
||||
const manager = apiManager._manager as AppManager;
|
||||
|
||||
const buttons = manager.getUIActionButtonManager().getAllActionButtons();
|
||||
|
||||
return API.v1.success(buttons);
|
||||
},
|
||||
},
|
||||
] as const;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { SettingValue } from '@rocket.chat/core-typings';
|
||||
import type { SettingValue } from '@rocket.chat/core-typings';
|
||||
import { Settings } from '@rocket.chat/models';
|
||||
|
||||
import { hasPermission } from '../../../authorization/server';
|
||||
import { twoFactorRequired } from '../../../2fa/server/twoFactorRequired';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
const waitToLoad = function (orch: AppServerOrchestrator): unknown {
|
||||
return new Promise<void>((resolve) => {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import type { Request, Response } from 'express';
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import rateLimit from 'express-rate-limit';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
@ -7,7 +8,8 @@ import { UIKitIncomingInteractionType } from '@rocket.chat/apps-engine/definitio
|
||||
import { AppInterface } from '@rocket.chat/apps-engine/definition/metadata';
|
||||
|
||||
import { settings } from '../../../settings/server';
|
||||
import { Apps, AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
import { Apps } from '../orchestrator';
|
||||
import { UiKitCoreApp } from '../../../../server/sdk';
|
||||
import { authenticationMiddleware } from '../../../api/server/middlewares/authentication';
|
||||
|
||||
@ -71,8 +73,8 @@ router.use((req: Request, res, next) => {
|
||||
next();
|
||||
});
|
||||
|
||||
const corsOptions = {
|
||||
origin: (origin: string | undefined, callback: Function): void => {
|
||||
const corsOptions: cors.CorsOptions = {
|
||||
origin: (origin, callback) => {
|
||||
if (
|
||||
!origin ||
|
||||
!corsEnabled ||
|
||||
@ -82,14 +84,14 @@ const corsOptions = {
|
||||
) {
|
||||
callback(null, true);
|
||||
} else {
|
||||
callback('Not allowed by CORS', false);
|
||||
callback(new Error('Not allowed by CORS'), false);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
apiServer.use('/api/apps/ui.interaction/', cors(corsOptions), router); // didn't have the rateLimiter option
|
||||
|
||||
const getPayloadForType = (type: UIKitIncomingInteractionType, req: Request): {} => {
|
||||
const getPayloadForType = (type: UIKitIncomingInteractionType, req: Request) => {
|
||||
if (type === UIKitIncomingInteractionType.BLOCK) {
|
||||
const { type, actionId, triggerId, mid, rid, payload, container } = req.body;
|
||||
|
||||
@ -109,7 +111,7 @@ const getPayloadForType = (type: UIKitIncomingInteractionType, req: Request): {}
|
||||
user,
|
||||
visitor,
|
||||
room,
|
||||
};
|
||||
} as const;
|
||||
}
|
||||
|
||||
if (type === UIKitIncomingInteractionType.VIEW_CLOSED) {
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import { AppStatus, AppStatusUtils } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import { ISetting } from '@rocket.chat/core-typings';
|
||||
import { IStreamer } from 'meteor/rocketchat:streamer';
|
||||
import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import { AppStatusUtils } from '@rocket.chat/apps-engine/definition/AppStatus';
|
||||
import type { ISetting } from '@rocket.chat/core-typings';
|
||||
import type { IStreamer } from 'meteor/rocketchat:streamer';
|
||||
|
||||
import { SystemLogger } from '../../../../server/lib/logger/system';
|
||||
import notifications from '../../../notifications/server/lib/Notifications';
|
||||
import { AppServerOrchestrator } from '../orchestrator';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export enum AppEvents {
|
||||
APP_ADDED = 'app/added',
|
||||
|
||||
@ -2,16 +2,8 @@ import type { VideoConference } from '@rocket.chat/apps-engine/definition/videoC
|
||||
import type { IVideoConference } from '@rocket.chat/core-typings';
|
||||
|
||||
import { VideoConf } from '../../../../server/sdk';
|
||||
import type { AppServerOrchestrator } from '../orchestrator';
|
||||
|
||||
export class AppVideoConferencesConverter {
|
||||
// @ts-ignore
|
||||
private orch: AppServerOrchestrator;
|
||||
|
||||
constructor(orch: AppServerOrchestrator) {
|
||||
this.orch = orch;
|
||||
}
|
||||
|
||||
async convertById(callId: string): Promise<VideoConference | undefined> {
|
||||
const call = await VideoConf.getUnfiltered(callId);
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ export class AppServerOrchestrator {
|
||||
this._converters.set('visitors', new AppVisitorsConverter(this));
|
||||
this._converters.set('departments', new AppDepartmentsConverter(this));
|
||||
this._converters.set('uploads', new AppUploadsConverter(this));
|
||||
this._converters.set('videoConferences', new AppVideoConferencesConverter(this));
|
||||
this._converters.set('videoConferences', new AppVideoConferencesConverter());
|
||||
|
||||
this._bridges = new RealAppBridges(this);
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { promises as fs } from 'fs';
|
||||
import { join, normalize } from 'path';
|
||||
|
||||
import { AppSourceStorage, IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import { AppSourceStorage } from '@rocket.chat/apps-engine/server/storage';
|
||||
|
||||
export class AppFileSystemSourceStorage extends AppSourceStorage {
|
||||
private pathPrefix = 'fs:/';
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import { MongoInternals } from 'meteor/mongo';
|
||||
import { GridFSBucket, GridFSBucketWriteStream, ObjectId } from 'mongodb';
|
||||
import { AppSourceStorage, IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import type { GridFSBucket, GridFSBucketWriteStream } from 'mongodb';
|
||||
import { ObjectId } from 'mongodb';
|
||||
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import { AppSourceStorage } from '@rocket.chat/apps-engine/server/storage';
|
||||
|
||||
import { streamToBuffer } from '../../../file-upload/server/lib/streamToBuffer';
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { AppMetadataStorage, IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import { AppMetadataStorage } from '@rocket.chat/apps-engine/server/storage';
|
||||
|
||||
import { AppsModel } from '../../../models/server/models/apps-model';
|
||||
import type { AppsModel } from '../../../models/server/models/apps-model';
|
||||
|
||||
export class AppRealStorage extends AppMetadataStorage {
|
||||
constructor(private db: AppsModel) {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { AppSourceStorage, IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import type { IAppStorageItem } from '@rocket.chat/apps-engine/server/storage';
|
||||
import { AppSourceStorage } from '@rocket.chat/apps-engine/server/storage';
|
||||
|
||||
import { AppFileSystemSourceStorage } from './AppFileSystemSourceStorage';
|
||||
import { AppGridFSSourceStorage } from './AppGridFSSourceStorage';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import crypto from 'crypto';
|
||||
import { ServerResponse, IncomingMessage } from 'http';
|
||||
import type { ServerResponse, IncomingMessage } from 'http';
|
||||
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { WebApp, WebAppInternals } from 'meteor/webapp';
|
||||
@ -7,8 +7,8 @@ import { WebAppHashing } from 'meteor/webapp-hashing';
|
||||
import _ from 'underscore';
|
||||
import sizeOf from 'image-size';
|
||||
import sharp from 'sharp';
|
||||
import { NextHandleFunction } from 'connect';
|
||||
import { IRocketChatAssets, IRocketChatAsset } from '@rocket.chat/core-typings';
|
||||
import type { NextHandleFunction } from 'connect';
|
||||
import type { IRocketChatAssets, IRocketChatAsset, IRocketChatAssetCache } from '@rocket.chat/core-typings';
|
||||
import { Settings } from '@rocket.chat/models';
|
||||
|
||||
import { settings, settingsRegistry } from '../../settings/server';
|
||||
@ -257,7 +257,7 @@ class RocketChatAssetsClass {
|
||||
}
|
||||
|
||||
public refreshClients(): boolean {
|
||||
return (process.emit as Function)('message', {
|
||||
return process.emit('message', {
|
||||
refresh: 'client',
|
||||
});
|
||||
}
|
||||
@ -358,9 +358,9 @@ for (const key of Object.keys(assets)) {
|
||||
|
||||
settings.watchByRegex(/^Assets_/, (key, value) => RocketChatAssets.processAsset(key, value));
|
||||
|
||||
Meteor.startup(function () {
|
||||
return Meteor.setTimeout(function () {
|
||||
return (process.emit as Function)('message', {
|
||||
Meteor.startup(() => {
|
||||
Meteor.setTimeout(() => {
|
||||
process.emit('message', {
|
||||
refresh: 'client',
|
||||
});
|
||||
}, 200);
|
||||
@ -368,14 +368,14 @@ Meteor.startup(function () {
|
||||
|
||||
const { calculateClientHash } = WebAppHashing;
|
||||
|
||||
WebAppHashing.calculateClientHash = function (manifest: Record<string, any>, includeFilter: Function, runtimeConfigOverride: any): string {
|
||||
WebAppHashing.calculateClientHash = function (manifest, includeFilter, runtimeConfigOverride): string {
|
||||
for (const key of Object.keys(assets)) {
|
||||
const value = getAssetByKey(key);
|
||||
if (!value.cache && !value.defaultUrl) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let cache = {};
|
||||
let cache: IRocketChatAssetCache;
|
||||
if (value.cache) {
|
||||
cache = {
|
||||
path: value.cache.path,
|
||||
@ -504,7 +504,7 @@ const listener = Meteor.bindEnvironment((req: IncomingMessage, res: ServerRespon
|
||||
|
||||
const reqModifiedHeader = req.headers['if-modified-since'];
|
||||
if (reqModifiedHeader) {
|
||||
if (reqModifiedHeader === (file.uploadDate && file.uploadDate.toUTCString())) {
|
||||
if (reqModifiedHeader === file.uploadDate?.toUTCString()) {
|
||||
res.setHeader('Last-Modified', reqModifiedHeader);
|
||||
res.writeHead(304);
|
||||
res.end();
|
||||
@ -523,9 +523,9 @@ const listener = Meteor.bindEnvironment((req: IncomingMessage, res: ServerRespon
|
||||
return;
|
||||
}
|
||||
|
||||
res.setHeader('Last-Modified', (file.uploadDate && file.uploadDate.toUTCString()) || new Date().toUTCString());
|
||||
res.setHeader('Content-Type', file.contentType);
|
||||
res.setHeader('Content-Length', file.size);
|
||||
res.setHeader('Last-Modified', file.uploadDate?.toUTCString() || new Date().toUTCString());
|
||||
if (file.contentType) res.setHeader('Content-Type', file.contentType);
|
||||
if (file.size) res.setHeader('Content-Length', file.size);
|
||||
res.writeHead(200);
|
||||
res.end(file.content);
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Accounts } from 'meteor/accounts-base';
|
||||
|
||||
import { ILoginAttempt } from '../ILoginAttempt';
|
||||
import type { ILoginAttempt } from '../ILoginAttempt';
|
||||
import { saveFailedLoginAttempts, saveSuccessfulLogin } from '../lib/restrictLoginAttempts';
|
||||
import { logFailedLoginAttempts } from '../lib/logLoginAttempts';
|
||||
import { callbacks } from '../../../../lib/callbacks';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ILoginAttempt } from '../ILoginAttempt';
|
||||
import type { ILoginAttempt } from '../ILoginAttempt';
|
||||
import { settings } from '../../../settings/server';
|
||||
import { SystemLogger } from '../../../../server/lib/logger/system';
|
||||
|
||||
@ -16,13 +16,13 @@ export const logFailedLoginAttempts = (login: ILoginAttempt): void => {
|
||||
if (!settings.get('Login_Logs_ClientIp')) {
|
||||
clientAddress = '-';
|
||||
}
|
||||
let forwardedFor = connection.httpHeaders && connection.httpHeaders['x-forwarded-for'];
|
||||
let realIp = connection.httpHeaders && connection.httpHeaders['x-real-ip'];
|
||||
let forwardedFor = connection.httpHeaders?.['x-forwarded-for'];
|
||||
let realIp = connection.httpHeaders?.['x-real-ip'];
|
||||
if (!settings.get('Login_Logs_ForwardedForIp')) {
|
||||
forwardedFor = '-';
|
||||
realIp = '-';
|
||||
}
|
||||
let userAgent = connection.httpHeaders && connection.httpHeaders['user-agent'];
|
||||
let userAgent = connection.httpHeaders?.['user-agent'];
|
||||
if (!settings.get('Login_Logs_UserAgent')) {
|
||||
userAgent = '-';
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import { getClientAddress } from '../../../../server/lib/getClientAddress';
|
||||
import { sendMessage } from '../../../lib/server/functions';
|
||||
import { Logger } from '../../../logger/server';
|
||||
import { settings } from '../../../settings/server';
|
||||
import { ILoginAttempt } from '../ILoginAttempt';
|
||||
import type { ILoginAttempt } from '../ILoginAttempt';
|
||||
|
||||
const logger = new Logger('LoginProtection');
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ const createPermissionValidator =
|
||||
}
|
||||
|
||||
const model = Models[roleScope as keyof typeof Models];
|
||||
return model.isUserInRole && model.isUserInRole(userId, roleId, scope);
|
||||
return model.isUserInRole?.(userId, roleId, scope);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Authorization } from '../../../../server/sdk';
|
||||
import { IAuthorization } from '../../../../server/sdk/types/IAuthorization';
|
||||
import type { IAuthorization } from '../../../../server/sdk/types/IAuthorization';
|
||||
|
||||
export const canAccessRoomAsync = Authorization.canAccessRoom;
|
||||
export const canAccessRoomIdAsync = Authorization.canAccessRoomId;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IUser } from '@rocket.chat/core-typings';
|
||||
import type { IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { hasPermissionAsync } from './hasPermission';
|
||||
import { getValue } from '../../../settings/server/raw';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
import type { IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
import { Subscriptions, Rooms } from '@rocket.chat/models';
|
||||
|
||||
import { canAccessRoomAsync } from './canAccessRoom';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { FindCursor, FindOptions } from 'mongodb';
|
||||
import type { FindCursor, FindOptions } from 'mongodb';
|
||||
import type { IRole, IUser } from '@rocket.chat/core-typings';
|
||||
import { Roles, Subscriptions, Users } from '@rocket.chat/models';
|
||||
import { FindPaginated } from '@rocket.chat/model-typings';
|
||||
import type { FindPaginated } from '@rocket.chat/model-typings';
|
||||
import { compact } from 'lodash';
|
||||
|
||||
export function getUsersInRole(roleId: IRole['_id'], scope?: string): Promise<FindCursor<IUser>>;
|
||||
|
||||
@ -29,4 +29,4 @@ export const hasRole = (...args: Parameters<typeof hasRoleAsync>): boolean => Pr
|
||||
|
||||
export const hasAnyRole = (...args: Parameters<typeof hasAnyRoleAsync>): boolean => Promise.await(hasAnyRoleAsync(...args));
|
||||
|
||||
export const subscriptionHasRole = (sub: ISubscription, role: IRole['_id']): boolean | undefined => sub.roles && sub.roles.includes(role);
|
||||
export const subscriptionHasRole = (sub: ISubscription, role: IRole['_id']): boolean | undefined => sub.roles?.includes(role);
|
||||
|
||||
@ -279,7 +279,7 @@ export const upsertPermissions = async (): Promise<void> => {
|
||||
roles: [],
|
||||
};
|
||||
// copy previously assigned roles if available
|
||||
if (previousSettingPermissions[permissionId] && previousSettingPermissions[permissionId].roles) {
|
||||
if (previousSettingPermissions[permissionId]?.roles) {
|
||||
permission.roles = previousSettingPermissions[permissionId].roles;
|
||||
}
|
||||
if (setting.group) {
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import mem from 'mem';
|
||||
import { IRoom, ISubscription, ISupportedLanguage, ITranslatedMessage, IUser, MessageAttachmentDefault } from '@rocket.chat/core-typings';
|
||||
import type {
|
||||
IRoom,
|
||||
ISubscription,
|
||||
ISupportedLanguage,
|
||||
ITranslatedMessage,
|
||||
IUser,
|
||||
MessageAttachmentDefault,
|
||||
} from '@rocket.chat/core-typings';
|
||||
|
||||
import { Subscriptions, Messages } from '../../../models/client';
|
||||
import { hasPermission } from '../../../authorization/client';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import _ from 'underscore';
|
||||
import { escapeHTML } from '@rocket.chat/string-helpers';
|
||||
import {
|
||||
import type {
|
||||
IMessage,
|
||||
IRoom,
|
||||
MessageAttachment,
|
||||
@ -286,7 +286,7 @@ export abstract class AutoTranslate {
|
||||
if (targetLanguage) {
|
||||
targetLanguages = [targetLanguage];
|
||||
} else {
|
||||
targetLanguages = Subscriptions.getAutoTranslateLanguagesByRoomAndNotUser(room._id, message.u && message.u._id);
|
||||
targetLanguages = Subscriptions.getAutoTranslateLanguagesByRoomAndNotUser(room._id, message.u?._id);
|
||||
}
|
||||
if (message.msg) {
|
||||
Meteor.defer(() => {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
|
||||
import { HTTP } from 'meteor/http';
|
||||
import _ from 'underscore';
|
||||
import {
|
||||
import type {
|
||||
IMessage,
|
||||
IDeepLTranslation,
|
||||
MessageAttachment,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
|
||||
import { HTTP } from 'meteor/http';
|
||||
import _ from 'underscore';
|
||||
import {
|
||||
import type {
|
||||
IMessage,
|
||||
IProviderMetadata,
|
||||
ISupportedLanguage,
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
|
||||
import { HTTP } from 'meteor/http';
|
||||
import _ from 'underscore';
|
||||
import { IMessage, IProviderMetadata, ISupportedLanguage, ITranslationResult, MessageAttachment } from '@rocket.chat/core-typings';
|
||||
import type { IMessage, IProviderMetadata, ISupportedLanguage, ITranslationResult, MessageAttachment } from '@rocket.chat/core-typings';
|
||||
|
||||
import { TranslationProviderRegistry, AutoTranslate } from './autotranslate';
|
||||
import { msLogger } from './logger';
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { FC, lazy, LazyExoticComponent } from 'react';
|
||||
import type { FC, LazyExoticComponent } from 'react';
|
||||
import { lazy } from 'react';
|
||||
|
||||
import { addAction } from '../../../client/views/room/lib/Toolbox';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { SettingValue } from '@rocket.chat/core-typings';
|
||||
import type { SettingValue } from '@rocket.chat/core-typings';
|
||||
import { Statistics } from '@rocket.chat/models';
|
||||
|
||||
import { settings } from '../../../settings/server';
|
||||
|
||||
@ -37,7 +37,7 @@ export async function connectWorkspace(token: string) {
|
||||
data: regInfo,
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e.response && e.response.data && e.response.data.error) {
|
||||
if (e.response?.data?.error) {
|
||||
SystemLogger.error(`Failed to register with Rocket.Chat Cloud. Error: ${e.response.data.error}`);
|
||||
} else {
|
||||
SystemLogger.error(e);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { HTTP } from 'meteor/http';
|
||||
import { CloudConfirmationPollData } from '@rocket.chat/core-typings';
|
||||
import type { CloudConfirmationPollData } from '@rocket.chat/core-typings';
|
||||
|
||||
import { settings } from '../../../settings/server';
|
||||
import { SystemLogger } from '../../../../server/lib/logger/system';
|
||||
@ -11,7 +11,7 @@ export async function getConfirmationPoll(deviceCode: string): Promise<CloudConf
|
||||
try {
|
||||
result = HTTP.get(`${cloudUrl}/api/v2/register/workspace/poll?token=${deviceCode}`);
|
||||
} catch (e: any) {
|
||||
if (e.response && e.response.data && e.response.data.error) {
|
||||
if (e.response?.data?.error) {
|
||||
SystemLogger.error(`Failed to register with Rocket.Chat Cloud. ErrorCode: ${e.response.data.error}`);
|
||||
} else {
|
||||
SystemLogger.error(e);
|
||||
|
||||
@ -22,7 +22,7 @@ export async function getWorkspaceLicense() {
|
||||
},
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e.response && e.response.data && e.response.data.error) {
|
||||
if (e.response?.data?.error) {
|
||||
SystemLogger.error(`Failed to update license from Rocket.Chat Cloud. Error: ${e.response.data.error}`);
|
||||
} else {
|
||||
SystemLogger.error(e);
|
||||
|
||||
@ -27,7 +27,7 @@ export async function startRegisterWorkspace(resend = false) {
|
||||
data: regInfo,
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e.response && e.response.data && e.response.data.error) {
|
||||
if (e.response?.data?.error) {
|
||||
SystemLogger.error(`Failed to register with Rocket.Chat Cloud. ErrorCode: ${e.response.data.error}`);
|
||||
} else {
|
||||
SystemLogger.error(e);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { HTTP } from 'meteor/http';
|
||||
import { CloudRegistrationIntentData } from '@rocket.chat/core-typings';
|
||||
import type { CloudRegistrationIntentData } from '@rocket.chat/core-typings';
|
||||
|
||||
import { settings } from '../../../settings/server';
|
||||
import { buildWorkspaceRegistrationData } from './buildRegistrationData';
|
||||
@ -15,7 +15,7 @@ export async function startRegisterWorkspaceSetupWizard(resend = false, email: s
|
||||
data: regInfo,
|
||||
});
|
||||
} catch (e: any) {
|
||||
if (e.response && e.response.data && e.response.data.error) {
|
||||
if (e.response?.data?.error) {
|
||||
SystemLogger.error(`Failed to register with Rocket.Chat Cloud. ErrorCode: ${e.response.data.error}`);
|
||||
} else {
|
||||
SystemLogger.error(e);
|
||||
|
||||
@ -38,7 +38,7 @@ export async function syncWorkspace(reconnectCheck = false) {
|
||||
|
||||
await getWorkspaceLicense();
|
||||
} catch (e: any) {
|
||||
if (e.response && e.response.data && e.response.data.error) {
|
||||
if (e.response?.data?.error) {
|
||||
SystemLogger.error(`Failed to sync with Rocket.Chat Cloud. Error: ${e.response.data.error}`);
|
||||
} else {
|
||||
SystemLogger.error(e);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IRoom, IUser, ValueOf } from '@rocket.chat/core-typings';
|
||||
import type { IRoom, IUser, ValueOf } from '@rocket.chat/core-typings';
|
||||
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
|
||||
import { RoomMemberActions } from '../../../definition/IRoomTypeConfig';
|
||||
|
||||
@ -2,12 +2,13 @@ import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
|
||||
import { FederatedRoom } from '../domain/FederatedRoom';
|
||||
import { FederatedUser } from '../domain/FederatedUser';
|
||||
import { EVENT_ORIGIN, IFederationBridge } from '../domain/IFederationBridge';
|
||||
import { RocketChatMessageAdapter } from '../infrastructure/rocket-chat/adapters/Message';
|
||||
import { RocketChatRoomAdapter } from '../infrastructure/rocket-chat/adapters/Room';
|
||||
import { RocketChatSettingsAdapter } from '../infrastructure/rocket-chat/adapters/Settings';
|
||||
import { RocketChatUserAdapter } from '../infrastructure/rocket-chat/adapters/User';
|
||||
import {
|
||||
import type { IFederationBridge } from '../domain/IFederationBridge';
|
||||
import { EVENT_ORIGIN } from '../domain/IFederationBridge';
|
||||
import type { RocketChatMessageAdapter } from '../infrastructure/rocket-chat/adapters/Message';
|
||||
import type { RocketChatRoomAdapter } from '../infrastructure/rocket-chat/adapters/Room';
|
||||
import type { RocketChatSettingsAdapter } from '../infrastructure/rocket-chat/adapters/Settings';
|
||||
import type { RocketChatUserAdapter } from '../infrastructure/rocket-chat/adapters/User';
|
||||
import type {
|
||||
FederationRoomCreateInputDto,
|
||||
FederationRoomChangeMembershipDto,
|
||||
FederationRoomSendInternalMessageDto,
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import { IMessage, IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
import type { IMessage, IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { FederatedRoom } from '../domain/FederatedRoom';
|
||||
import { FederatedUser } from '../domain/FederatedUser';
|
||||
import { IFederationBridge } from '../domain/IFederationBridge';
|
||||
import { RocketChatRoomAdapter } from '../infrastructure/rocket-chat/adapters/Room';
|
||||
import { RocketChatSettingsAdapter } from '../infrastructure/rocket-chat/adapters/Settings';
|
||||
import { RocketChatUserAdapter } from '../infrastructure/rocket-chat/adapters/User';
|
||||
import {
|
||||
import type { IFederationBridge } from '../domain/IFederationBridge';
|
||||
import type { RocketChatRoomAdapter } from '../infrastructure/rocket-chat/adapters/Room';
|
||||
import type { RocketChatSettingsAdapter } from '../infrastructure/rocket-chat/adapters/Settings';
|
||||
import type { RocketChatUserAdapter } from '../infrastructure/rocket-chat/adapters/User';
|
||||
import type {
|
||||
FederationAfterLeaveRoomDto,
|
||||
FederationCreateDMAndInviteUserDto,
|
||||
FederationRoomSendExternalMessageDto,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import type { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
|
||||
import { EVENT_ORIGIN } from '../../domain/IFederationBridge';
|
||||
import type { EVENT_ORIGIN } from '../../domain/IFederationBridge';
|
||||
|
||||
class BaseRoom {
|
||||
externalRoomId: string;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IMessage } from '@rocket.chat/core-typings';
|
||||
import type { IMessage } from '@rocket.chat/core-typings';
|
||||
|
||||
export class FederationCreateDMAndInviteUserDto {
|
||||
internalInviterId: string;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
|
||||
import { IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
import type { IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { FederatedUser } from './FederatedUser';
|
||||
import type { FederatedUser } from './FederatedUser';
|
||||
|
||||
export class FederatedRoom {
|
||||
public externalId: string;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IUser } from '@rocket.chat/core-typings';
|
||||
import type { IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
export interface IFederatedUserCreationParams {
|
||||
name: string;
|
||||
|
||||
@ -28,7 +28,7 @@ export const federationRoomServiceSender = FederationFactory.buildRoomServiceSen
|
||||
);
|
||||
|
||||
FederationFactory.setupListeners(federationRoomServiceSender);
|
||||
let cancelSettingsObserver: Function;
|
||||
let cancelSettingsObserver: () => void;
|
||||
|
||||
export const runFederation = async (): Promise<void> => {
|
||||
federationQueueInstance.setHandler(federationEventsHandler.handleEvent.bind(federationEventsHandler), FEDERATION_PROCESSING_CONCURRENCY);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
import type { IRoom, IUser } from '@rocket.chat/core-typings';
|
||||
|
||||
import { FederationRoomServiceReceiver } from '../application/RoomServiceReceiver';
|
||||
import { FederationRoomServiceSender } from '../application/RoomServiceSender';
|
||||
@ -17,7 +17,7 @@ import { RocketChatMessageAdapter } from './rocket-chat/adapters/Message';
|
||||
import { RocketChatRoomAdapter } from './rocket-chat/adapters/Room';
|
||||
import { RocketChatSettingsAdapter } from './rocket-chat/adapters/Settings';
|
||||
import { RocketChatUserAdapter } from './rocket-chat/adapters/User';
|
||||
import { IFederationBridge } from '../domain/IFederationBridge';
|
||||
import type { IFederationBridge } from '../domain/IFederationBridge';
|
||||
import { FederationHooks } from './rocket-chat/hooks';
|
||||
import { FederationRoomSenderConverter } from './rocket-chat/converters/RoomSender';
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import type { AppServiceOutput, Bridge } from '@rocket.chat/forked-matrix-appservice-bridge';
|
||||
|
||||
import { IFederationBridge } from '../../domain/IFederationBridge';
|
||||
import type { IFederationBridge } from '../../domain/IFederationBridge';
|
||||
import { bridgeLogger } from '../rocket-chat/adapters/logger';
|
||||
import { IMatrixEvent } from './definitions/IMatrixEvent';
|
||||
import { MatrixEventType } from './definitions/MatrixEventType';
|
||||
import type { IMatrixEvent } from './definitions/IMatrixEvent';
|
||||
import type { MatrixEventType } from './definitions/MatrixEventType';
|
||||
import { MatrixRoomType } from './definitions/MatrixRoomType';
|
||||
import { MatrixRoomVisibility } from './definitions/MatrixRoomVisibility';
|
||||
|
||||
@ -23,7 +23,7 @@ export class MatrixBridge implements IFederationBridge {
|
||||
protected bridgeUrl: string,
|
||||
protected bridgePort: number,
|
||||
protected homeServerRegistrationFile: Record<string, any>,
|
||||
protected eventHandler: Function,
|
||||
protected eventHandler: (event: IMatrixEvent<MatrixEventType>) => void,
|
||||
) {
|
||||
this.logInfo();
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
FederationRoomSendInternalMessageDto,
|
||||
} from '../../../application/input/RoomReceiverDto';
|
||||
import { EVENT_ORIGIN } from '../../../domain/IFederationBridge';
|
||||
import { IMatrixEvent } from '../definitions/IMatrixEvent';
|
||||
import type { IMatrixEvent } from '../definitions/IMatrixEvent';
|
||||
import { AddMemberToRoomMembership } from '../definitions/IMatrixEventContent/IMatrixEventContentAddMemberToRoom';
|
||||
import { RoomJoinRules } from '../definitions/IMatrixEventContent/IMatrixEventContentSetRoomJoinRules';
|
||||
import { MatrixEventType } from '../definitions/MatrixEventType';
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { MatrixEventType } from './MatrixEventType';
|
||||
import { EventContent } from './IMatrixEventContent';
|
||||
import type { MatrixEventType } from './MatrixEventType';
|
||||
import type { EventContent } from './IMatrixEventContent';
|
||||
|
||||
export interface IMatrixEvent<T extends MatrixEventType> {
|
||||
age: number;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { MatrixEventType } from '../MatrixEventType';
|
||||
import { IMatrixEventContentCreateRoom } from './IMatrixEventContentCreateRoom';
|
||||
import { IMatrixEventContentAddMemberToRoom } from './IMatrixEventContentAddMemberToRoom';
|
||||
import { IMatrixEventContentSendMessage } from './IMatrixEventContentSendMessage';
|
||||
import { IMatrixEventContentSetRoomJoinRules } from './IMatrixEventContentSetRoomJoinRules';
|
||||
import { IMatrixEventContentSetRoomName } from './IMatrixEventContentSetRoomName';
|
||||
import { IMatrixEventContentSetRoomTopic } from './IMatrixEventContentSetRoomTopic';
|
||||
import type { MatrixEventType } from '../MatrixEventType';
|
||||
import type { IMatrixEventContentCreateRoom } from './IMatrixEventContentCreateRoom';
|
||||
import type { IMatrixEventContentAddMemberToRoom } from './IMatrixEventContentAddMemberToRoom';
|
||||
import type { IMatrixEventContentSendMessage } from './IMatrixEventContentSendMessage';
|
||||
import type { IMatrixEventContentSetRoomJoinRules } from './IMatrixEventContentSetRoomJoinRules';
|
||||
import type { IMatrixEventContentSetRoomName } from './IMatrixEventContentSetRoomName';
|
||||
import type { IMatrixEventContentSetRoomTopic } from './IMatrixEventContentSetRoomTopic';
|
||||
|
||||
export type EventContent = {
|
||||
[MatrixEventType.ROOM_CREATED]: IMatrixEventContentCreateRoom;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IMatrixEvent } from '../definitions/IMatrixEvent';
|
||||
import { MatrixEventType } from '../definitions/MatrixEventType';
|
||||
import type { IMatrixEvent } from '../definitions/IMatrixEvent';
|
||||
import type { MatrixEventType } from '../definitions/MatrixEventType';
|
||||
|
||||
export abstract class MatrixBaseEventHandler<T extends MatrixEventType> {
|
||||
protected type: T;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { FederationRoomServiceReceiver } from '../../../application/RoomServiceReceiver';
|
||||
import { RocketChatSettingsAdapter } from '../../rocket-chat/adapters/Settings';
|
||||
import type { FederationRoomServiceReceiver } from '../../../application/RoomServiceReceiver';
|
||||
import type { RocketChatSettingsAdapter } from '../../rocket-chat/adapters/Settings';
|
||||
import { MatrixRoomReceiverConverter } from '../converters/RoomReceiver';
|
||||
import { IMatrixEvent } from '../definitions/IMatrixEvent';
|
||||
import type { IMatrixEvent } from '../definitions/IMatrixEvent';
|
||||
import { MatrixEventType } from '../definitions/MatrixEventType';
|
||||
import { MatrixBaseEventHandler } from './BaseEvent';
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user