Skip to content

Commit

Permalink
Merge branch 'RocketChat:develop' into PRTour1
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSingh-02 authored Jun 24, 2023
2 parents c8db21f + 1dd51c0 commit e57f637
Show file tree
Hide file tree
Showing 241 changed files with 3,197 additions and 3,150 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-forks-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed a problem where the setting `Show Agent Email` from Omnichannel was not being used by the back when returning agent's info
10 changes: 10 additions & 0 deletions .changeset/custom-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/core-typings": patch
"@rocket.chat/rest-typings": patch
"@rocket.chat/ui-client": patch
"@rocket.chat/ui-contexts": patch
"@rocket.chat/web-ui-registration": patch
---

Added and Improved Custom Fields form to Registration Flow
5 changes: 5 additions & 0 deletions .changeset/hungry-oranges-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed a bug with autotranslation encoding text
5 changes: 5 additions & 0 deletions .changeset/little-crews-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

fix show badge for thread direct mentions
6 changes: 6 additions & 0 deletions .changeset/pretty-clocks-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/model-typings": patch
---

fix: hidden custom fields being required in some cases
6 changes: 6 additions & 0 deletions .changeset/slimy-olives-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/rest-typings': minor
'@rocket.chat/meteor': minor
---

Reintroduce an user preference to allow users to see all thread messages in the main channel
5 changes: 5 additions & 0 deletions .changeset/soft-carrots-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed an error on mobile ios browser where if you started recording audio and denied permission, it would look like it is still recording
5 changes: 5 additions & 0 deletions .changeset/two-wasps-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed Business Hours behavior so they now Take seconds in consideration to assess if BH is open/closed
8 changes: 4 additions & 4 deletions .github/workflows/ci-code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
check: ['ts', 'lint']

steps:
# - name: Set Swap Space
# uses: pierotofy/set-swap-space@master
# with:
# swap-size-gb: 4
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 4

- uses: actions/checkout@v3

Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ jobs:
# docker rmi $(docker image ls -aq)
# df -h

