Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions apps/meteor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# @rocket.chat/meteor

## 7.7.2

### Patch Changes

- Bump @rocket.chat/meteor version.

- Bump @rocket.chat/meteor version.

- ([#36323](https://github.com/RocketChat/Rocket.Chat/pull/36323) by [@dionisio-bot](https://github.com/dionisio-bot)) Fixes an issue that was causing ddp-streamer process to break if the communication with presence service was interrupted for any reason.

- ([#36250](https://github.com/RocketChat/Rocket.Chat/pull/36250) by [@dionisio-bot](https://github.com/dionisio-bot)) fix: Security Hotfix (https://docs.rocket.chat/docs/security-fixes-and-updates)

- ([#36270](https://github.com/RocketChat/Rocket.Chat/pull/36270) by [@dionisio-bot](https://github.com/dionisio-bot)) Fixes an issue that caused the queue worker to stop processing if something failed when checking MAC limits or while fetching the list of queues

- ([#36298](https://github.com/RocketChat/Rocket.Chat/pull/36298) by [@dionisio-bot](https://github.com/dionisio-bot)) Fixes an issue that prevented the action of removing an agent when editing a department to work.

- <details><summary>Updated dependencies [8874a5aab72c962f213d128a54393d95f7dabef8]:</summary>

- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
</details>

## 7.7.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/lib/departmentsLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export async function saveDepartmentAgents(
departmentAgents: {
upsert?: (Pick<ILivechatDepartmentAgents, 'agentId' | 'username'> & {
count?: number;
sort?: number;
order?: number;
})[];
remove?: Pick<ILivechatDepartmentAgents, 'agentId' | 'username'>[];
},
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/utils/rocketchat.info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "7.7.1"
"version": "7.7.2"
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import type { IDepartmentAgent } from '../definitions';

export const formatAgentListPayload = (oldAgentList: IDepartmentAgent[], newAgentList: IDepartmentAgent[]) => {
const upsert: IDepartmentAgent[] = [];
const remove: IDepartmentAgent[] = [];
const upsert: Pick<IDepartmentAgent, 'agentId' | 'username' | 'count' | 'order'>[] = [];
const remove: Pick<IDepartmentAgent, 'agentId' | 'username'>[] = [];

for (const agent of newAgentList) {
const initialAgent = agent._id ? oldAgentList.find((initialAgent) => initialAgent._id === agent._id) : undefined;

if (!initialAgent || agent.count !== initialAgent.count || agent.order !== initialAgent.order) {
upsert.push(agent);
upsert.push({ agentId: agent.agentId, username: agent.username, count: agent.count, order: agent.order });
}
}

for (const initialAgent of oldAgentList) {
if (!newAgentList.some((agent) => initialAgent._id === agent._id)) {
remove.push(initialAgent);
remove.push({ agentId: initialAgent.agentId, username: initialAgent.username });
}
}

Expand Down
14 changes: 14 additions & 0 deletions apps/meteor/ee/server/services/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# rocketchat-services

## 2.0.17

### Patch Changes

- <details><summary>Updated dependencies [8874a5aab72c962f213d128a54393d95f7dabef8]:</summary>

- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
</details>

## 2.0.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rocketchat-services",
"private": true,
"version": "2.0.16",
"version": "2.0.17",
"description": "Rocket.Chat Authorization service",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rocket.chat/meteor",
"description": "The Ultimate Open Source WebChat Platform",
"version": "7.7.1",
"version": "7.7.2",
"private": true,
"type": "commonjs",
"author": {
Expand Down
14 changes: 9 additions & 5 deletions apps/meteor/server/publications/room/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ Meteor.methods<ServerMethods>({
}

const userId = Meteor.userId();

if (!userId && settings.get('Accounts_AllowAnonymousRead') === false) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'getRoomByTypeAndName',
});
const isAnonymous = !userId;

if (isAnonymous) {
const allowAnon = settings.get('Accounts_AllowAnonymousRead');
if (!allowAnon || type !== 'c') {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'getRoomByTypeAndName',
});
}
}

const roomFind = roomCoordinator.getRoomFind(type);
Expand Down
63 changes: 39 additions & 24 deletions apps/meteor/server/services/omnichannel/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class OmnichannelQueue implements IOmnichannelQueue {

private running = false;

private errorDelay = 10 * 1000; // 10 seconds

private delay() {
const timeout = settings.get<number>('Omnichannel_queue_delay_timeout') ?? 5;
return timeout < 1 ? DEFAULT_RACE_TIMEOUT : timeout * 1000;
Expand Down Expand Up @@ -79,28 +81,38 @@ export class OmnichannelQueue implements IOmnichannelQueue {
}

private async execute() {
if (!this.running) {
queueLogger.debug('Queue stopped. Cannot execute');
return;
}
try {
if (!this.running) {
queueLogger.debug('Queue stopped. Cannot execute');
return;
}

if (await License.shouldPreventAction('monthlyActiveContacts', 1)) {
queueLogger.debug('MAC limit reached. Queue wont execute');
this.running = false;
return;
}
if (await License.shouldPreventAction('monthlyActiveContacts', 1)) {
queueLogger.debug('MAC limit reached. Queue wont execute');
this.running = false;
return;
}

// We still go 1 by 1, but we go with every queue every cycle instead of just 1 queue per cycle
// And we get tracing :)
const queues = await this.getActiveQueues();
for await (const queue of queues) {
await tracerSpan(
'omnichannel.queue',
{ attributes: { workerTime: new Date().toISOString(), queue: queue || 'Public' }, root: true },
() => this.checkQueue(queue),
);
}

// We still go 1 by 1, but we go with every queue every cycle instead of just 1 queue per cycle
// And we get tracing :)
const queues = await this.getActiveQueues();
for await (const queue of queues) {
await tracerSpan(
'omnichannel.queue',
{ attributes: { workerTime: new Date().toISOString(), queue: queue || 'Public' }, root: true },
() => this.checkQueue(queue),
);
this.scheduleExecution();
} catch (e) {
queueLogger.error({
msg: 'Queue Worker Error. Rescheduling with extra delay',
extraDelay: this.errorDelay,
err: e,
});
this.scheduleExecution(this.errorDelay);
}
this.scheduleExecution();
}

private async checkQueue(queue: string | null) {
Expand Down Expand Up @@ -136,15 +148,18 @@ export class OmnichannelQueue implements IOmnichannelQueue {
}
}

private scheduleExecution(): void {
private scheduleExecution(extraDelay?: number): void {
if (this.timeoutHandler !== null) {
return;
}

this.timeoutHandler = setTimeout(() => {
this.timeoutHandler = null;
return this.execute();
}, this.delay());
this.timeoutHandler = setTimeout(
() => {
this.timeoutHandler = null;
return this.execute();
},
this.delay() + (extraDelay || 0),
);
}

async shouldStart() {
Expand Down
24 changes: 24 additions & 0 deletions apps/meteor/tests/end-to-end/api/livechat/10-departments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,30 @@ import { IS_EE } from '../../../e2e/config/constants';
.send({ upsert: [{ agentId: agent._id, username: agent.username, name: agent.name }], remove: [] })
.expect(200);
expect(res.body).to.have.property('success', true);
});
it('should successfully remove an agent from a department', async () => {
const [dep, agent] = await Promise.all([createDepartment(), createAgent()]);
const res = await request
.post(api(`livechat/department/${dep._id}/agents`))
.set(credentials)
// UI sends the whole agent object, but API only needs agentId and username
.send({
remove: [
{
agentId: agent._id,
username: agent.username,
name: agent.name,
count: 0,
order: 0,
departmentId: 'afdsfads',
_id: 'afsdfadsfaf',
_updatedAt: new Date(),
},
],
upsert: [],
})
.expect(200);
expect(res.body).to.have.property('success', true);
await deleteDepartment(dep._id);
});
});
Expand Down
44 changes: 40 additions & 4 deletions apps/meteor/tests/end-to-end/api/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,7 @@ describe('Meteor.methods', () => {
let testUserCredentials: Credentials;
let dmId: IRoom['_id'];
let room: IRoom;
let privateRoom: IRoom;

before(async () => {
testUser = await createUser();
Expand Down Expand Up @@ -2613,14 +2614,49 @@ describe('Meteor.methods', () => {
});
});

after(() =>
Promise.all([
before(async () => {
privateRoom = (
await createRoom({
type: 'p',
name: `private.test.${Date.now()}-${Math.random()}`,
})
).body.group;
});

after(async () => {
await Promise.all([
deleteRoom({ type: 'd', roomId: dmId }),
deleteRoom({ type: 'c', roomId: room._id }),
deleteRoom({ type: 'p', roomId: privateRoom._id }),
deleteUser(testUser),
deleteUser(testUser2),
]),
);
updateSetting('Accounts_AllowAnonymousRead', false),
]);
});

it('should throw error when anonymous user tries to read private channel with anonymous read enabled', async () => {
await updateSetting('Accounts_AllowAnonymousRead', true);

const payload = {
message: JSON.stringify({
msg: 'method',
id: '2',
method: 'getRoomByTypeAndName',
params: ['p', privateRoom.name],
}),
};

const res = await request.post('/api/v1/method.callAnon/getRoomByTypeAndName').set('Content-Type', 'application/json').send(payload);

expect(res.body).to.have.property('message');
const parsedMessage = JSON.parse(res.body.message);

expect(parsedMessage).to.have.property('error');
expect(parsedMessage.error).to.have.property('error');
expect(parsedMessage.error.error).to.equal('error-invalid-user');

await updateSetting('Accounts_AllowAnonymousRead', false);
});

it("should throw an error if the user isn't logged in", (done) => {
void request
Expand Down
12 changes: 12 additions & 0 deletions apps/uikit-playground/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @rocket.chat/uikit-playground

## 0.6.17

### Patch Changes

- <details><summary>Updated dependencies []:</summary>

- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
</details>

## 0.6.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/uikit-playground/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rocket.chat/uikit-playground",
"private": true,
"version": "0.6.16",
"version": "0.6.17",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
14 changes: 14 additions & 0 deletions ee/apps/account-service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @rocket.chat/account-service

## 0.4.26

### Patch Changes

- <details><summary>Updated dependencies [8874a5aab72c962f213d128a54393d95f7dabef8]:</summary>

- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
</details>

## 0.4.25

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/account-service/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rocket.chat/account-service",
"private": true,
"version": "0.4.25",
"version": "0.4.26",
"description": "Rocket.Chat Account service",
"scripts": {
"build": "tsc -p tsconfig.json",
Expand Down
Loading
Loading