Skip to content

Commit

Permalink
Merge branch 'develop' into fix/accounts-email-verification
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 23, 2023
2 parents b1b6428 + 72653e6 commit 74c8c07
Show file tree
Hide file tree
Showing 91 changed files with 1,436 additions and 935 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-ties-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

fix: custom-css injection
5 changes: 5 additions & 0 deletions .changeset/cyan-mangos-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: UI issue on marketplace filters
5 changes: 5 additions & 0 deletions .changeset/empty-files-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix unnecessary username validation on accounts profile form
5 changes: 5 additions & 0 deletions .changeset/hip-pans-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Omnichannel webhook is not retrying requests
5 changes: 5 additions & 0 deletions .changeset/lazy-shoes-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

chore: adding some portugueses translations to the app details page
5 changes: 5 additions & 0 deletions .changeset/rotten-dryers-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Add pagination & tooltips to agent's dropdown on forwarding modal
2 changes: 1 addition & 1 deletion apps/meteor/app/apps/server/bridges/livechat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class AppLivechatBridge extends LivechatBridge {
throw new Error('Invalid token for livechat message');
}

const msg = await Livechat.sendMessage({
const msg = await LivechatTyped.sendMessage({
guest: this.orch.getConverters()?.get('visitors').convertAppVisitor(message.visitor),
message: await this.orch.getConverters()?.get('messages').convertAppMessage(message),
agent: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type WorkspaceRegistrationData<T> = {
MAC: number;
// activeContactsBillingMonth: number;
// activeContactsYesterday: number;
statsToken?: string;
};

export async function buildWorkspaceRegistrationData<T extends string | undefined>(contactEmail: T): Promise<WorkspaceRegistrationData<T>> {
Expand Down Expand Up @@ -92,5 +93,6 @@ export async function buildWorkspaceRegistrationData<T extends string | undefine
MAC: stats.omnichannelContactsBySource?.contactsCount ?? 0,
// activeContactsBillingMonth: stats.omnichannelContactsBySource.contactsCount,
// activeContactsYesterday: stats.uniqueContactsOfYesterday.contactsCount,
statsToken: stats.statsToken,
};
}
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/imports/server/rest/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ API.v1.addRoute('livechat/sms-incoming/:service', {
};

try {
const msg = SMSService.response.call(this, await Livechat.sendMessage(sendMessage));
const msg = SMSService.response.call(this, await LivechatTyped.sendMessage(sendMessage));
setImmediate(async () => {
if (sms.extra) {
if (sms.extra.fromCountry) {
Expand Down
13 changes: 8 additions & 5 deletions apps/meteor/app/livechat/imports/server/rest/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ import { hasAtLeastOnePermissionAsync } from '../../../../authorization/server/f
import { findAgents, findManagers } from '../../../server/api/lib/users';
import { Livechat } from '../../../server/lib/Livechat';

const emptyStringArray: string[] = [];

API.v1.addRoute(
'livechat/users/:type',
{
authRequired: true,
permissionsRequired: {
GET: {
permissions: ['manage-livechat-agents'],
operation: 'hasAll',
},
POST: { permissions: ['view-livechat-manager'], operation: 'hasAll' },
'POST': ['view-livechat-manager'],
'*': emptyStringArray,
},
validateParams: {
GET: isLivechatUsersManagerGETProps,
Expand All @@ -39,9 +38,13 @@ API.v1.addRoute(
return API.v1.unauthorized();
}

const { onlyAvailable, excludeId, showIdleAgents } = this.queryParams;
return API.v1.success(
await findAgents({
text,
onlyAvailable,
excludeId,
showIdleAgents,
pagination: {
offset,
count,
Expand Down
39 changes: 35 additions & 4 deletions apps/meteor/app/livechat/server/api/lib/users.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ILivechatAgent, IRole } from '@rocket.chat/core-typings';
import { Users } from '@rocket.chat/models';
import { escapeRegExp } from '@rocket.chat/string-helpers';
import type { FilterOperators } from 'mongodb';

/**
* @param {IRole['_id']} role the role id
Expand All @@ -10,18 +11,39 @@ import { escapeRegExp } from '@rocket.chat/string-helpers';
async function findUsers({
role,
text,
onlyAvailable = false,
excludeId,
showIdleAgents = true,
pagination: { offset, count, sort },
}: {
role: IRole['_id'];
text?: string;
onlyAvailable?: boolean;
excludeId?: string;
showIdleAgents?: boolean;
pagination: { offset: number; count: number; sort: any };
}): Promise<{ users: ILivechatAgent[]; count: number; offset: number; total: number }> {
const query = {};
const query: FilterOperators<ILivechatAgent> = {};
const orConditions: FilterOperators<ILivechatAgent>['$or'] = [];
if (text) {
const filterReg = new RegExp(escapeRegExp(text), 'i');
Object.assign(query, {
$or: [{ username: filterReg }, { name: filterReg }, { 'emails.address': filterReg }],
});
orConditions.push({ $or: [{ username: filterReg }, { name: filterReg }, { 'emails.address': filterReg }] });
}

if (onlyAvailable) {
query.statusLivechat = 'available';
}

if (excludeId) {
query._id = { $ne: excludeId };
}

if (!showIdleAgents) {
orConditions.push({ $or: [{ status: { $exists: true, $ne: 'offline' }, roles: { $ne: 'bot' } }, { roles: 'bot' }] });
}

if (orConditions.length) {
query.$and = orConditions;
}

const [
Expand Down Expand Up @@ -52,14 +74,23 @@ async function findUsers({
}
export async function findAgents({
text,
onlyAvailable = false,
excludeId,
showIdleAgents = true,
pagination: { offset, count, sort },
}: {
text?: string;
onlyAvailable: boolean;
excludeId?: string;
showIdleAgents?: boolean;
pagination: { offset: number; count: number; sort: any };
}): Promise<ReturnType<typeof findUsers>> {
return findUsers({
role: 'livechat-agent',
text,
onlyAvailable,
excludeId,
showIdleAgents,
pagination: {
offset,
count,
Expand Down
16 changes: 10 additions & 6 deletions apps/meteor/app/livechat/server/api/v1/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { isWidget } from '../../../../api/server/helpers/isWidget';
import { loadMessageHistory } from '../../../../lib/server/functions/loadMessageHistory';
import { settings } from '../../../../settings/server';
import { normalizeMessageFileUpload } from '../../../../utils/server/functions/normalizeMessageFileUpload';
import { Livechat } from '../../lib/Livechat';
import { Livechat as LivechatTyped } from '../../lib/LivechatTyped';
import { findGuest, findRoom, normalizeHttpHeaderData } from '../lib/livechat';

Expand Down Expand Up @@ -67,7 +66,7 @@ API.v1.addRoute(
},
};

const result = await Livechat.sendMessage(sendMessage);
const result = await LivechatTyped.sendMessage(sendMessage);
if (result) {
const message = await Messages.findOneById(_id);
if (!message) {
Expand Down Expand Up @@ -176,7 +175,7 @@ API.v1.addRoute(
throw new Error('invalid-message');
}

const result = await Livechat.deleteMessage({ guest, message });
const result = await LivechatTyped.deleteMessage({ guest, message });
if (result) {
return API.v1.success({
message: {
Expand Down Expand Up @@ -272,10 +271,15 @@ API.v1.addRoute(
visitor = await LivechatVisitors.findOneEnabledById(visitorId);
}

const guest = visitor;
if (!guest) {
throw new Error('error-invalid-token');
}

const sentMessages = await Promise.all(
this.bodyParams.messages.map(async (message: { msg: string }): Promise<{ username: string; msg: string; ts: number }> => {
const sendMessage = {
guest: visitor,
guest,
message: {
_id: Random.id(),
rid,
Expand All @@ -288,8 +292,8 @@ API.v1.addRoute(
},
},
};
// @ts-expect-error -- Typings on sendMessage are wrong
const sentMessage = await Livechat.sendMessage(sendMessage);

const sentMessage = await LivechatTyped.sendMessage(sendMessage);
return {
username: sentMessage.u.username,
msg: sentMessage.msg,
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/api/v1/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ API.v1.addRoute('livechat/visitor/:token', {
}

const { _id } = visitor;
const result = await Livechat.removeGuest(_id);
const result = await LivechatTyped.removeGuest(_id);
if (!result.modifiedCount) {
throw new Meteor.Error('error-removing-visitor', 'An error ocurred while deleting visitor');
}
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/livechat/server/lib/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export const forwardRoomToAgent = async (room: IOmnichannelRoom, transferData: T
return false;
}

await Livechat.saveTransferHistory(room, transferData);
await LivechatTyped.saveTransferHistory(room, transferData);

const { servedBy } = roomTaken;
if (servedBy) {
Expand Down Expand Up @@ -537,7 +537,7 @@ export const forwardRoomToDepartment = async (room: IOmnichannelRoom, guest: ILi
logger.debug(
`Routing algorithm doesn't support auto assignment (using ${RoutingManager.methodName}). Chat will be on department queue`,
);
await Livechat.saveTransferHistory(room, transferData);
await LivechatTyped.saveTransferHistory(room, transferData);
return RoutingManager.unassignAgent(inquiry, departmentId);
}

Expand Down Expand Up @@ -573,7 +573,7 @@ export const forwardRoomToDepartment = async (room: IOmnichannelRoom, guest: ILi
}
}

await Livechat.saveTransferHistory(room, transferData);
await LivechatTyped.saveTransferHistory(room, transferData);
if (oldServedBy) {
// if chat is queued then we don't ignore the new servedBy agent bcs at this
// point the chat is not assigned to him/her and it is still in the queue
Expand Down
Loading

0 comments on commit 74c8c07

Please sign in to comment.