- name: Cache vite
uses: actions/cache@v3
with:
path: ./node_modules/.vite
key: vite-local-cache-${{ runner.OS }}-${{ hashFiles('package.json') }}
restore-keys: |
vite-local-cache-${{ runner.os }}-
- name: Cache meteor local
uses: actions/cache@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { getUserInfo } from '../helpers/getUserInfo';
import { getPaginationItems } from '../helpers/getPaginationItems';
import { getUserFromParams } from '../helpers/getUserFromParams';
import { i18n } from '../../../../server/lib/i18n';
import { apiDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';

/**
* @openapi
Expand Down Expand Up @@ -392,7 +393,7 @@ API.v1.addRoute(
API.v1.addRoute(
'pw.getPolicy',
{
authRequired: true,
authRequired: false,
},
{
get() {
Expand All @@ -409,6 +410,7 @@ API.v1.addRoute(
},
{
async get() {
apiDeprecationLogger.endpoint(this.request.route, '7.0.0', this.response, ' Use pw.getPolicy instead.');
check(
this.queryParams,
Match.ObjectIncluding({
Expand Down
13 changes: 13 additions & 0 deletions apps/meteor/app/api/server/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,15 @@ API.v1.addRoute(
}

const { secret: secretURL, ...params } = this.bodyParams;

if (this.bodyParams.customFields) {
try {
await validateCustomFields(this.bodyParams.customFields);
} catch (e) {
return API.v1.failure(e);
}
}

// Register the user
const userId = await Meteor.callAsync('registerUser', {
...params,
Expand All @@ -579,6 +588,10 @@ API.v1.addRoute(
return API.v1.failure('User not found');
}

if (this.bodyParams.customFields) {
await saveCustomFields(userId, this.bodyParams.customFields);
}

return API.v1.success({ user });
},
},
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/apps/server/bridges/livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { AppServerOrchestrator } from '../../../../ee/server/apps/orchestra
import { Livechat as LivechatTyped } from '../../../livechat/server/lib/LivechatTyped';
import { callbacks } from '../../../../lib/callbacks';
import { deasyncPromise } from '../../../../server/deasync/deasync';
import { settings } from '../../../settings/server';

export class AppLivechatBridge extends LivechatBridge {
// eslint-disable-next-line no-empty-function
Expand Down Expand Up @@ -90,7 +91,7 @@ export class AppLivechatBridge extends LivechatBridge {

let agentRoom: SelectedAgent | undefined;
if (agent?.id) {
const user = await Users.getAgentInfo(agent.id);
const user = await Users.getAgentInfo(agent.id, settings.get('Livechat_show_agent_email'));
if (!user) {
throw new Error(`The agent with id "${agent.id}" was not found.`);
}
Expand Down
5 changes: 2 additions & 3 deletions apps/meteor/app/autotranslate/server/deeplTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ class DeeplAutoTranslate extends AutoTranslate {
*/
async _translateMessage(message: IMessage, targetLanguages: string[]): Promise<ITranslationResult> {
const translations: { [k: string]: string } = {};
let msgs = message.msg.split('\n');
msgs = msgs.map((msg) => encodeURIComponent(msg));
const msgs = message.msg.split('\n');
const supportedLanguages = await this.getSupportedLanguages('en');
for await (let language of targetLanguages) {
if (language.indexOf('-') !== -1 && !_.findWhere(supportedLanguages, { language })) {
Expand Down Expand Up @@ -250,7 +249,7 @@ class DeeplAutoTranslate extends AutoTranslate {
params: {
auth_key: this.apiKey,
target_lang: language,
text: encodeURIComponent(attachment.description || attachment.text || ''),
text: attachment.description || attachment.text || '',
},
});
if (!result.ok) {
Expand Down
6 changes: 2 additions & 4 deletions apps/meteor/app/autotranslate/server/googleTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ class GoogleAutoTranslate extends AutoTranslate {
*/
async _translateMessage(message: IMessage, targetLanguages: string[]): Promise<ITranslationResult> {
const translations: { [k: string]: string } = {};
let msgs = message.msg.split('\n');
msgs = msgs.map((msg) => encodeURIComponent(msg));

const supportedLanguages = await this.getSupportedLanguages('en');

Expand All @@ -142,7 +140,7 @@ class GoogleAutoTranslate extends AutoTranslate {
key: this.apiKey,
target: language,
format: 'text',
q: msgs,
q: message.msg.split('\n'),
},
});
if (!result.ok) {
Expand Down Expand Up @@ -189,7 +187,7 @@ class GoogleAutoTranslate extends AutoTranslate {
key: this.apiKey,
target: language,
format: 'text',
q: encodeURIComponent(attachment.description || attachment.text || ''),
q: attachment.description || attachment.text || '',
},
});
if (!result.ok) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Meteor.methods<ServerMethods>({
$set: {
scriptCompiled,
},
$unset: { scriptError: 1 },
$unset: { scriptError: 1 as const },
},
);
} catch (e) {
Expand All @@ -96,7 +96,7 @@ Meteor.methods<ServerMethods>({
scriptError,
},
$unset: {
scriptCompiled: 1,
scriptCompiled: 1 as const,
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ Meteor.methods<ServerMethods>({
{ _id: integrationId },
{
$set: { scriptCompiled: integration.scriptCompiled },
$unset: { scriptError: 1 },
$unset: { scriptError: 1 as const },
},
);
} else {
await Integrations.updateOne(
{ _id: integrationId },
{
$set: { scriptError: integration.scriptError },
$unset: { scriptCompiled: 1 },
$unset: { scriptCompiled: 1 as const },
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/api/lib/livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function getRoom({
return LivechatTyped.getRoom(guest, message, roomInfo, agent, extraParams);
}

export async function findAgent(agentId: string): Promise<void | { hiddenInfo: true } | ILivechatAgent> {
export async function findAgent(agentId?: string): Promise<void | { hiddenInfo: true } | ILivechatAgent> {
return normalizeAgent(agentId);
}

Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/livechat/server/business-hour/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createDefaultBusinessHourRow } from './LivechatBusinessHours';
export const filterBusinessHoursThatMustBeOpened = async (
businessHours: ILivechatBusinessHour[],
): Promise<Pick<ILivechatBusinessHour, '_id' | 'type'>[]> => {
const currentTime = moment(moment().format('dddd:HH:mm'), 'dddd:HH:mm');
const currentTime = moment(moment().format('dddd:HH:mm:ss'), 'dddd:HH:mm:ss');

return businessHours
.filter(
Expand All @@ -17,9 +17,9 @@ export const filterBusinessHoursThatMustBeOpened = async (
businessHour.workHours
.filter((hour) => hour.open)
.some((hour) => {
const localTimeStart = moment(`${hour.start.cron.dayOfWeek}:${hour.start.cron.time}`, 'dddd:HH:mm');
const localTimeFinish = moment(`${hour.finish.cron.dayOfWeek}:${hour.finish.cron.time}`, 'dddd:HH:mm');
return currentTime.isSameOrAfter(localTimeStart) && currentTime.isSameOrBefore(localTimeFinish);
const localTimeStart = moment(`${hour.start.cron.dayOfWeek}:${hour.start.cron.time}:00`, 'dddd:HH:mm:ss');
const localTimeFinish = moment(`${hour.finish.cron.dayOfWeek}:${hour.finish.cron.time}:00`, 'dddd:HH:mm:ss');
return currentTime.isSameOrAfter(localTimeStart) && currentTime.isBefore(localTimeFinish);
}),
)
.map((businessHour) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ callbacks.add(
return message;
}

if (!RoutingManager.getConfig().showQueue) {
if (!RoutingManager.getConfig()?.showQueue) {
// since last message is only getting used on UI as preview message when queue is enabled
return message;
}
Expand Down
10 changes: 7 additions & 3 deletions apps/meteor/app/livechat/server/lib/Contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ export const Contacts = {
}
}

const allowedCF = LivechatCustomField.findByScope<Pick<ILivechatCustomField, '_id' | 'label' | 'regexp' | 'required'>>('visitor', {
projection: { _id: 1, label: 1, regexp: 1, required: 1 },
});
const allowedCF = LivechatCustomField.findByScope<Pick<ILivechatCustomField, '_id' | 'label' | 'regexp' | 'required' | 'visibility'>>(
'visitor',
{
projection: { _id: 1, label: 1, regexp: 1, required: 1 },
},
false,
);

const livechatData: Record<string, string> = {};

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/lib/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const normalizeAgent = async (agentId) => {
return { hiddenInfo: true };
}

const agent = await Users.getAgentInfo(agentId);
const agent = await Users.getAgentInfo(agentId, settings.get('Livechat_show_agent_email'));
const { customFields: agentCustomFields, ...extraData } = agent;
const customFields = parseAgentCustomFields(agentCustomFields);

Expand Down
Loading

0 comments on commit e57f637

Please sign in to comment.