Skip to content

Commit

Permalink
Merge branch 'develop' into improve/videoconf-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed Aug 17, 2022
2 parents d7c1342 + ddfcf87 commit 07e8c04
Show file tree
Hide file tree
Showing 267 changed files with 2,995 additions and 2,270 deletions.
13 changes: 13 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@
/apps/meteor/client/ @RocketChat/frontend
/apps/meteor/tests/ @RocketChat/chat-engine
/apps/meteor/app/apps/ @RocketChat/apps
/apps/meteor/app/livechat @RocketChat/omnichannel
/apps/meteor/app/voip @RocketChat/omnichannel
/apps/meteor/app/sms @RocketChat/omnichannel
/apps/meteor/packages/rocketchat-livechat @RocketChat/omnichannel
/apps/meteor/server/services/voip @RocketChat/omnichannel
/apps/meteor/server/services/omnichannel-voip @RocketChat/omnichannel
/apps/meteor/server/features/EmailInbox @RocketChat/omnichannel
/apps/meteor/ee/app/canned-responses @RocketChat/omnichannel
/apps/meteor/ee/app/livechat @RocketChat/omnichannel
/apps/meteor/ee/app/livechat-enterprise @RocketChat/omnichannel
/apps/meteor/ee/client/omnichannel @RocketChat/omnichannel
/apps/meteor/client/components/omnichannel @RocketChat/omnichannel
/apps/meteor/client/components/voip @RocketChat/omnichannel
8 changes: 1 addition & 7 deletions apps/meteor/app/2fa/client/overrideMeteorCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Meteor } from 'meteor/meteor';
import { t } from '../../utils/client';
import { process2faReturn } from '../../../client/lib/2fa/process2faReturn';
import { isTotpInvalidError } from '../../../client/lib/2fa/utils';
import { dispatchToastMessage } from '../../../client/lib/toast';

const { call } = Meteor;

