Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into fix/…
Browse files Browse the repository at this point in the history
…turbo

* 'develop' of github.com:RocketChat/Rocket.Chat:
  [NEW] Community Edition Watermark (#25844)
  [BREAK] remove unused endpoints and restify others (#25889)
  Chore: add underscore to ddp-streamer
  [IMPROVE] VoIP admin page cleanup: remove unused settings (#25993)
  Regression: Fix micro services (#26054)
  Regression: Fix threads list (#26052)
  [NEW] VoIP Input/Output Device Selection (#25966)
  Chore: Account/Profile to TS (#25929)
  • Loading branch information
gabriellsh committed Jun 29, 2022
2 parents 4ab9ec6 + 0f40989 commit e3d86d5
Show file tree
Hide file tree
Showing 93 changed files with 1,213 additions and 731 deletions.
17 changes: 0 additions & 17 deletions apps/meteor/app/lib/server/startup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3210,7 +3210,6 @@ settingsRegistry.addGroup('Call_Center', function () {
this.add('VoIP_Enabled', false, {
type: 'boolean',
public: true,
alert: 'Experimental_Feature_Alert',
enableQuery: {
_id: 'Livechat_enabled',
value: true,
Expand All @@ -3225,22 +3224,6 @@ settingsRegistry.addGroup('Call_Center', function () {
},
});
this.section('Server_Configuration', function () {
this.add('VoIP_Server_Host', '', {
type: 'string',
public: true,
enableQuery: {
_id: 'VoIP_Enabled',
value: true,
},
});
this.add('VoIP_Server_Websocket_Port', 0, {
type: 'int',
public: true,
enableQuery: {
_id: 'VoIP_Enabled',
value: true,
},
});
this.add('VoIP_Server_Name', '', {
type: 'string',
public: true,
Expand Down
10 changes: 9 additions & 1 deletion apps/meteor/app/livechat/imports/server/rest/departments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isLivechatDepartmentProps } from '@rocket.chat/rest-typings';
import { Match, check } from 'meteor/check';

import { API } from '../../../../api/server';
import { hasPermission } from '../../../../authorization/server';
import { hasPermission, hasAtLeastOnePermission } from '../../../../authorization/server';
import { LivechatDepartment, LivechatDepartmentAgents } from '../../../../models/server';
import { Livechat } from '../../../server/lib/Livechat';
import {
Expand All @@ -18,6 +18,10 @@ API.v1.addRoute(
{ authRequired: true, validateParams: isLivechatDepartmentProps },
{
async get() {
if (!hasAtLeastOnePermission(this.userId, ['view-livechat-departments', 'view-l-room'])) {
return API.v1.unauthorized();
}

const { offset, count } = this.getPaginationItems();
const { sort } = this.parseJsonQuery();

Expand Down Expand Up @@ -76,6 +80,10 @@ API.v1.addRoute(
{ authRequired: true },
{
async get() {
if (!hasAtLeastOnePermission(this.userId, ['view-livechat-departments', 'view-l-room'])) {
return API.v1.unauthorized();
}

check(this.urlParams, {
_id: String,
});
Expand Down
21 changes: 0 additions & 21 deletions apps/meteor/app/livechat/imports/server/rest/officeHour.js

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/app/livechat/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ import '../imports/server/rest/visitors.js';
import '../imports/server/rest/visitors.ts';
import '../imports/server/rest/dashboards.js';
import '../imports/server/rest/queue.js';
import '../imports/server/rest/officeHour.js';
import '../imports/server/rest/businessHours.js';
13 changes: 0 additions & 13 deletions apps/meteor/app/livechat/server/api/lib/officeHour.js

This file was deleted.

2 changes: 0 additions & 2 deletions apps/meteor/app/livechat/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import './methods/getAgentData';
import './methods/getAgentOverviewData';
import './methods/getAnalyticsChartData';
import './methods/getAnalyticsOverviewData';
import './methods/getInitialData';
import './methods/getNextAgent';
import './methods/getRoutingConfig';
import './methods/loadHistory';
Expand Down Expand Up @@ -61,7 +60,6 @@ import './methods/sendOfflineMessage';
import './methods/setCustomField';
import './methods/setDepartmentForVisitor';
import './methods/startVideoCall';
import './methods/startFileUploadRoom';
import './methods/transfer';
import './methods/webhookTest';
import './methods/setUpConnection';
Expand Down
112 changes: 0 additions & 112 deletions apps/meteor/app/livechat/server/methods/getInitialData.js

This file was deleted.

30 changes: 0 additions & 30 deletions apps/meteor/app/livechat/server/methods/startFileUploadRoom.js

This file was deleted.

8 changes: 7 additions & 1 deletion apps/meteor/client/components/CustomFieldsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ const CustomFieldsAssembler = ({ formValues, formHandlers, customFields, ...prop
return null;
});

export default function CustomFieldsForm({ jsonCustomFields, customFieldsData, setCustomFieldsData, onLoadFields = () => {}, ...props }) {
export default function CustomFieldsForm({
jsonCustomFields = undefined,
customFieldsData,
setCustomFieldsData,
onLoadFields = () => {},
...props
}) {
const accountsCustomFieldsJson = useSetting('Accounts_CustomFields');

const [customFields] = useState(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/client/components/Omnichannel/Tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Tags = ({
const t = useTranslation();
const forms = useFormsSubscription() as any;

const { value: tagsResult, phase: stateTags } = useEndpointData('/v1/livechat/tags.list');
const { value: tagsResult, phase: stateTags } = useEndpointData('/v1/livechat/tags');

// TODO: Refactor the formsSubscription to use components instead of hooks (since the only thing the hook does is return a component)
const { useCurrentChatTags } = forms;
Expand Down
35 changes: 34 additions & 1 deletion apps/meteor/client/contexts/CallContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { IVoipRoom } from '@rocket.chat/core-typings';
import type { CallStates, IVoipRoom } from '@rocket.chat/core-typings';
import { ICallerInfo, VoIpCallerInfo } from '@rocket.chat/core-typings';
import { Device } from '@rocket.chat/ui-contexts';
import { createContext, useContext, useMemo } from 'react';
import { useSyncExternalStore } from 'use-sync-external-store/shim';

Expand Down Expand Up @@ -29,6 +30,8 @@ type CallContextReady = {
openRoom: (rid: IVoipRoom['_id']) => void;
createRoom: (caller: ICallerInfo) => IVoipRoom['_id'];
closeRoom: (data?: { comment?: string; tags?: string[] }) => void;
changeAudioOutputDevice: (selectedAudioDevices: Device) => void;
changeAudioInputDevice: (selectedAudioDevices: Device) => void;
};
type CallContextError = {
enabled: true;
Expand Down Expand Up @@ -84,6 +87,16 @@ export const useCallActions = (): CallActionsType => {
return context.actions;
};

export const useCallerStatus = (): CallStates => {
const context = useContext(CallContext);

if (isCallContextReady(context)) {
return context.voipClient.callState;
}

return 'INITIAL';
};

export const useCallerInfo = (): VoIpCallerInfo => {
const context = useContext(CallContext);

Expand Down Expand Up @@ -188,3 +201,23 @@ export const useOpenedRoomInfo = (): CallContextReady['openedRoomInfo'] => {

return context.openedRoomInfo;
};

export const useChangeAudioOutputDevice = (): CallContextReady['changeAudioOutputDevice'] => {
const context = useContext(CallContext);

if (!isCallContextReady(context)) {
throw new Error('useChangeAudioOutputDevice only if Calls are enabled and ready');
}

return context.changeAudioOutputDevice;
};

export const useChangeAudioInputDevice = (): CallContextReady['changeAudioOutputDevice'] => {
const context = useContext(CallContext);

if (!isCallContextReady(context)) {
throw new Error('useChangeAudioInputDevice only if Calls are enabled and ready');
}

return context.changeAudioInputDevice;
};
21 changes: 5 additions & 16 deletions apps/meteor/client/hooks/useUpdateAvatar.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import { IUser } from '@rocket.chat/core-typings';
import { AvatarObject, AvatarServiceObject, AvatarReset, AvatarUrlObj, IUser } from '@rocket.chat/core-typings';
import { useToastMessageDispatch, useMethod, useTranslation } from '@rocket.chat/ui-contexts';
import { useMemo, useCallback } from 'react';

import { useEndpointAction } from './useEndpointAction';
import { useEndpointUpload } from './useEndpointUpload';

type AvatarUrlObj = {
avatarUrl: string;
};

type AvatarReset = 'reset';

type AvatarServiceObject = {
blob: Blob;
contentType: string;
service: string;
};

type AvatarObject = AvatarReset | AvatarUrlObj | FormData | AvatarServiceObject;

const isAvatarReset = (avatarObj: AvatarObject): avatarObj is AvatarReset => avatarObj === 'reset';
const isServiceObject = (avatarObj: AvatarObject): avatarObj is AvatarServiceObject =>
!isAvatarReset(avatarObj) && typeof avatarObj === 'object' && 'service' in avatarObj;
const isAvatarUrl = (avatarObj: AvatarObject): avatarObj is AvatarUrlObj =>
!isAvatarReset(avatarObj) && typeof avatarObj === 'object' && 'service' && 'avatarUrl' in avatarObj;

export const useUpdateAvatar = (avatarObj: AvatarObject, userId: IUser['_id']): (() => void) => {
export const useUpdateAvatar = (
avatarObj: AvatarObject,
userId: IUser['_id'],
): (() => Promise<{ success: boolean } | null | undefined>) => {
const t = useTranslation();
const avatarUrl = isAvatarUrl(avatarObj) ? avatarObj.avatarUrl : '';

Expand Down
Loading

0 comments on commit e3d86d5

Please sign in to comment.