Skip to content

Commit

Permalink
Merge branch 'develop' into fix/forceCodeLang
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jun 13, 2024
2 parents a0780e6 + afa560d commit 0653d51
Show file tree
Hide file tree
Showing 202 changed files with 2,597 additions and 929 deletions.
6 changes: 6 additions & 0 deletions .changeset/clean-moose-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/i18n": minor
---

Introduced the use of the `API_User_Limit` setting to limit amount of members to simultaneously auto-join a room in a team
5 changes: 5 additions & 0 deletions .changeset/eighty-wasps-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed an issue with how the UI checked for permissions when deciding if editing or deleting a message by moderators users
6 changes: 6 additions & 0 deletions .changeset/famous-scissors-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/i18n": patch
---

Prevent usage of OTR messages with End-to-end Encryption, both feature shouldn't and can't work together.
5 changes: 5 additions & 0 deletions .changeset/five-shoes-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed codeBlock styles in light mode
5 changes: 5 additions & 0 deletions .changeset/forty-ghosts-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed "Take it" button behavior disabling it when agent status is set to offline
5 changes: 5 additions & 0 deletions .changeset/fuzzy-readers-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes issues with loading license modules when loading the page while logged out
6 changes: 6 additions & 0 deletions .changeset/late-drinks-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": minor
---

Fixed an issue that would not allow the user to dismiss the closeToSeatsLimit banner for old workspaces

