Skip to content

Commit

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

* 'develop' of github.com:RocketChat/Rocket.Chat:
  feat: Implement proper accessbility for report user modal (#33294)
  chore: update E2EE setting text (#33226)
  fix: conference calls are shown as "not answered" after they end (#33179)
  fix: markdown inconsistency with bold and italics (#33157)
  feat: E2EE messages mentions (#32510)
  refactor: Reactions set/unset (#32994)
  ci: auto candidate releases (#33325)
  feat: `RoomSidepanel` (#33225)
  feat: contextualbar based on chat size (#33321)
  fix: error on sendmessage stub (#33317)
  fix: `LivechatSessionTaken` webhook event called without `agent` param (#33209)
  refactor: Remove old `setreaction` callbacks and use new after/before callbacks (#33309)
  fix: Mark as unread not working (#32939)
  fix: Local avatars prioritized over external avatar provider and remove remnant references on client of `Accounts_AvatarExternalProviderUrl` (#33296)
  feat: Allow managing association to business units on departments' creation and update (#32682)
  • Loading branch information
gabriellsh committed Sep 23, 2024
2 parents a9ab199 + 9bcb802 commit ac9694c
Show file tree
Hide file tree
Showing 90 changed files with 2,742 additions and 270 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-ladybugs-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed error during sendmessage client stub
7 changes: 7 additions & 0 deletions .changeset/dirty-stingrays-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/model-typings": minor
"@rocket.chat/rest-typings": minor
---

Added support for specifying a unit on departments' creation and update
5 changes: 5 additions & 0 deletions .changeset/five-coats-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/fuselage-ui-kit': patch
---

Fixed an error that incorrectly showed conference calls as not answered after they ended
5 changes: 5 additions & 0 deletions .changeset/hot-balloons-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed issue where when you marked a room as unread and you were part of it, sometimes it would mark it as read right after
5 changes: 5 additions & 0 deletions .changeset/kind-llamas-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Changed the contextualbar behavior based on chat size instead the viewport
6 changes: 6 additions & 0 deletions .changeset/late-hats-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/i18n": minor
---

Improves the accessibility of the report user modal by adding an appropriate label, description, and ARIA attributes.
7 changes: 7 additions & 0 deletions .changeset/late-planes-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/core-typings": patch
"@rocket.chat/i18n": patch
---

Added a new setting to enable mentions in end to end encrypted channels
5 changes: 5 additions & 0 deletions .changeset/spicy-rocks-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed `LivechatSessionTaken` webhook event being called without the `agent` param, which represents the agent serving the room.
9 changes: 9 additions & 0 deletions .changeset/strong-grapes-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@rocket.chat/meteor': patch
---

Fixed remaining direct references to external user avatar URLs

Fixed local avatars having priority over external provider

It mainly corrects the behavior of E2E encryption messages and desktop notifications.
5 changes: 5 additions & 0 deletions .changeset/sweet-nails-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed inconsistency between the markdown parser from the composer and the rest of the application when using bold and italics in a text.
10 changes: 10 additions & 0 deletions .changeset/witty-lemons-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@rocket.chat/core-services': minor
'@rocket.chat/model-typings': minor
'@rocket.chat/core-typings': minor
'@rocket.chat/rest-typings': minor
'@rocket.chat/ui-client': minor
'@rocket.chat/meteor': minor
---

Implemented new feature preview for Sidepanel
35 changes: 35 additions & 0 deletions .github/workflows/release-candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release candidate cut
on:
schedule:
- cron: '28 0 20 * *' # run at minute 28 to avoid the chance of delay due to high load on GH
jobs:
new-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
token: ${{ secrets.CI_PAT }}

- name: Setup NodeJS
uses: ./.github/actions/setup-node
with:
node-version: 14.21.3
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- uses: rharkor/[email protected]

- name: Build packages
run: yarn build

- name: 'Start release candidate'
uses: ./packages/release-action
with:
action: next
base-ref: ${{ github.ref_name }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CI_PAT }}
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ API.v1.addRoute(
throw new Meteor.Error('error-emoji-param-not-provided', 'The required "emoji" param is missing.');
}

await executeSetReaction(this.userId, emoji, msg._id, this.bodyParams.shouldReact);
await executeSetReaction(this.userId, emoji, msg, this.bodyParams.shouldReact);

return API.v1.success();
},
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ API.v1.addRoute(
const discussionParent =
room.prid &&
(await Rooms.findOneById<Pick<IRoom, 'name' | 'fname' | 't' | 'prid' | 'u'>>(room.prid, {
projection: { name: 1, fname: 1, t: 1, prid: 1, u: 1 },
projection: { name: 1, fname: 1, t: 1, prid: 1, u: 1, sidepanel: 1 },
}));
const { team, parentRoom } = await Team.getRoomInfo(room);
const parent = discussionParent || parentRoom;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/client/methods/sendMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Meteor.methods<ServerMethods>({

await onClientMessageReceived(message as IMessage).then((message) => {
ChatMessage.insert(message);
return callbacks.run('afterSaveMessage', message, room);
return callbacks.run('afterSaveMessage', message, { room });
});
},
});
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/methods/updateMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { hasPermissionAsync } from '../../../authorization/server/functions/hasP
import { settings } from '../../../settings/server';
import { updateMessage } from '../functions/updateMessage';

const allowedEditedFields = ['tshow', 'alias', 'attachments', 'avatar', 'emoji', 'msg', 'customFields', 'content'];
const allowedEditedFields = ['tshow', 'alias', 'attachments', 'avatar', 'emoji', 'msg', 'customFields', 'content', 'e2eMentions'];

export async function executeUpdateMessage(
uid: IUser['_id'],
Expand Down
15 changes: 12 additions & 3 deletions apps/meteor/app/livechat/imports/server/rest/departments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ API.v1.addRoute(
check(this.bodyParams, {
department: Object,
agents: Match.Maybe(Array),
departmentUnit: Match.Maybe({ _id: Match.Optional(String) }),
});

const agents = this.bodyParams.agents ? { upsert: this.bodyParams.agents } : {};
const department = await LivechatTs.saveDepartment(null, this.bodyParams.department as ILivechatDepartment, agents);
const { departmentUnit } = this.bodyParams;
const department = await LivechatTs.saveDepartment(
this.userId,
null,
this.bodyParams.department as ILivechatDepartment,
agents,
departmentUnit || {},
);

if (department) {
return API.v1.success({
Expand Down Expand Up @@ -112,17 +120,18 @@ API.v1.addRoute(
check(this.bodyParams, {
department: Object,
agents: Match.Maybe(Array),
departmentUnit: Match.Maybe({ _id: Match.Optional(String) }),
});

const { _id } = this.urlParams;
const { department, agents } = this.bodyParams;
const { department, agents, departmentUnit } = this.bodyParams;

if (!permissionToSave) {
throw new Error('error-not-allowed');
}

const agentParam = permissionToAddAgents && agents ? { upsert: agents } : {};
await LivechatTs.saveDepartment(_id, department, agentParam);
await LivechatTs.saveDepartment(this.userId, _id, department, agentParam, departmentUnit || {});

return API.v1.success({
department: await LivechatDepartment.findOneById(_id),
Expand Down
25 changes: 24 additions & 1 deletion apps/meteor/app/livechat/server/lib/LivechatTyped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1789,18 +1789,37 @@ class LivechatClass {
* @param {string|null} _id - The department id
* @param {Partial<import('@rocket.chat/core-typings').ILivechatDepartment>} departmentData
* @param {{upsert?: { agentId: string; count?: number; order?: number; }[], remove?: { agentId: string; count?: number; order?: number; }}} [departmentAgents] - The department agents
* @param {{_id?: string}} [departmentUnit] - The department's unit id
*/
async saveDepartment(
userId: string,
_id: string | null,
departmentData: LivechatDepartmentDTO,
departmentAgents?: {
upsert?: { agentId: string; count?: number; order?: number }[];
remove?: { agentId: string; count?: number; order?: number };
},
departmentUnit?: { _id?: string },
) {
check(_id, Match.Maybe(String));
if (departmentUnit?._id !== undefined && typeof departmentUnit._id !== 'string') {
throw new Meteor.Error('error-invalid-department-unit', 'Invalid department unit id provided', {
method: 'livechat:saveDepartment',
});
}

const department = _id ? await LivechatDepartment.findOneById(_id, { projection: { _id: 1, archived: 1, enabled: 1 } }) : null;
const department = _id
? await LivechatDepartment.findOneById(_id, { projection: { _id: 1, archived: 1, enabled: 1, parentId: 1 } })
: null;

if (departmentUnit && !departmentUnit._id && department && department.parentId) {
const isLastDepartmentInUnit = (await LivechatDepartment.countDepartmentsInUnit(department.parentId)) === 1;
if (isLastDepartmentInUnit) {
throw new Meteor.Error('error-unit-cant-be-empty', "The last department in a unit can't be removed", {
method: 'livechat:saveDepartment',
});
}
}

if (!department && !(await isDepartmentCreationAvailable())) {
throw new Meteor.Error('error-max-departments-number-reached', 'Maximum number of departments reached', {
Expand Down Expand Up @@ -1887,6 +1906,10 @@ class LivechatClass {
await callbacks.run('livechat.afterDepartmentDisabled', departmentDB);
}

if (departmentUnit) {
await callbacks.run('livechat.manageDepartmentUnit', { userId, departmentId: departmentDB._id, unitId: departmentUnit._id });
}

return departmentDB;
}
}
Expand Down
15 changes: 12 additions & 3 deletions apps/meteor/app/livechat/server/lib/RoutingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,20 @@ export const RoutingManager: Routing = {

logger.info(`Inquiry ${inquiry._id} taken by agent ${agent.agentId}`);

// assignAgent changes the room data to add the agent serving the conversation. afterTakeInquiry expects room object to be updated
const inq = await this.assignAgent(inquiry as InquiryWithAgentInfo, room, agent);
const roomAfterUpdate = await LivechatRooms.findOneById(rid);

if (!roomAfterUpdate) {
// This should never happen
throw new Error('error-room-not-found');
}

callbacks.runAsync(
'livechat.afterTakeInquiry',
{
inquiry: await this.assignAgent(inquiry as InquiryWithAgentInfo, room, agent),
room,
inquiry: inq,
room: roomAfterUpdate,
},
agent,
);
Expand All @@ -282,7 +291,7 @@ export const RoutingManager: Routing = {
queuedAt: undefined,
});

return LivechatRooms.findOneById(rid);
return roomAfterUpdate;
},

async transferRoom(room, guest, transferData) {
Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/app/livechat/server/methods/saveDepartment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ declare module '@rocket.chat/ddp-client' {
order?: number | undefined;
}[]
| undefined,
departmentUnit?: { _id?: string },
) => ILivechatDepartment;
}
}

Meteor.methods<ServerMethods>({
async 'livechat:saveDepartment'(_id, departmentData, departmentAgents) {
async 'livechat:saveDepartment'(_id, departmentData, departmentAgents, departmentUnit) {
const uid = Meteor.userId();
if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-departments'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:saveDepartment',
});
}

return Livechat.saveDepartment(_id, departmentData, { upsert: departmentAgents });
return Livechat.saveDepartment(uid, _id, departmentData, { upsert: departmentAgents }, departmentUnit);
},
});
20 changes: 15 additions & 5 deletions apps/meteor/app/mentions/server/Mentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Mentions is a named function that will process Mentions
* @param {Object} message - The message object
*/
import type { IMessage, IRoom, IUser } from '@rocket.chat/core-typings';
import { isE2EEMessage, type IMessage, type IRoom, type IUser } from '@rocket.chat/core-typings';

import { type MentionsParserArgs, MentionsParser } from '../lib/MentionsParser';

Expand Down Expand Up @@ -43,8 +43,13 @@ export class MentionsServer extends MentionsParser {
});
}

async getUsersByMentions({ msg, rid, u: sender }: Pick<IMessage, 'msg' | 'rid' | 'u'>): Promise<IMessage['mentions']> {
const mentions = this.getUserMentions(msg);
async getUsersByMentions(message: IMessage): Promise<IMessage['mentions']> {
const { msg, rid, u: sender, e2eMentions }: Pick<IMessage, 'msg' | 'rid' | 'u' | 't' | 'e2eMentions'> = message;

const mentions =
isE2EEMessage(message) && e2eMentions?.e2eUserMentions && e2eMentions?.e2eUserMentions.length > 0
? e2eMentions?.e2eUserMentions
: this.getUserMentions(msg);
const mentionsAll: { _id: string; username: string }[] = [];
const userMentions = [];

Expand All @@ -67,8 +72,13 @@ export class MentionsServer extends MentionsParser {
return [...mentionsAll, ...(userMentions.length ? await this.getUsers(userMentions) : [])];
}

async getChannelbyMentions({ msg }: Pick<IMessage, 'msg'>) {
const channels = this.getChannelMentions(msg);
async getChannelbyMentions(message: IMessage) {
const { msg, e2eMentions }: Pick<IMessage, 'msg' | 't' | 'e2eMentions'> = message;

const channels =
isE2EEMessage(message) && e2eMentions?.e2eChannelMentions && e2eMentions?.e2eChannelMentions.length > 0
? e2eMentions?.e2eChannelMentions
: this.getChannelMentions(msg);
return this.getChannels(channels.map((c) => c.trim().substr(1)));
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/message-mark-as-unread/client/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ Meteor.startup(() => {
const { message = messageArgs(this).msg } = props;

try {
await sdk.call('unreadMessages', message);
const subscription = ChatSubscription.findOne({
rid: message.rid,
});

if (subscription == null) {
return;
}
router.navigate('/home');
await LegacyRoomManager.close(subscription.t + subscription.name);
return router.navigate('/home');
await sdk.call('unreadMessages', message);
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
Expand Down
4 changes: 0 additions & 4 deletions apps/meteor/app/reactions/client/methods/setReaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Meteor } from 'meteor/meteor';

import { roomCoordinator } from '../../../../client/lib/rooms/roomCoordinator';
import { callbacks } from '../../../../lib/callbacks';
import { emoji } from '../../../emoji/client';
import { Messages, ChatRoom, Subscriptions } from '../../../models/client';

Expand Down Expand Up @@ -55,10 +54,8 @@ Meteor.methods<ServerMethods>({
if (!message.reactions || typeof message.reactions !== 'object' || Object.keys(message.reactions).length === 0) {
delete message.reactions;
Messages.update({ _id: messageId }, { $unset: { reactions: 1 } });
await callbacks.run('unsetReaction', messageId, reaction);
} else {
Messages.update({ _id: messageId }, { $set: { reactions: message.reactions } });
await callbacks.run('setReaction', messageId, reaction);
}
} else {
if (!message.reactions) {
Expand All @@ -72,7 +69,6 @@ Meteor.methods<ServerMethods>({
message.reactions[reaction].usernames.push(user.username);

Messages.update({ _id: messageId }, { $set: { reactions: message.reactions } });
await callbacks.run('setReaction', messageId, reaction);
}
},
});
Loading

0 comments on commit ac9694c

Please sign in to comment.