Expand All @@ -17,12 +16,7 @@ const callWithTotp =
(twoFactorCode: string, twoFactorMethod: string): unknown =>
call(methodName, ...args, { twoFactorCode, twoFactorMethod }, (error: unknown, result: unknown): void => {
if (isTotpInvalidError(error)) {
(error as { toastrShowed?: true }).toastrShowed = true;
dispatchToastMessage({
type: 'error',
message: twoFactorMethod === 'password' ? t('Invalid_password') : t('Invalid_two_factor_code'),
});
callback(error);
callback(new Error(twoFactorMethod === 'password' ? t('Invalid_password') : t('Invalid_two_factor_code')));
return;
}

Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/action-links/client/lib/actionLinks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import type { IMessage } from '@rocket.chat/core-typings';

import { handleError } from '../../../../client/lib/utils/handleError';
import { dispatchToastMessage } from '../../../../client/lib/toast';

// Action Links namespace creation.
export const actionLinks = {
Expand Down Expand Up @@ -71,9 +71,9 @@ export const actionLinks = {
}

// and run on server side
Meteor.call('actionLinkHandler', name, message._id, (err: Error) => {
if (err && !ranClient) {
handleError(err);
Meteor.call('actionLinkHandler', name, message._id, (error: unknown) => {
if (error && !ranClient) {
dispatchToastMessage({ type: 'error', message: error });
}
});
},
Expand Down
20 changes: 11 additions & 9 deletions apps/meteor/app/api/server/v1/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@ API.v1.addRoute(
{ authRequired: true },
{
async post() {
const [asset, { refreshAllClients }, assetName] = await getUploadFormData({
request: this.request,
});
const [asset, { refreshAllClients, assetName: customName }, fileName] = await getUploadFormData(
{
request: this.request,
},
{ field: 'asset' },
);

const assetName = customName || fileName;
const assetsKeys = Object.keys(RocketChatAssets.assets);

const isValidAsset = assetsKeys.includes(assetName);
if (!isValidAsset) {
throw new Meteor.Error('error-invalid-asset', 'Invalid asset');
}

Meteor.runAsUser(this.userId, () => {
Meteor.call('setAsset', asset.fileBuffer, asset.mimetype, assetName);
if (refreshAllClients) {
Meteor.call('refreshClients');
}
});
Meteor.call('setAsset', asset.fileBuffer, asset.mimetype, assetName);
if (refreshAllClients) {
Meteor.call('refreshClients');
}

return API.v1.success();
},
Expand Down
41 changes: 41 additions & 0 deletions apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import {
isMethodCallProps,
isMethodCallAnonProps,
isMeteorCall,
validateParamsPwGetPolicyRest,
} from '@rocket.chat/rest-typings';
import type { IUser } from '@rocket.chat/core-typings';
import { Users as UsersRaw } from '@rocket.chat/models';

import { hasPermission } from '../../../authorization/server';
import { Users } from '../../../models/server';
Expand All @@ -24,6 +26,7 @@ import { getDefaultUserFields } from '../../../utils/server/functions/getDefault
import { getURL } from '../../../utils/lib/getURL';
import { getLogs } from '../../../../server/stream/stdout';
import { SystemLogger } from '../../../../server/lib/logger/system';
import { passwordPolicy } from '../../../lib/server';

/**
* @openapi
Expand Down Expand Up @@ -383,6 +386,44 @@ API.v1.addRoute(
},
);

API.v1.addRoute(
'pw.getPolicy',
{
authRequired: true,
},
{
get() {
return API.v1.success(passwordPolicy.getPasswordPolicy());
},
},
);

API.v1.addRoute(
'pw.getPolicyReset',
{
authRequired: false,
validateParams: validateParamsPwGetPolicyRest,
},
{
async get() {
check(
this.queryParams,
Match.ObjectIncluding({
token: String,
}),
);
const { token } = this.queryParams;

const user = await UsersRaw.findOneByResetToken(token, { projection: { _id: 1 } });
if (!user) {
return API.v1.unauthorized();
}

return API.v1.success(passwordPolicy.getPasswordPolicy());
},
},
);

/**
* @openapi
* /api/v1/stdout.queue:
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/apps/client/gameCenter/gameCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { ReactiveVar } from 'meteor/reactive-var';

import { modal } from '../../../ui-utils/client';
import { APIClient, t } from '../../../utils/client';
import { dispatchToastMessage } from '../../../../client/lib/toast';
import './gameCenter.html';
import { handleError } from '../../../../client/lib/utils/handleError';

const getExternalComponents = async (instance) => {
try {
const { externalComponents } = await APIClient.get('/apps/externalComponents');
instance.games.set(externalComponents);
} catch (e) {
handleError(e);
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}

instance.isLoading.set(false);
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/apps/client/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class AppClientOrchestrator {
return this._manager;
}

public handleError(error: Error): void {
public handleError(error: unknown): void {
if (hasAtLeastOnePermission(['manage-apps'])) {
dispatchToastMessage({
type: 'error',
message: error.message,
message: error,
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/assets/server/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ class RocketChatAssetsClass {

const extension = getExtension(contentType);
if (assetInstance.constraints.extensions.includes(extension) === false) {
throw new Meteor.Error(contentType, `Invalid file type: ${contentType}`, {
throw new Meteor.Error('error-invalid-file-type', `Invalid file type: ${contentType}`, {
function: 'RocketChat.Assets.setAsset',
errorTitle: 'error-invalid-file-type',
});
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/cas/server/cas_rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Meteor.startup(function () {
});

this.section('CAS_Login_Layout', function () {
this.add('CAS_popup_width', '810', { type: 'int', group: 'CAS', public: true });
this.add('CAS_popup_height', '610', { type: 'int', group: 'CAS', public: true });
this.add('CAS_popup_width', 810, { type: 'int', group: 'CAS', public: true });
this.add('CAS_popup_height', 610, { type: 'int', group: 'CAS', public: true });
this.add('CAS_button_label_text', 'CAS', { type: 'string', group: 'CAS' });
this.add('CAS_button_label_color', '#FFFFFF', { type: 'color', group: 'CAS' });
this.add('CAS_button_color', '#1d74f5', { type: 'color', group: 'CAS' });
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/e2e/client/tabbar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo, useCallback } from 'react';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useSetting, usePermission, useMethod } from '@rocket.chat/ui-contexts';
import { useSetting, usePermission, useEndpoint } from '@rocket.chat/ui-contexts';

import { addAction } from '../../../client/views/room/lib/Toolbox';
import { useReactiveValue } from '../../../client/hooks/useReactiveValue';
Expand All @@ -13,10 +13,10 @@ addAction('e2e', ({ room }) => {
const canEditRoom = usePermission('edit-room', room._id);
const hasPermission = (room.t === 'd' || (canEditRoom && canToggleE2e)) && e2eReady;

const toggleE2E = useMethod('saveRoomSettings');
const toggleE2E = useEndpoint('POST', '/v1/rooms.saveRoomSettings');

const action = useMutableCallback(() => {
toggleE2E(room._id, 'encrypted', !room.encrypted);
toggleE2E({ rid: room._id, encrypted: !room.encrypted });
});

const enabledOnRoom = !!room.encrypted;
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/lib/server/functions/addUserToRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ export const addUserToRoom = function (
});
}

if (room.teamMain && room.teamId && inviter) {
if (room.teamMain && room.teamId) {
// if user is joining to main team channel, create a membership
Promise.await(Team.addMember(inviter, userToBeAdded._id, room.teamId));
Promise.await(Team.addMember(inviter || userToBeAdded, userToBeAdded._id, room.teamId));
}

return true;
Expand Down
6 changes: 4 additions & 2 deletions apps/meteor/app/lib/server/functions/cleanRoomHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export const cleanRoomHistory = function ({

let fileCount = 0;
Messages.findFilesByRoomIdPinnedTimestampAndUsers(rid, excludePinned, ignoreDiscussion, ts, fromUsers, ignoreThreads, {
fields: { 'file._id': 1, 'pinned': 1 },
fields: { pinned: 1, files: 1 },
limit,
}).forEach((document: IMessage) => {
FileUpload.getStore('Uploads').deleteById(document.file?._id);
const uploadsStore = FileUpload.getStore('Uploads');

document.files?.forEach((file) => uploadsStore.deleteById(file._id));
fileCount++;
if (filesOnly) {
Messages.update({ _id: document._id }, { $unset: { file: 1 }, $set: { attachments: [{ color: '#FD745E', text }] } });
Expand Down
128 changes: 0 additions & 128 deletions apps/meteor/app/livechat/client/lib/dateHandler.js

This file was deleted.

Loading

0 comments on commit 07e8c04

Please sign in to comment.