Skip to content

Commit

Permalink
Merge branch 'develop' into fix/e2ee_copy_link_Starred_and_Pinned
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo authored Jul 24, 2024
2 parents 13793dc + 03c8b06 commit abf5ca7
Show file tree
Hide file tree
Showing 74 changed files with 2,285 additions and 517 deletions.
6 changes: 6 additions & 0 deletions .changeset/cuddly-brooms-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/i18n": minor
---

Allows admins to customize the `Subject` field of Omnichannel email transcripts via setting. By passing a value to the setting `Custom email subject for transcript`, system will use it as the `Subject` field, unless a custom subject is passed when requesting a transcript. If there's no custom subject and setting value is empty, the current default value will be used
12 changes: 12 additions & 0 deletions .changeset/new-scissors-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@rocket.chat/omnichannel-services': minor
'@rocket.chat/pdf-worker': minor
'@rocket.chat/core-services': minor
'@rocket.chat/model-typings': minor
'@rocket.chat/i18n': minor
'@rocket.chat/meteor': minor
---

Added system messages support for Omnichannel PDF transcripts and email transcripts. Currently these transcripts don't render system messages and is shown as an empty message in PDF/email. This PR adds this support for all valid livechat system messages.

Also added a new setting under transcripts, to toggle the inclusion of system messages in email and PDF transcripts.
15 changes: 15 additions & 0 deletions .changeset/nice-laws-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'rocketchat-services': minor
'@rocket.chat/core-services': minor
'@rocket.chat/model-typings': minor
'@rocket.chat/ui-video-conf': minor
'@rocket.chat/core-typings': minor
'@rocket.chat/ui-contexts': minor
'@rocket.chat/models': minor
'@rocket.chat/ui-kit': minor
'@rocket.chat/i18n': minor
'@rocket.chat/meteor': minor
---

New Feature: Video Conference Persistent Chat.
This feature provides a discussion id for conference provider apps to store the chat messages exchanged during the conferences, so that those users may then access those messages again at any time through Rocket.Chat.
5 changes: 5 additions & 0 deletions .changeset/perfect-coins-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed an issue in the "Create discussion" form, that would have the "Create" action button disabled even though the form is prefilled when opening it from the message action
5 changes: 5 additions & 0 deletions .changeset/red-vans-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed issue that caused unintentional clicks when scrolling the channels sidebar on safari/chrome in iOS
5 changes: 5 additions & 0 deletions .changeset/smooth-lobsters-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix show correct user roles after updating user roles on admin edit user panel.
7 changes: 7 additions & 0 deletions .changeset/weak-pets-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@rocket.chat/omnichannel-services': patch
'@rocket.chat/core-services': patch
'@rocket.chat/meteor': patch
---

Reduced time on generation of PDF transcripts. Earlier Rocket.Chat was fetching the required translations everytime a PDF transcript was requested, this process was async and was being unnecessarily being performed on every pdf transcript request. This PR improves this and now the translations are loaded at the start and kept in memory to process further pdf transcripts requests. This reduces the time of asynchronously fetching translations again and again.
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 @@ -246,7 +246,8 @@ export class AppLivechatBridge extends LivechatBridge {
username,
name,
type,
};
userType: 'user',
} as const;

let userId;
let transferredTo;
Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/app/apps/server/bridges/videoConferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class AppVideoConferenceBridge extends VideoConferenceBridge {
if (data.status > oldData.status) {
await VideoConf.setStatus(call._id, data.status);
}

if (data.discussionRid !== oldData.discussionRid) {
await VideoConf.assignDiscussionToConference(call._id, data.discussionRid);
}
}

protected async registerProvider(info: IVideoConfProvider, appId: string): Promise<void> {
Expand Down
18 changes: 11 additions & 7 deletions apps/meteor/app/apps/server/converters/messages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isMessageFromVisitor } from '@rocket.chat/core-typings';
import { Messages, Rooms, Users } from '@rocket.chat/models';
import { Random } from '@rocket.chat/random';

Expand Down Expand Up @@ -107,16 +108,19 @@ export class AppMessagesConverter {
return undefined;
}

let user = await cache.get('user')(message.u._id);

// When the sender of the message is a Guest (livechat) and not a user
if (!user) {
user = this.orch.getConverters().get('users').convertToApp(message.u);
}
// When the message contains token, means the message is from the visitor(omnichannel)
const user = await (isMessageFromVisitor(msgObj)
? this.orch.getConverters().get('users').convertToApp(message.u)
: cache.get('user')(message.u._id));

delete message.u;

return user;
/**
* Old System Messages from visitor doesn't have the `token` field, to not return
* `sender` as undefined, so we need to add this fallback here.
*/

return user || this.orch.getConverters().get('users').convertToApp(message.u);
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IRoom } from '@rocket.chat/core-typings';
import { Messages, Rooms } from '@rocket.chat/models';
import { Messages, Rooms, VideoConference } from '@rocket.chat/models';

