Skip to content

Commit

Permalink
Merge branch 'master' into develop_pwa-catchup-accdbc6
Browse files Browse the repository at this point in the history
  • Loading branch information
Shailesh351 committed Oct 19, 2021
2 parents f2bf9e2 + 6e49fc9 commit 1f98dd8
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM registry.access.redhat.com/ubi8/nodejs-12

ENV RC_VERSION 4.0.2
ENV RC_VERSION 4.0.3

MAINTAINER buildmaster@rocket.chat

Expand Down
34 changes: 34 additions & 0 deletions .github/history.json
Original file line number Diff line number Diff line change
Expand Up @@ -66186,6 +66186,40 @@
]
}
]
},
"4.0.3": {
"node_version": "12.22.1",
"npm_version": "6.14.1",
"apps_engine_version": "1.28.0",
"mongo_versions": [
"3.6",
"4.0",
"4.2",
"4.4",
"5.0"
],
"pull_requests": [
{
"pr": "23418",
"title": "[FIX][APPS] Communication problem when updating and uninstalling apps in cluster",
"userLogin": "thassiov",
"description": "- Make the hook responsible for receiving app update events inside a cluster fetch the app's package (zip file) in the correct place.\r\n- Also shows a warning message on uninstalls inside a cluster. As there are many servers writing to the same place, some race conditions may occur. This prevents problems related to terminating the process in the middle due to errors being thrown and leaving the server in a faulty state.",
"milestone": "4.0.3",
"contributors": [
"thassiov"
]
},
{
"pr": "23473",
"title": "[FIX] Server crashing when Routing method is not available at start",
"userLogin": "KevLehman",
"milestone": "4.0.3",
"contributors": [
"KevLehman",
"web-flow"
]
}
]
}
}
}
2 changes: 1 addition & 1 deletion .snapcraft/resources/prepareRocketChat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

curl -SLf "https://releases.rocket.chat/4.0.2/download/" -o rocket.chat.tgz
curl -SLf "https://releases.rocket.chat/4.0.3/download/" -o rocket.chat.tgz

tar xf rocket.chat.tgz --strip 1

Expand Down
2 changes: 1 addition & 1 deletion .snapcraft/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 5. `snapcraft snap`

name: rocketchat-server
version: 4.0.2
version: 4.0.3
summary: Rocket.Chat server
description: Have your own Slack like online chat, built with Meteor. https://rocket.chat/
confinement: strict
Expand Down
24 changes: 24 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@

# 4.0.3
`2021-10-18 · 2 🐛 · 2 👩‍💻👨‍💻`

### Engine versions
- Node: `12.22.1`
- NPM: `6.14.1`
- MongoDB: `3.6, 4.0, 4.2, 4.4, 5.0`
- Apps-Engine: `1.28.0`

### 🐛 Bug fixes