5 changes: 5 additions & 0 deletions .changeset/short-coins-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed an issue where apps installed via the Marketplace would not be shown in the installed list if the app is unpublished
5 changes: 5 additions & 0 deletions .changeset/thin-suns-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes issues causing nonstop sound notification when taking a chat from the `Current Chats` view
5 changes: 5 additions & 0 deletions .changeset/tidy-apes-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed inverted navigation direction in the image gallery
5 changes: 5 additions & 0 deletions .changeset/wild-carrots-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Remove password change reason when the `request password change` option is set to false
2 changes: 1 addition & 1 deletion apps/meteor/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@2.15
METEOR@2.16
26 changes: 13 additions & 13 deletions apps/meteor/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[email protected].10
[email protected].11
[email protected]
[email protected]
[email protected]
[email protected]
[email protected].3
[email protected].4
[email protected]
[email protected]
[email protected]
Expand All @@ -15,14 +15,14 @@ [email protected]
[email protected]
[email protected]
[email protected]
check@1.3.2
check@1.4.1
[email protected]
[email protected]
[email protected]
[email protected].1
[email protected].0
[email protected].2
[email protected].1
[email protected]
[email protected].0
[email protected].1
[email protected]
dispatch:[email protected]
[email protected]
Expand All @@ -31,7 +31,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
[email protected].5
[email protected].6
[email protected]
[email protected]
[email protected]
Expand All @@ -45,17 +45,17 @@ [email protected]
[email protected]
kadira:[email protected]
[email protected]
[email protected].3
[email protected].4
[email protected]
[email protected]
[email protected]
meteorhacks:[email protected]
[email protected]
[email protected].3
[email protected].4
[email protected]
[email protected]
[email protected]
[email protected].8
[email protected].10
[email protected]
[email protected]
[email protected]
Expand Down Expand Up @@ -84,7 +84,7 @@ rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
[email protected]
[email protected].3
[email protected].4
[email protected]
[email protected]
[email protected]
Expand All @@ -93,10 +93,10 @@ [email protected]
[email protected]
[email protected]
[email protected]
[email protected].0
[email protected].1
[email protected]
[email protected]
[email protected]
zodern:[email protected]
zodern:[email protected]
zodern:[email protected].11
zodern:[email protected].13
3 changes: 1 addition & 2 deletions apps/meteor/app/api/server/v1/banners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ import { API } from '../api';
*/
API.v1.addRoute(
'banners.getNew',
{ authRequired: true },
{ authRequired: true, deprecation: { version: '8.0.0', alternatives: ['banners/:id', 'banners'] } },
{
// deprecated
async get() {
check(
this.queryParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const canDeleteMessageAsync = async (
if (!allowed) {
return false;
}
const bypassBlockTimeLimit = await hasPermissionAsync(uid, 'bypass-time-limit-edit-and-delete');
const bypassBlockTimeLimit = await hasPermissionAsync(uid, 'bypass-time-limit-edit-and-delete', rid);

if (!bypassBlockTimeLimit) {
const blockDeleteInMinutes = await getValue('Message_AllowDeleting_BlockDeleteInMinutes');
Expand Down
21 changes: 18 additions & 3 deletions apps/meteor/app/lib/server/functions/deleteUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { callbacks } from '../../../../lib/callbacks';
import { i18n } from '../../../../server/lib/i18n';
import { FileUpload } from '../../../file-upload/server';
import { settings } from '../../../settings/server';
import { notifyOnRoomChangedById, notifyOnIntegrationChangedByUserId } from '../lib/notifyListener';
import { notifyOnRoomChangedById, notifyOnIntegrationChangedByUserId, notifyOnLivechatDepartmentAgentChanged } from '../lib/notifyListener';
import { getSubscribedRoomsForUserWithDetails, shouldRemoveOrChangeOwner } from './getRoomsWithSingleOwner';
import { getUserSingleOwnedRooms } from './getUserSingleOwnedRooms';
import { relinquishRoomOwnerships } from './relinquishRoomOwnerships';
Expand Down Expand Up @@ -95,9 +95,24 @@ export async function deleteUser(userId: string, confirmRelinquish = false, dele

await Subscriptions.removeByUserId(userId); // Remove user subscriptions

// Remove user as livechat agent
if (user.roles.includes('livechat-agent')) {
// Remove user as livechat agent
await LivechatDepartmentAgents.removeByAgentId(userId);
const departmentAgents = await LivechatDepartmentAgents.findByAgentId(userId).toArray();

const { deletedCount } = await LivechatDepartmentAgents.removeByAgentId(userId);

if (deletedCount > 0) {
departmentAgents.forEach((depAgent) => {
void notifyOnLivechatDepartmentAgentChanged(
{
_id: depAgent._id,
agentId: userId,
departmentId: depAgent.departmentId,
},
'removed',
);
});
}
}

if (user.roles.includes('livechat-monitor')) {
Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/app/lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ export const saveUser = async function (userId, userData) {

const updateUser = {
$set: {},
$unset: {},
};

handleBio(updateUser, userData.bio);
Expand All @@ -419,6 +420,9 @@ export const saveUser = async function (userId, userData) {

if (typeof userData.requirePasswordChange !== 'undefined') {
updateUser.$set.requirePasswordChange = userData.requirePasswordChange;
if (!userData.requirePasswordChange) {
updateUser.$unset.requirePasswordChangeReason = 1;
}
}

if (typeof userData.verified === 'boolean') {
Expand Down
46 changes: 46 additions & 0 deletions apps/meteor/app/lib/server/lib/notifyListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
IPbxEvent,
LoginServiceConfiguration as LoginServiceConfigurationData,
ILivechatPriority,
ILivechatDepartmentAgents,
IEmailInbox,
IIntegrationHistory,
AtLeast,
Expand All @@ -23,6 +24,7 @@ import {
Integrations,
LoginServiceConfiguration,
IntegrationHistory,
LivechatDepartmentAgents,
} from '@rocket.chat/models';

type ClientAction = 'inserted' | 'updated' | 'removed';
Expand Down Expand Up @@ -307,3 +309,47 @@ export async function notifyOnIntegrationHistoryChangedById<T extends IIntegrati

void api.broadcast('watch.integrationHistory', { clientAction, id: item._id, data: item, diff });
}

export async function notifyOnLivechatDepartmentAgentChanged<T extends ILivechatDepartmentAgents>(
data: Partial<T> & Pick<T, '_id' | 'agentId' | 'departmentId'>,
clientAction: ClientAction = 'updated',
): Promise<void> {
if (!dbWatchersDisabled) {
return;
}

void api.broadcast('watch.livechatDepartmentAgents', { clientAction, id: data._id, data });
}

export async function notifyOnLivechatDepartmentAgentChangedByDepartmentId<T extends ILivechatDepartmentAgents>(
departmentId: T['departmentId'],
clientAction: 'inserted' | 'updated' = 'updated',
): Promise<void> {
if (!dbWatchersDisabled) {
return;
}

const items = LivechatDepartmentAgents.findByDepartmentId(departmentId, { projection: { _id: 1, agentId: 1, departmentId: 1 } });

for await (const item of items) {
void api.broadcast('watch.livechatDepartmentAgents', { clientAction, id: item._id, data: item });
}
}

export async function notifyOnLivechatDepartmentAgentChangedByAgentsAndDepartmentId<T extends ILivechatDepartmentAgents>(
agentsIds: T['agentId'][],
departmentId: T['departmentId'],
clientAction: 'inserted' | 'updated' = 'updated',
): Promise<void> {
if (!dbWatchersDisabled) {
return;
}

const items = LivechatDepartmentAgents.findByAgentsAndDepartmentId(agentsIds, departmentId, {
projection: { _id: 1, agentId: 1, departmentId: 1 },
});

for await (const item of items) {
void api.broadcast('watch.livechatDepartmentAgents', { clientAction, id: item._id, data: item });
}
}
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 @@ -53,7 +53,7 @@ export async function executeUpdateMessage(uid: IUser['_id'], message: AtLeast<I
}

const blockEditInMinutes = settings.get('Message_AllowEditing_BlockEditInMinutes');
const bypassBlockTimeLimit = await hasPermissionAsync(uid, 'bypass-time-limit-edit-and-delete');
const bypassBlockTimeLimit = await hasPermissionAsync(uid, 'bypass-time-limit-edit-and-delete', message.rid);

if (!bypassBlockTimeLimit && Match.test(blockEditInMinutes, Number) && blockEditInMinutes !== 0) {
let currentTsDiff = 0;
Expand Down
21 changes: 18 additions & 3 deletions apps/meteor/app/livechat/server/hooks/afterAgentRemoved.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import { LivechatDepartment, Users, LivechatDepartmentAgents, LivechatVisitors } from '@rocket.chat/models';

import { callbacks } from '../../../../lib/callbacks';
import { notifyOnLivechatDepartmentAgentChanged } from '../../../lib/server/lib/notifyListener';

callbacks.add('livechat.afterAgentRemoved', async ({ agent }) => {
const departmentIds = (await LivechatDepartmentAgents.findByAgentId(agent._id).toArray()).map((department) => department.departmentId);
await Promise.all([
const departments = await LivechatDepartmentAgents.findByAgentId(agent._id).toArray();

const [, { deletedCount }] = await Promise.all([
Users.removeAgent(agent._id),
LivechatDepartmentAgents.removeByAgentId(agent._id),
agent.username && LivechatVisitors.removeContactManagerByUsername(agent.username),
departmentIds.length && LivechatDepartment.decreaseNumberOfAgentsByIds(departmentIds),
departments.length && LivechatDepartment.decreaseNumberOfAgentsByIds(departments.map(({ departmentId }) => departmentId)),
]);

if (deletedCount > 0) {
departments.forEach((depAgent) => {
void notifyOnLivechatDepartmentAgentChanged(
{
_id: depAgent._id,
agentId: agent._id,
departmentId: depAgent.departmentId,
},
'removed',
);
});
}
});
Loading

0 comments on commit 0653d51

Please sign in to comment.