import { callbacks } from '../../../../lib/callbacks';
import { broadcastMessageFromData } from '../../../../server/modules/watchers/lib/messages';
Expand Down Expand Up @@ -108,6 +108,8 @@ callbacks.add(
},
},
);

await VideoConference.unsetDiscussionRid(drid);
return drid;
},
callbacks.priority.LOW,
Expand Down
18 changes: 12 additions & 6 deletions apps/meteor/app/lib/server/functions/addUserToRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ import { notifyOnRoomChangedById } from '../lib/notifyListener';

export const addUserToRoom = async function (
rid: string,
user: Pick<IUser, '_id' | 'username'> | string,
user: Pick<IUser, '_id'> | string,
inviter?: Pick<IUser, '_id' | 'username'>,
silenced?: boolean,
{
skipSystemMessage,
skipAlertSound,
}: {
skipSystemMessage?: boolean;
skipAlertSound?: boolean;
} = {},
): Promise<boolean | undefined> {
const now = new Date();
const room = await Rooms.findOneById(rid);
Expand All @@ -43,12 +49,12 @@ export const addUserToRoom = async function (
}

try {
await callbacks.run('federation.beforeAddUserToARoom', { user, inviter }, room);
await callbacks.run('federation.beforeAddUserToARoom', { user: userToBeAdded, inviter }, room);
} catch (error) {
throw new Meteor.Error((error as any)?.message);
}

await callbacks.run('beforeAddedToRoom', { user: userToBeAdded, inviter: userToBeAdded });
await callbacks.run('beforeAddedToRoom', { user: userToBeAdded, inviter });

// Check if user is already in room
const subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, userToBeAdded._id);
Expand Down Expand Up @@ -79,7 +85,7 @@ export const addUserToRoom = async function (
await Subscriptions.createWithRoomAndUser(room, userToBeAdded as IUser, {
ts: now,
open: true,
alert: true,
alert: !skipAlertSound,
unread: 1,
userMentions: 1,
groupMentions: 0,
Expand All @@ -93,7 +99,7 @@ export const addUserToRoom = async function (
throw new Meteor.Error('error-invalid-user', 'Cannot add an user to a room without a username');
}

if (!silenced) {
if (!skipSystemMessage) {
if (inviter) {
const extraData = {
ts: now,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export async function sendMessageNotifications(message: IMessage, room: IRoom, u
return;
}

const sender = await roomCoordinator.getRoomDirectives(room.t).getMsgSender(message.u._id);
const sender = await roomCoordinator.getRoomDirectives(room.t).getMsgSender(message);
if (!sender) {
return message;
}
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/livechat/server/api/v1/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ API.v1.addRoute(
throw new Error('error-invalid-visitor');
}

const transferedBy = this.user satisfies TransferByData;
transferData.transferredBy = normalizeTransferredByData(transferedBy, room);
transferData.transferredBy = normalizeTransferredByData(this.user, room);
if (transferData.userId) {
const userToTransfer = await Users.findOneById(transferData.userId);
if (userToTransfer) {
Expand Down
16 changes: 12 additions & 4 deletions apps/meteor/app/livechat/server/lib/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ export const createLivechatRoom = async <

await callbacks.run('livechat.newRoom', room);

await sendMessage(guest, { t: 'livechat-started', msg: '', groupable: false }, room);
// TODO: replace with `Message.saveSystemMessage`

await sendMessage(guest, { t: 'livechat-started', msg: '', groupable: false, token: guest.token }, room);

return result.value as IOmnichannelRoom;
};
Expand Down Expand Up @@ -646,6 +648,7 @@ export const forwardRoomToDepartment = async (room: IOmnichannelRoom, guest: ILi
'',
{ _id, username },
{
...(transferData.transferredBy.userType === 'visitor' && { token: room.v.token }),
transferData: {
...transferData,
prevDepartment: transferData.originalDepartmentName,
Expand Down Expand Up @@ -681,18 +684,23 @@ export const forwardRoomToDepartment = async (room: IOmnichannelRoom, guest: ILi
return true;
};

export const normalizeTransferredByData = (transferredBy: TransferByData, room: IOmnichannelRoom) => {
type MakePropertyOptional<T, K extends keyof T> = Omit<T, K> & { [P in K]?: T[P] };

export const normalizeTransferredByData = (
transferredBy: MakePropertyOptional<TransferByData, 'userType'>,
room: IOmnichannelRoom,
): TransferByData => {
if (!transferredBy || !room) {
throw new Error('You must provide "transferredBy" and "room" params to "getTransferredByData"');
}
const { servedBy: { _id: agentId } = {} } = room;
const { _id, username, name, userType: transferType } = transferredBy;
const type = transferType || (_id === agentId ? 'agent' : 'user');
const userType = transferType || (_id === agentId ? 'agent' : 'user');
return {
_id,
username,
...(name && { name }),
type,
userType,
};
};

Expand Down
Loading

0 comments on commit abf5ca7

Please sign in to comment.