Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into ref/…
Browse files Browse the repository at this point in the history
…omni
  • Loading branch information
ggazzo committed Aug 21, 2020
2 parents 3aca1b0 + 06467a6 commit ab78f68
Show file tree
Hide file tree
Showing 60 changed files with 9,222 additions and 6,594 deletions.
13 changes: 12 additions & 1 deletion .github/issue-close-app.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# Config for Close Issue app: https://probot.github.io/apps/close-issue/

# Comment that will be sent if an issue is judged to be closed
comment: "This issue was closed because it does not use any of our issue templates. Please make sure to use one of the suggested templates."
comment: |
This issue was closed because it does not use our bug report issue template.
Please make sure to use it and fill it as much as you can so we can provide better and faster support.
The following sections **must not** be removed, or else the BOT will close it immediately again:
* Steps to reproduce
* Expected behavior
* Actual behavior
* Server Setup Information
issueConfigs:
# There can be several configs for different kind of issues.
- content:
# Bug report
- "Steps to reproduce"
- "Expected behavior"
- "Actual behavior"
- "Server Setup Information"
- "Version of Rocket.Chat Server"
- content:
# Release issue
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ jobs:
MONGO_URL: mongodb://localhost:27017/rocketchat
MONGO_OPLOG_URL: mongodb://localhost:27017/local
run: |
for i in $(seq 1 5); do (docker exec mongo mongo rocketchat --eval 'db.dropDatabase()') && xvfb-run --auto-servernum npm run testci && s=0 && break || s=$? && sleep 1; done; (exit $s)
echo -e 'pcm.!default {\n type hw\n card 0\n}\n\nctl.!default {\n type hw\n card 0\n}' > ~/.asoundrc
Xvfb -screen 0 1024x768x24 :99 &
for i in $(seq 1 5); do (docker exec mongo mongo rocketchat --eval 'db.dropDatabase()') && npm run testci && s=0 && break || s=$? && sleep 1; done; (exit $s)
# notification:
# runs-on: ubuntu-latest
Expand Down
12 changes: 6 additions & 6 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ accounts-github@1.4.3
accounts-google@1.3.3
accounts-meteor-developer@1.4.2
accounts-oauth@1.2.0
accounts-password@1.6.0
accounts-password@1.6.1
accounts-twitter@1.4.2
aldeed:simple-schema@1.5.4
allow-deny@1.1.0
Expand All @@ -27,8 +27,8 @@ dandv:caret-position@2.1.1
ddp@1.4.0
ddp-client@2.3.3
ddp-common@1.4.0
ddp-rate-limiter@1.0.7
ddp-server@2.3.1
ddp-rate-limiter@1.0.8
ddp-server@2.3.2
deepwell:bootstrap-datepicker2@1.3.0
deps@1.0.12
diff-sequence@1.1.1
Expand Down Expand Up @@ -79,7 +79,7 @@ meteor-base@1.4.0
meteor-developer-oauth@1.2.1
meteorhacks:inject-initial@1.0.4
meteorspark:util@0.2.0
minifier-css@1.5.0
minifier-css@1.5.2
minifier-js@2.6.0
minimongo@1.6.0
mizzao:timesync@0.3.4
Expand All @@ -97,7 +97,7 @@ mystor:device-detection@0.2.0
nimble:restivus@0.8.12
nooitaf:colors@1.1.2_1
npm-bcrypt@0.9.3
npm-mongo@3.7.0
npm-mongo@3.7.1
oauth@1.3.0
oauth1@1.3.0
oauth2@1.3.0
Expand Down Expand Up @@ -130,7 +130,7 @@ session@1.2.0
sha@1.0.9
shell-server@0.5.0
simple:json-routes@2.1.0
socket-stream-client@0.3.0
socket-stream-client@0.3.1
spacebars@1.0.15
spacebars-compiler@1.1.3
srp@1.1.0
Expand Down
2 changes: 1 addition & 1 deletion app/authentication/server/startup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Accounts.onCreateUser(function(options, user = {}) {
callbacks.run('beforeCreateUser', options, user);

user.status = 'offline';
user.active = !settings.get('Accounts_ManuallyApproveNewUsers');
user.active = user.active !== undefined ? user.active : !settings.get('Accounts_ManuallyApproveNewUsers');

if (!user.name) {
if (options.profile) {
Expand Down
1 change: 0 additions & 1 deletion app/authorization/client/views/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { hasAllPermission } from '../hasPermission';
import { t } from '../../../utils/client';
import { SideNav } from '../../../ui-utils/client/lib/SideNav';
import { CONSTANTS, AuthorizationUtils } from '../../lib';

import { hasAtLeastOnePermission } from '..';

Template.permissions.helpers({
Expand Down
1 change: 1 addition & 0 deletions app/authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Meteor.startup(function() {
{ _id: 'assign-roles', roles: ['admin'] },
{ _id: 'ban-user', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'bulk-register-user', roles: ['admin'] },
{ _id: 'change-livechat-room-visitor', roles: ['admin', 'livechat-manager', 'livechat-agent'] },
{ _id: 'create-c', roles: ['admin', 'user', 'bot', 'app'] },
{ _id: 'create-d', roles: ['admin', 'user', 'bot', 'app'] },
{ _id: 'create-p', roles: ['admin', 'user', 'bot', 'app'] },
Expand Down
1 change: 0 additions & 1 deletion app/autotranslate/server/methods/getSupportedLanguages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';

import { hasPermission } from '../../../authorization';

import { TranslationProviderRegistry } from '..';

Meteor.methods({
Expand Down
1 change: 0 additions & 1 deletion app/autotranslate/server/methods/translateMessage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { Rooms } from '../../../models';

import { TranslationProviderRegistry } from '..';

Meteor.methods({
Expand Down
4 changes: 3 additions & 1 deletion app/e2e/client/rocketchat.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,10 @@ class E2E {
}

closeAlert() {
if (showingE2EAlert) {
alerts.close();
}
showingE2EAlert = false;
alerts.close();
}
}

Expand Down
1 change: 0 additions & 1 deletion app/importer/server/methods/downloadPublicImportFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Meteor } from 'meteor/meteor';
import { RocketChatImportFileInstance } from '../startup/store';
import { ProgressStep } from '../../lib/ImporterProgressStep';
import { hasPermission } from '../../../authorization';

import { Importers } from '..';

function downloadHttpFile(fileUrl, writeStream) {
Expand Down
1 change: 0 additions & 1 deletion app/importer/server/methods/getImportFileData.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { RocketChatImportFileInstance } from '../startup/store';
import { hasPermission } from '../../../authorization';
import { Imports } from '../../../models';
import { ProgressStep } from '../../lib/ImporterProgressStep';

import { Importers } from '..';

Meteor.methods({
Expand Down
1 change: 0 additions & 1 deletion app/importer/server/methods/getImportProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';

import { hasPermission } from '../../../authorization';
import { Imports } from '../../../models';

import { Importers } from '..';


Expand Down
1 change: 0 additions & 1 deletion app/importer/server/methods/startImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';

import { hasPermission } from '../../../authorization';
import { Imports } from '../../../models';

import {
Importers,
Selection,
Expand Down
1 change: 0 additions & 1 deletion app/importer/server/methods/uploadImportFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { RocketChatFile } from '../../../file';
import { RocketChatImportFileInstance } from '../startup/store';
import { hasPermission } from '../../../authorization';
import { ProgressStep } from '../../lib/ImporterProgressStep';

import { Importers } from '..';

Meteor.methods({
Expand Down
36 changes: 36 additions & 0 deletions app/livechat/server/api/v1/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { API } from '../../../../api/server';
import { findGuest, findRoom, getRoom, settings, findAgent, onCheckRoomParams } from '../lib/livechat';
import { Livechat } from '../../lib/Livechat';
import { normalizeTransferredByData } from '../../lib/Helper';
import { findVisitorInfo } from '../lib/visitors';

API.v1.addRoute('livechat/room', {
get() {
Expand Down Expand Up @@ -179,3 +180,38 @@ API.v1.addRoute('livechat/room.forward', { authRequired: true }, {
API.v1.success(Meteor.runAsUser(this.userId, () => Meteor.call('livechat:transfer', this.bodyParams)));
},
});

API.v1.addRoute('livechat/room.visitor', { authRequired: true }, {
put() {
try {
check(this.bodyParams, {
rid: String,
oldVisitorId: String,
newVisitorId: String,
});

const { rid, newVisitorId, oldVisitorId } = this.bodyParams;

const { visitor } = Promise.await(findVisitorInfo({ userId: this.userId, visitorId: newVisitorId }));
if (!visitor) {
throw new Meteor.Error('invalid-visitor');
}

let room = LivechatRooms.findOneById(rid, { _id: 1 });
if (!room) {
throw new Meteor.Error('invalid-room');
}

const { v: { _id: roomVisitorId } = {} } = room;
if (roomVisitorId !== oldVisitorId) {
throw new Meteor.Error('invalid-room-visitor');
}

room = Livechat.changeRoomVisitor(this.userId, rid, visitor);

return API.v1.success({ room });
} catch (e) {
return API.v1.failure(e);
}
},
});
9 changes: 7 additions & 2 deletions app/livechat/server/api/v1/videoCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ API.v1.addRoute('livechat/video.call/:token', {
Messages.createWithTypeRoomIdMessageAndUser('livechat_video_call', room._id, '', guest, {
actionLinks: config.theme.actionLinks,
});

let rname;
if (rcSettings.get('Jitsi_URL_Room_Hash')) {
rname = rcSettings.get('uniqueID') + rid;
} else {
rname = encodeURIComponent(room.t === 'd' ? room.usernames.join(' x ') : room.name);
}
const videoCall = {
rid,
domain: rcSettings.get('Jitsi_Domain'),
provider: 'jitsi',
room: rcSettings.get('Jitsi_URL_Room_Prefix') + rcSettings.get('uniqueID') + rid + rcSettings.get('Jitsi_URL_Room_Suffix'),
room: rcSettings.get('Jitsi_URL_Room_Prefix') + rname + rcSettings.get('Jitsi_URL_Room_Suffix'),
timeout: new Date(Date.now() + 3600 * 1000),
};

Expand Down
3 changes: 2 additions & 1 deletion app/livechat/server/lib/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export const userCanTakeInquiry = (user) => {
return (status !== 'offline' && statusLivechat === 'available') || roles.includes('bot');
};

export const updateDepartmentAgents = (departmentId, agents) => {
export const updateDepartmentAgents = (departmentId, agents, departmentEnabled) => {
check(departmentId, String);
check(agents, Match.ObjectIncluding({
upsert: Match.Maybe(Array),
Expand Down Expand Up @@ -389,6 +389,7 @@ export const updateDepartmentAgents = (departmentId, agents) => {
username: agent.username,
count: agent.count ? parseInt(agent.count) : 0,
order: agent.order ? parseInt(agent.order) : 0,
departmentEnabled,
});
agentsAdded.push(agent.agentId);
});
Expand Down
39 changes: 36 additions & 3 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
LivechatInquiry,
} from '../../../models';
import { Logger } from '../../../logger';
import { addUserRoles, hasPermission, hasRole, removeUserFromRoles } from '../../../authorization';
import { addUserRoles, hasPermission, hasRole, removeUserFromRoles, canAccessRoom } from '../../../authorization';
import * as Mailer from '../../../mailer';
import { sendMessage } from '../../../lib/server/functions/sendMessage';
import { updateMessage } from '../../../lib/server/functions/updateMessage';
Expand Down Expand Up @@ -839,7 +839,7 @@ export const Livechat = {
throw new Meteor.Error('error-department-not-found', 'Department not found', { method: 'livechat:saveDepartmentAgents' });
}

return updateDepartmentAgents(_id, departmentAgents);
return updateDepartmentAgents(_id, departmentAgents, department.enabled);
},

saveDepartment(_id, departmentData, departmentAgents) {
Expand Down Expand Up @@ -883,7 +883,7 @@ export const Livechat = {

const departmentDB = LivechatDepartment.createOrUpdateDepartment(_id, departmentData);
if (departmentDB && departmentAgents) {
updateDepartmentAgents(departmentDB._id, departmentAgents);
updateDepartmentAgents(departmentDB._id, departmentAgents, departmentDB.enabled);
}

return departmentDB;
Expand Down Expand Up @@ -1119,6 +1119,39 @@ export const Livechat = {

return Promise.await(businessHourManager.allowAgentChangeServiceStatus(agentId));
},

notifyRoomVisitorChange(roomId, visitor) {
Livechat.stream.emit(roomId, {
type: 'visitorData',
visitor,
});
},

changeRoomVisitor(userId, roomId, visitor) {
const user = Promise.await(Users.findOneById(userId));
if (!user) {
throw new Error('error-user-not-found');
}

if (!hasPermission(userId, 'change-livechat-room-visitor')) {
throw new Error('error-not-authorized');
}

const room = Promise.await(LivechatRooms.findOneById(roomId, { _id: 1, t: 1 }));
if (!room) {
throw new Meteor.Error('invalid-room');
}

if (!canAccessRoom(room, user)) {
throw new Error('error-not-allowed');
}

LivechatRooms.changeVisitorByRoomId(room._id, visitor);

Livechat.notifyRoomVisitorChange(room._id, visitor);

return LivechatRooms.findOneById(roomId);
},
};

Livechat.stream = new Meteor.Streamer('livechat-room');
Expand Down
37 changes: 31 additions & 6 deletions app/livechat/server/methods/changeLivechatStatus.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
import { Meteor } from 'meteor/meteor';

import { Livechat } from '../lib/Livechat';
import { hasPermission } from '../../../authorization';
import Users from '../../../models/server/models/Users';

Meteor.methods({
'livechat:changeLivechatStatus'() {
if (!Meteor.userId()) {
'livechat:changeLivechatStatus'({ status, agentId = Meteor.userId() } = {}) {
const uid = Meteor.userId();

if (!uid || !agentId) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:changeLivechatStatus' });
}

const user = Meteor.user();
const agent = Users.findOneAgentById(agentId, {
fields: {
status: 1,
statusLivechat: 1,
},
});

if (!agent) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:saveAgentInfo' });
}

const newStatus = status || (agent.statusLivechat === 'available' ? 'not-available' : 'available');

if (newStatus === agent.statusLivechat) {
return;
}

if (agentId !== uid) {
if (!hasPermission(uid, 'manage-livechat-agents')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:saveAgentInfo' });
}
return Livechat.setUserStatusLivechat(agentId, newStatus);
}

const newStatus = user.statusLivechat === 'available' ? 'not-available' : 'available';
if (!Livechat.allowAgentChangeServiceStatus(newStatus, user._id)) {
if (!Livechat.allowAgentChangeServiceStatus(newStatus, agentId)) {
throw new Meteor.Error('error-business-hours-are-closed', 'Not allowed', { method: 'livechat:changeLivechatStatus' });
}

return Livechat.setUserStatusLivechat(user._id, newStatus);
return Livechat.setUserStatusLivechat(agentId, newStatus);
},
});
8 changes: 7 additions & 1 deletion app/livechat/server/methods/startVideoCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ Meteor.methods({
],
});

let rname;
if (settings.get('Jitsi_URL_Room_Hash')) {
rname = settings.get('uniqueID') + roomId;
} else {
rname = encodeURIComponent(room.t === 'd' ? room.usernames.join(' x ') : room.name);
}
return {
roomId: room._id,
domain: settings.get('Jitsi_Domain'),
jitsiRoom: settings.get('Jitsi_URL_Room_Prefix') + settings.get('uniqueID') + roomId + settings.get('Jitsi_URL_Room_Suffix'),
jitsiRoom: settings.get('Jitsi_URL_Room_Prefix') + rname + settings.get('Jitsi_URL_Room_Suffix'),
};
},
});
Loading

0 comments on commit ab78f68

Please sign in to comment.