Skip to content

Commit

Permalink
Merge branch 'develop' into improve/home
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Aug 17, 2022
2 parents 708664d + 5bca39e commit 5f670eb
Show file tree
Hide file tree
Showing 217 changed files with 2,080 additions and 1,660 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
/apps/meteor/app/voip @RocketChat/omnichannel
/apps/meteor/app/sms @RocketChat/omnichannel
/apps/meteor/packages/rocketchat-livechat @RocketChat/omnichannel
/apps/meteor/packages/rocketchat-i18n @RocketChat/translation
/apps/meteor/server/services/voip @RocketChat/omnichannel
/apps/meteor/server/services/omnichannel-voip @RocketChat/omnichannel
/apps/meteor/server/features/EmailInbox @RocketChat/omnichannel
Expand Down
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
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
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.

5 changes: 3 additions & 2 deletions apps/meteor/app/livechat/client/views/app/dialog/closeRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { settings } from '../../../../../settings';
import { modal } from '../../../../../ui-utils/client';
import { APIClient, t } from '../../../../../utils';
import { hasAnyRole } from '../../../../../authorization';
import { dispatchToastMessage } from '../../../../../../client/lib/toast';
import './closeRoom.html';
import { handleError } from '../../../../../../client/lib/utils/handleError';

const validateRoomComment = (comment) => {
if (!settings.get('Livechat_request_comment_when_closing_conversation')) {
Expand Down Expand Up @@ -87,7 +87,8 @@ Template.closeRoom.events({
Meteor.call('livechat:closeRoom', this.rid, comment, { clientAction: true, tags }, function (error /* , result*/) {
if (error) {
console.log(error);
return handleError(error);
dispatchToastMessage({ type: 'error', message: error });
return;
}

modal.open({
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/livechat/client/views/app/livechatReadOnly.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { FlowRouter } from 'meteor/kadira:flow-router';

import { ChatRoom, CachedChatRoom } from '../../../../models/client';
import { callWithErrorHandling } from '../../../../../client/lib/utils/callWithErrorHandling';
import './livechatReadOnly.html';
import { APIClient } from '../../../../utils/client';
import { RoomManager } from '../../../../ui-utils/client/lib/RoomManager';
import { inquiryDataStream } from '../../lib/stream/inquiry';
import { handleError } from '../../../../../client/lib/utils/handleError';
import { dispatchToastMessage } from '../../../../../client/lib/toast';
import './livechatReadOnly.html';

Template.livechatReadOnly.helpers({
inquiryOpen() {
Expand Down Expand Up @@ -66,7 +66,7 @@ Template.livechatReadOnly.events({
throw new Meteor.Error('error-join-room', 'Error joining room');
}
} catch (error) {
handleError(error);
dispatchToastMessage({ type: 'error', message: error });
throw error;
}
},
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/livechat/client/views/app/tabbar/agentEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';

import { getCustomFormTemplate } from '../customTemplates/register';
import './agentEdit.html';
import { hasPermission } from '../../../../../authorization';
import { t, APIClient } from '../../../../../utils/client';
import { handleError } from '../../../../../../client/lib/utils/handleError';
import { dispatchToastMessage } from '../../../../../../client/lib/toast';
import './agentEdit.html';

Template.agentEdit.helpers({
canEditDepartment() {
Expand Down Expand Up @@ -80,7 +79,8 @@ Template.agentEdit.events({
const agentDepartments = instance.agentDepartments.get();
Meteor.call('livechat:saveAgentInfo', _id, agentData, agentDepartments, (error) => {
if (error) {
return handleError(error);
dispatchToastMessage({ type: 'error', message: error });
return;
}

dispatchToastMessage({ type: 'success', message: t('Saved') });
Expand Down
7 changes: 4 additions & 3 deletions apps/meteor/app/livechat/client/views/app/tabbar/agentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import _ from 'underscore';
import s from 'underscore.string';

import { getCustomFormTemplate } from '../customTemplates/register';
import './agentInfo.html';
import { modal } from '../../../../../ui-utils';
import { t, APIClient } from '../../../../../utils/client';
import { hasPermission } from '../../../../../authorization';
import { handleError } from '../../../../../../client/lib/utils/handleError';
import { dispatchToastMessage } from '../../../../../../client/lib/toast';
import './agentInfo.html';

const customFieldsTemplate = () => getCustomFormTemplate('livechatAgentInfoForm');

Expand Down Expand Up @@ -118,7 +118,8 @@ Template.agentInfo.events({
() => {
Meteor.call('livechat:removeAgent', this.username, (error) => {
if (error) {
return handleError(error);
dispatchToastMessage({ type: 'error', message: error });
return;
}

const { tabBar, onRemoveAgent } = instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { Subscriptions } from '../../../../../models/client';
import { settings } from '../../../../../settings';
import { t } from '../../../../../utils';
import { hasRole, hasPermission, hasAtLeastOnePermission } from '../../../../../authorization';
import './visitorInfo.html';
import { APIClient } from '../../../../../utils/client';
import { RoomManager } from '../../../../../ui-utils/client';
import { getCustomFormTemplate } from '../customTemplates/register';
import { Markdown } from '../../../../../markdown/client';
import { handleError } from '../../../../../../client/lib/utils/handleError';
import { formatDateAndTime } from '../../../../../../client/lib/utils/formatDateAndTime';
import { roomCoordinator } from '../../../../../../client/lib/rooms/roomCoordinator';
import { dispatchToastMessage } from '../../../../../../client/lib/toast';
import './visitorInfo.html';

const isSubscribedToRoom = () => {
const data = Template.currentData();
Expand Down Expand Up @@ -279,7 +279,8 @@ Template.visitorInfo.events({
const comment = TAPi18n.__('Chat_closed_by_agent');
return Meteor.call('livechat:closeRoom', this.rid, comment, { clientAction: true }, function (error /* , result*/) {
if (error) {
return handleError(error);
dispatchToastMessage({ type: 'error', message: error });
return;
}

modal.open({
Expand Down Expand Up @@ -320,7 +321,7 @@ Template.visitorInfo.events({
() => {
Meteor.call('livechat:returnAsInquiry', this.rid, function (error /* , result*/) {
if (error) {
handleError(error);
dispatchToastMessage({ type: 'error', message: error });
} else {
Session.set('openedRoom');
FlowRouter.go('/home');
Expand Down
Loading

0 comments on commit 5f670eb

Please sign in to comment.