Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/triggers-omni' into fix-liv…
Browse files Browse the repository at this point in the history
…echat-department-trigger
  • Loading branch information
MartinSchoeler committed Mar 8, 2024
2 parents 0a303dd + 1074224 commit 7aaad54
Show file tree
Hide file tree
Showing 360 changed files with 5,789 additions and 3,624 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-penguins-do.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Now we are considering channels with auto-join inside teams on user creation
5 changes: 5 additions & 0 deletions .changeset/cuddly-rocks-fix.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

Deprecate `insertOrUpdateUser` Meteor method
5 changes: 5 additions & 0 deletions .changeset/funny-cooks-sneeze.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed room owner specified on room import not being inserted as a room member or owner.
5 changes: 5 additions & 0 deletions .changeset/nice-ducks-shout.md
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed auto-availability of reactivated livechat agents; they now stay 'Not Available' until manually set to 'Available'
5 changes: 5 additions & 0 deletions .changeset/nine-ads-hide.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

feat: show date on message's scroll
6 changes: 6 additions & 0 deletions .changeset/orange-dragons-fly.md
@@ -0,0 +1,6 @@
---
"@rocket.chat/livechat": minor
---

chore: Refactor & Improve Livechat Widget API
Refactors and adds better error handling to the widget's API calls
5 changes: 5 additions & 0 deletions .changeset/quick-cheetahs-help.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/web-ui-registration": patch
---

fixed the login page crashing when receiving unexpected errors
5 changes: 5 additions & 0 deletions .changeset/silly-socks-divide.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/eslint-config": patch
---

Fixed react eslint config
6 changes: 2 additions & 4 deletions apps/meteor/app/apps/server/bridges/activation.ts
@@ -1,13 +1,11 @@
import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
import type { IAppServerOrchestrator, AppStatus } from '@rocket.chat/apps';
import type { ProxiedApp } from '@rocket.chat/apps-engine/server/ProxiedApp';
import { AppActivationBridge as ActivationBridge } from '@rocket.chat/apps-engine/server/bridges/AppActivationBridge';
import { Users } from '@rocket.chat/models';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';

export class AppActivationBridge extends ActivationBridge {
// eslint-disable-next-line no-empty-function
constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}

Expand Down
5 changes: 2 additions & 3 deletions apps/meteor/app/apps/server/bridges/api.ts
@@ -1,3 +1,4 @@
import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import type { RequestMethod } from '@rocket.chat/apps-engine/definition/accessors';
import type { IApiRequest, IApiEndpoint, IApi } from '@rocket.chat/apps-engine/definition/api';
import { ApiBridge } from '@rocket.chat/apps-engine/server/bridges/ApiBridge';
Expand All @@ -7,7 +8,6 @@ import express from 'express';
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';
import { authenticationMiddleware } from '../../../api/server/middlewares/authentication';