- **APPS:** Communication problem when updating and uninstalling apps in cluster ([#23418](https://github.com/RocketChat/Rocket.Chat/pull/23418))

- Make the hook responsible for receiving app update events inside a cluster fetch the app's package (zip file) in the correct place.
- Also shows a warning message on uninstalls inside a cluster. As there are many servers writing to the same place, some race conditions may occur. This prevents problems related to terminating the process in the middle due to errors being thrown and leaving the server in a faulty state.

- Server crashing when Routing method is not available at start ([#23473](https://github.com/RocketChat/Rocket.Chat/pull/23473))

### 👩‍💻👨‍💻 Core Team 🤓

- [@KevLehman](https://github.com/KevLehman)
- [@thassiov](https://github.com/thassiov)

# 4.0.2
`2021-10-14 · 4 🐛 · 2 👩‍💻👨‍💻`

Expand Down
4 changes: 3 additions & 1 deletion app/apps/server/communication/websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export class AppServerListener {

const storageItem = await this.orch.getStorage().retrieveOne(appId);

await this.orch.getManager().update(Buffer.from(storageItem.zip, 'base64'));
const appPackage = await this.orch.getAppSourceStorage().fetch(storageItem);

await this.orch.getManager().update(appPackage);
this.clientStreamer.emitWithoutBroadcast(AppEvents.APP_UPDATED, appId);
}

Expand Down
5 changes: 5 additions & 0 deletions app/apps/server/storage/AppGridFSSourceStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export class AppGridFSSourceStorage extends AppSourceStorage {
return new Promise((resolve, reject) => {
this.bucket.delete(this.itemToObjectId(item), (error) => {
if (error) {
if (error.message.includes('FileNotFound: no file with id')) {
console.warn(`This instance could not remove the ${ item.info.name } app package. If you are running Rocket.Chat in a cluster with multiple instances, possibly other instance removed the package. If this is not the case, it is possible that the file in the database got renamed or removed manually.`);
return resolve();
}

return reject(error);
}

Expand Down
2 changes: 1 addition & 1 deletion app/livechat/server/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import './livechat';
import './config';
import './startup';
import './visitorStatus';
import './agentStatus';
import '../lib/messageTypes';
import './config';
import './roomType';
import './hooks/beforeCloseRoom';
import './hooks/beforeDelegateAgent';
Expand Down
26 changes: 18 additions & 8 deletions app/livechat/server/lib/RoutingManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';

import { settings } from '../../../settings/server';
import {
createLivechatSubscription,
dispatchAgentDelegated,
Expand All @@ -13,7 +12,7 @@ import {
allowAgentSkipQueue,
} from './Helper';
import { callbacks } from '../../../callbacks/server';
import { Logger } from '../../../logger';
import { Logger } from '../../../../server/lib/logger/Logger';
import { LivechatRooms, Rooms, Messages, Users, LivechatInquiry, Subscriptions } from '../../../models/server';
import { Apps, AppEvents } from '../../../apps/server';

Expand All @@ -23,9 +22,24 @@ export const RoutingManager = {
methodName: null,
methods: {},

setMethodName(name) {
startQueue() {
// queue shouldn't start on CE
},

isMethodSet() {
return !!this.methodName;
},

setMethodNameAndStartQueue(name) {
logger.debug(`Changing default routing method from ${ this.methodName } to ${ name }`);
this.methodName = name;
if (!this.methods[name]) {
logger.warn(`Cannot change routing method to ${ name }. Selected Routing method does not exists. Defaulting to Manual_Selection`);
this.methodName = 'Manual_Selection';
} else {
this.methodName = name;
}

this.startQueue();
},

registerMethod(name, Method) {
Expand Down Expand Up @@ -217,7 +231,3 @@ export const RoutingManager = {
});
},
};

settings.get('Livechat_Routing_Method', function(key, value) {
RoutingManager.setMethodName(value);
});
5 changes: 5 additions & 0 deletions app/livechat/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { businessHourManager } from './business-hour';
import { createDefaultBusinessHourIfNotExists } from './business-hour/Helper';
import { hasPermission } from '../../authorization/server';
import { Livechat } from './lib/Livechat';
import { RoutingManager } from './lib/RoutingManager';

import './roomAccessValidator.internalService';

Expand Down Expand Up @@ -57,5 +58,9 @@ Meteor.startup(async () => {
return businessHourManager.stopManager();
});

settings.get('Livechat_Routing_Method', function(key, value) {
RoutingManager.setMethodNameAndStartQueue(value);
});

Accounts.onLogout(({ user }) => user?.roles?.includes('livechat-agent') && !user?.roles?.includes('bot') && Livechat.setUserStatusLivechat(user._id, 'not-available'));
});
2 changes: 1 addition & 1 deletion app/utils/rocketchat.info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "4.0.2"
"version": "4.0.3"
}
16 changes: 12 additions & 4 deletions ee/app/livechat-enterprise/server/lib/LivechatEnterprise.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,27 @@ const queueWorker = {
},
};

let omnichannelIsEnabled = false;

function shouldQueueStart() {
if (!omnichannelIsEnabled) {
queueWorker.stop();
return;
}

const routingSupportsAutoAssign = RoutingManager.getConfig().autoAssignAgent;
queueLogger.debug(`Routing method ${ RoutingManager.methodName } supports auto assignment: ${ routingSupportsAutoAssign }. ${
routingSupportsAutoAssign
? 'Starting'
: 'Stopping'
} queue`);

routingSupportsAutoAssign && settings.get('Livechat_enabled') ? queueWorker.start() : queueWorker.stop();
routingSupportsAutoAssign ? queueWorker.start() : queueWorker.stop();
}

RoutingManager.startQueue = shouldQueueStart;

settings.get('Livechat_enabled', (_, value) => {
value && settings.get('Livechat_Routing_Method') ? shouldQueueStart() : queueWorker.stop();
omnichannelIsEnabled = value;
omnichannelIsEnabled && RoutingManager.isMethodSet() ? shouldQueueStart() : queueWorker.stop();
});

settings.onload('Livechat_Routing_Method', shouldQueueStart);
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Rocket.Chat",
"description": "The Ultimate Open Source WebChat Platform",
"version": "4.0.2",
"version": "4.0.3",
"author": {
"name": "Rocket.Chat",
"url": "https://rocket.chat/"
Expand Down
2 changes: 1 addition & 1 deletion server/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import '../ee/server/broker';
import './lib/logger/startup';
import './importPackages';
import '../imports/startup/server';

import './services/startup';

import '../ee/server';
import './lib/logger/startup';
import './lib/pushConfig';
import './startup/migrations';
import './startup/appcache';
Expand Down

0 comments on commit 1f98dd8

Please sign in to comment.