const apiServer = express();
Expand All @@ -24,8 +24,7 @@ interface IRequestWithPrivateHash extends Request {
export class AppApisBridge extends ApiBridge {
appRouters: Map<string, IRouter>;

// eslint-disable-next-line no-empty-function
constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
this.appRouters = new Map();

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/apps/server/bridges/cloud.ts
@@ -1,11 +1,11 @@
import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import type { IWorkspaceToken } from '@rocket.chat/apps-engine/definition/cloud/IWorkspaceToken';
import { CloudWorkspaceBridge } from '@rocket.chat/apps-engine/server/bridges/CloudWorkspaceBridge';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';
import { getWorkspaceAccessTokenWithScope } from '../../../cloud/server';

export class AppCloudBridge extends CloudWorkspaceBridge {
constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}

Expand Down
46 changes: 28 additions & 18 deletions apps/meteor/app/apps/server/bridges/commands.ts
@@ -1,18 +1,18 @@
import type { IAppServerOrchestrator, IAppsRoom, IAppsUser } from '@rocket.chat/apps';
import type { ISlashCommand, ISlashCommandPreview, 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, SlashCommandCallbackParams } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';

import { Utilities } from '../../../../ee/lib/misc/Utilities';
import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';
import { parseParameters } from '../../../../lib/utils/parseParameters';
import { slashCommands } from '../../../utils/server/slashCommand';

export class AppCommandsBridge extends CommandBridge {
disabledCommands: Map<string, (typeof slashCommands.commands)[string]>;

constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
this.disabledCommands = new Map();
}
Expand Down Expand Up @@ -44,7 +44,7 @@ export class AppCommandsBridge extends CommandBridge {
slashCommands.commands[cmd] = this.disabledCommands.get(cmd) as (typeof slashCommands.commands)[string];
this.disabledCommands.delete(cmd);

this.orch.getNotifier().commandUpdated(cmd);
void this.orch.getNotifier().commandUpdated(cmd);
}

protected async disableCommand(command: string, appId: string): Promise<void> {
Expand All @@ -69,7 +69,7 @@ export class AppCommandsBridge extends CommandBridge {
this.disabledCommands.set(cmd, commandObj);
delete slashCommands.commands[cmd];

this.orch.getNotifier().commandDisabled(cmd);
void this.orch.getNotifier().commandDisabled(cmd);
}

// command: { command, paramsExample, i18nDescription, executor: function }
Expand All @@ -95,7 +95,7 @@ export class AppCommandsBridge extends CommandBridge {
) as (typeof slashCommands.commands)[string]['previewCallback'];

slashCommands.commands[cmd] = item;
this.orch.getNotifier().commandUpdated(cmd);
void this.orch.getNotifier().commandUpdated(cmd);
}

protected async registerCommand(command: ISlashCommand, appId: string): Promise<void> {
Expand All @@ -118,7 +118,7 @@ export class AppCommandsBridge extends CommandBridge {
} as SlashCommand;

slashCommands.commands[command.command.toLowerCase()] = item;
this.orch.getNotifier().commandAdded(command.command.toLowerCase());
void this.orch.getNotifier().commandAdded(command.command.toLowerCase());
}

protected async unregisterCommand(command: string, appId: string): Promise<void> {
Expand All @@ -132,7 +132,7 @@ export class AppCommandsBridge extends CommandBridge {
this.disabledCommands.delete(cmd);
delete slashCommands.commands[cmd];

this.orch.getNotifier().commandRemoved(cmd);
void this.orch.getNotifier().commandRemoved(cmd);
}

private _verifyCommand(command: ISlashCommand): void {
Expand Down Expand Up @@ -162,14 +162,15 @@ export class AppCommandsBridge extends CommandBridge {
}

private async _appCommandExecutor({ command, message, params, triggerId, userId }: SlashCommandCallbackParams<string>): Promise<void> {
const user = await this.orch.getConverters()?.get('users').convertById(userId);
const room = await this.orch.getConverters()?.get('rooms').convertById(message.rid);
// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.
const user: IAppsUser | undefined = await this.orch.getConverters()?.get('users').convertById(userId);
const room: IAppsRoom | undefined = await this.orch.getConverters()?.get('rooms').convertById(message.rid);
const threadId = message.tmid;
const parameters = parseParameters(params);

const context = new SlashCommandContext(
Object.freeze(user),
Object.freeze(room),
Object.freeze(user as IAppsUser),
Object.freeze(room as IAppsRoom),
Object.freeze(parameters) as string[],
threadId,
triggerId,
Expand All @@ -183,12 +184,19 @@ export class AppCommandsBridge extends CommandBridge {
parameters: any,
message: RequiredField<Partial<IMessage>, 'rid'>,
): Promise<ISlashCommandPreview | undefined> {
const user = await this.orch.getConverters()?.get('users').convertById(Meteor.userId());
const room = await this.orch.getConverters()?.get('rooms').convertById(message.rid);
// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.
const uid = Meteor.userId() as string;
const user: IAppsUser | undefined = await this.orch.getConverters()?.get('users').convertById(uid);
const room: IAppsRoom | undefined = await this.orch.getConverters()?.get('rooms').convertById(message.rid);
const threadId = message.tmid;
const params = parseParameters(parameters);

const context = new SlashCommandContext(Object.freeze(user), Object.freeze(room), Object.freeze(params) as string[], threadId);
const context = new SlashCommandContext(
Object.freeze(user as IAppsUser),
Object.freeze(room as IAppsRoom),
Object.freeze(params) as string[],
threadId,
);
return this.orch.getManager()?.getCommandManager().getPreviews(command, context);
}

Expand All @@ -199,14 +207,16 @@ export class AppCommandsBridge extends CommandBridge {
preview: ISlashCommandPreviewItem,
triggerId: string,
): Promise<void> {
const user = await this.orch.getConverters()?.get('users').convertById(Meteor.userId());
const room = await this.orch.getConverters()?.get('rooms').convertById(message.rid);
// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.
const uid = Meteor.userId() as string;
const user: IAppsUser | undefined = await this.orch.getConverters()?.get('users').convertById(uid);
const room: IAppsRoom | undefined = await this.orch.getConverters()?.get('rooms').convertById(message.rid);
const threadId = message.tmid;
const params = parseParameters(parameters);

const context = new SlashCommandContext(
Object.freeze(user),
Object.freeze(room),
Object.freeze(user as IAppsUser),
Object.freeze(room as IAppsRoom),
Object.freeze(params) as string[],
threadId,
triggerId,
Expand Down
11 changes: 6 additions & 5 deletions apps/meteor/app/apps/server/bridges/details.ts
@@ -1,18 +1,19 @@
import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import { AppDetailChangesBridge as DetailChangesBridge } from '@rocket.chat/apps-engine/server/bridges/AppDetailChangesBridge';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';

export class AppDetailChangesBridge extends DetailChangesBridge {
constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}

protected onAppSettingsChange(appId: string, setting: ISetting): void {
const logFailure = () => console.warn('failed to notify about the setting change.', appId);

try {
this.orch.getNotifier().appSettingsChange(appId, setting);
this.orch.getNotifier().appSettingsChange(appId, setting).catch(logFailure);
} catch (e) {
console.warn('failed to notify about the setting change.', appId);
logFailure();
}
}
}
5 changes: 2 additions & 3 deletions apps/meteor/app/apps/server/bridges/environmental.ts
@@ -1,11 +1,10 @@
import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import { EnvironmentalVariableBridge } from '@rocket.chat/apps-engine/server/bridges/EnvironmentalVariableBridge';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';

export class AppEnvironmentalVariableBridge extends EnvironmentalVariableBridge {
allowed: Array<string>;

constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
this.allowed = ['NODE_ENV', 'ROOT_URL', 'INSTANCE_IP'];
}
Expand Down
5 changes: 2 additions & 3 deletions apps/meteor/app/apps/server/bridges/http.ts
@@ -1,10 +1,9 @@
import type { IAppServerOrchestrator } from '@rocket.chat/apps';
import type { IHttpResponse } from '@rocket.chat/apps-engine/definition/accessors';
import type { IHttpBridgeRequestInfo } from '@rocket.chat/apps-engine/server/bridges';
import { HttpBridge } from '@rocket.chat/apps-engine/server/bridges/HttpBridge';
import { serverFetch as fetch } from '@rocket.chat/server-fetch';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';

const isGetOrHead = (method: string): boolean => ['GET', 'HEAD'].includes(method.toUpperCase());

// Previously, there was no timeout for HTTP requests.
Expand All @@ -13,7 +12,7 @@ const isGetOrHead = (method: string): boolean => ['GET', 'HEAD'].includes(method
const DEFAULT_TIMEOUT = 3 * 60 * 1000;

export class AppHttpBridge extends HttpBridge {
constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}

Expand Down
17 changes: 10 additions & 7 deletions apps/meteor/app/apps/server/bridges/internal.ts
@@ -1,14 +1,13 @@
import type { ISetting } from '@rocket.chat/apps-engine/definition/settings';
import type { IAppServerOrchestrator, IAppsSetting } from '@rocket.chat/apps';
import { InternalBridge } from '@rocket.chat/apps-engine/server/bridges/InternalBridge';
import type { ISubscription } from '@rocket.chat/core-typings';
import type { ISetting, ISubscription } from '@rocket.chat/core-typings';
import { Settings, Subscriptions } from '@rocket.chat/models';

import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestrator';
import { isTruthy } from '../../../../lib/isTruthy';
import { deasyncPromise } from '../../../../server/deasync/deasync';

export class AppInternalBridge extends InternalBridge {
constructor(private readonly orch: AppServerOrchestrator) {
constructor(private readonly orch: IAppServerOrchestrator) {
super();
}

Expand Down Expand Up @@ -37,9 +36,13 @@ export class AppInternalBridge extends InternalBridge {
return records.map((s: ISubscription) => s.u.username).filter(isTruthy);
}

protected async getWorkspacePublicKey(): Promise<ISetting> {
const publicKeySetting = await Settings.findOneById('Cloud_Workspace_PublicKey');
protected async getWorkspacePublicKey(): Promise<IAppsSetting> {
// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.
const publicKeySetting: ISetting | null = await Settings.findOneById('Cloud_Workspace_PublicKey');

return this.orch.getConverters()?.get('settings').convertToApp(publicKeySetting);
return this.orch
.getConverters()
?.get('settings')
.convertToApp(publicKeySetting as ISetting);
}
}

0 comments on commit 7aaad54

Please sign in to comment.