-
{{_ "Backup_codes"}}
-
-
{{codesRemaining}}
-
-
+
+
{{_ "Backup_codes"}}
+
+
{{codesRemaining}}
+
-
+
{{/if}}
{{/if}}
diff --git a/packages/rocketchat-api/server/api.js b/packages/rocketchat-api/server/api.js
index 98719acbfecd..d28a95d95f49 100644
--- a/packages/rocketchat-api/server/api.js
+++ b/packages/rocketchat-api/server/api.js
@@ -386,7 +386,7 @@ const defaultOptionsEndpoint = function _defaultOptionsEndpoint() {
if (RocketChat.settings.get('API_Enable_CORS') === true) {
this.response.writeHead(200, {
'Access-Control-Allow-Origin': RocketChat.settings.get('API_CORS_Origin'),
- 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, X-User-Id, X-Auth-Token',
+ 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, X-User-Id, X-Auth-Token, x-visitor-token',
});
} else {
this.response.writeHead(405);
diff --git a/packages/rocketchat-api/server/v1/groups.js b/packages/rocketchat-api/server/v1/groups.js
index 5a125fb01d31..fc5430c1f6ce 100644
--- a/packages/rocketchat-api/server/v1/groups.js
+++ b/packages/rocketchat-api/server/v1/groups.js
@@ -151,10 +151,8 @@ RocketChat.API.v1.addRoute('groups.counters', { authRequired: true }, {
const lm = room.lm ? room.lm : room._updatedAt;
if (typeof subscription !== 'undefined' && subscription.open) {
- if (subscription.ls) {
- unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls, lm);
- unreadsFrom = subscription.ls;
- }
+ unreads = RocketChat.models.Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, (subscription.ls || subscription.ts), lm);
+ unreadsFrom = subscription.ls || subscription.ts;
userMentions = subscription.userMentions;
joined = true;
}
diff --git a/packages/rocketchat-api/server/v1/rooms.js b/packages/rocketchat-api/server/v1/rooms.js
index 23a82d47a53a..b913fe18ea0e 100644
--- a/packages/rocketchat-api/server/v1/rooms.js
+++ b/packages/rocketchat-api/server/v1/rooms.js
@@ -196,3 +196,24 @@ RocketChat.API.v1.addRoute('rooms.cleanHistory', { authRequired: true }, {
},
});
+RocketChat.API.v1.addRoute('rooms.info', { authRequired: true }, {
+ get() {
+ const room = findRoomByIdOrName({ params: this.requestParams() });
+ const { fields } = this.parseJsonQuery();
+ if (!Meteor.call('canAccessRoom', room._id, this.userId, {})) {
+ return RocketChat.API.v1.failure('not-allowed', 'Not Allowed');
+ }
+ return RocketChat.API.v1.success({ room: RocketChat.models.Rooms.findOneByIdOrName(room._id, { fields }) });
+ },
+});
+
+RocketChat.API.v1.addRoute('rooms.leave', { authRequired: true }, {
+ post() {
+ const room = findRoomByIdOrName({ params: this.bodyParams });
+ Meteor.runAsUser(this.userId, () => {
+ Meteor.call('leaveRoom', room._id);
+ });
+
+ return RocketChat.API.v1.success();
+ },
+});
diff --git a/packages/rocketchat-api/server/v1/users.js b/packages/rocketchat-api/server/v1/users.js
index ed2b7687504f..d1e96b8c1f26 100644
--- a/packages/rocketchat-api/server/v1/users.js
+++ b/packages/rocketchat-api/server/v1/users.js
@@ -117,7 +117,8 @@ RocketChat.API.v1.addRoute('users.getPresence', { authRequired: true }, {
RocketChat.API.v1.addRoute('users.info', { authRequired: true }, {
get() {
const { username } = this.getUserFromParams();
-
+ const { fields } = this.parseJsonQuery();
+ let user = {};
let result;
Meteor.runAsUser(this.userId, () => {
result = Meteor.call('getFullUserData', { username, limit: 1 });
@@ -127,8 +128,24 @@ RocketChat.API.v1.addRoute('users.info', { authRequired: true }, {
return RocketChat.API.v1.failure(`Failed to get the user data for the userId of "${ username }".`);
}
+ user = result[0];
+ if (fields.userRooms === 1 && RocketChat.authz.hasPermission(this.userId, 'view-other-user-channels')) {
+ user.rooms = RocketChat.models.Subscriptions.findByUserId(this.userId, {
+ fields: {
+ rid: 1,
+ name: 1,
+ t: 1,
+ roles: 1,
+ },
+ sort: {
+ t: 1,
+ name: 1,
+ },
+ }).fetch();
+ }
+
return RocketChat.API.v1.success({
- user: result[0],
+ user,
});
},
});
@@ -481,8 +498,8 @@ RocketChat.API.v1.addRoute('users.regeneratePersonalAccessToken', { authRequired
RocketChat.API.v1.addRoute('users.getPersonalAccessTokens', { authRequired: true }, {
get() {
- if (!RocketChat.settings.get('API_Enable_Personal_Access_Tokens')) {
- throw new Meteor.Error('error-personal-access-tokens-are-current-disabled', 'Personal Access Tokens are currently disabled');
+ if (!RocketChat.authz.hasPermission(this.userId, 'create-personal-access-tokens')) {
+ throw new Meteor.Error('not-authorized', 'Not Authorized');
}
const loginTokens = RocketChat.models.Users.getLoginTokensByUserId(this.userId).fetch()[0];
const getPersonalAccessTokens = () => loginTokens.services.resume.loginTokens
diff --git a/packages/rocketchat-apps/server/bridges/persistence.js b/packages/rocketchat-apps/server/bridges/persistence.js
index e65fd609a6e2..9119807a708d 100644
--- a/packages/rocketchat-apps/server/bridges/persistence.js
+++ b/packages/rocketchat-apps/server/bridges/persistence.js
@@ -92,4 +92,19 @@ export class AppPersistenceBridge {
throw new Error('Not implemented.');
}
+
+ async updateByAssociation(association, data, upsert, appId) {
+ console.log(`The App ${ appId } is updating the record with association to data as follows:`, association, data);
+
+ if (typeof data !== 'object') {
+ throw new Error('Attempted to store an invalid data type, it must be an object.');
+ }
+
+ const query = {
+ appId,
+ associations: association,
+ };
+
+ return this.orch.getPersistenceModel().upsert(query, { $set: { data } }, { upsert });
+ }
}
diff --git a/packages/rocketchat-apps/server/bridges/rooms.js b/packages/rocketchat-apps/server/bridges/rooms.js
index 5cbbc783dd80..9ae44a587200 100644
--- a/packages/rocketchat-apps/server/bridges/rooms.js
+++ b/packages/rocketchat-apps/server/bridges/rooms.js
@@ -19,8 +19,11 @@ export class AppRoomBridge {
case RoomType.PRIVATE_GROUP:
method = 'createPrivateGroup';
break;
+ case RoomType.DIRECT_MESSAGE:
+ method = 'createDirectMessage';
+ break;
default:
- throw new Error('Only channels and private groups can be created.');
+ throw new Error('Only channels, private groups and direct messages can be created.');
}
let rid;
@@ -30,7 +33,13 @@ export class AppRoomBridge {
delete extraData.t;
delete extraData.ro;
delete extraData.customFields;
- const info = Meteor.call(method, rcRoom.name, members, rcRoom.ro, rcRoom.customFields, extraData);
+ let info;
+ if (room.type === RoomType.DIRECT_MESSAGE) {
+ members.splice(members.indexOf(room.creator.username), 1);
+ info = Meteor.call(method, members[0]);
+ } else {
+ info = Meteor.call(method, rcRoom.name, members, rcRoom.ro, rcRoom.customFields, extraData);
+ }
rid = info.rid;
});
@@ -73,6 +82,21 @@ export class AppRoomBridge {
return this.orch.getConverters().get('users').convertById(room.u._id);
}
+ async getMembers(roomId, appId) {
+ console.log(`The App ${ appId } is getting the room's members by room id: "${ roomId }"`);
+ const subscriptions = await RocketChat.models.Subscriptions.findByRoomId(roomId);
+ return subscriptions.map((sub) => this.orch.getConverters().get('users').convertById(sub.u && sub.u._id));
+ }
+
+ async getDirectByUsernames(usernames, appId) {
+ console.log(`The App ${ appId } is getting direct room by usernames: "${ usernames }"`);
+ const room = await RocketChat.models.Rooms.findDirectRoomContainingAllUsernames(usernames);
+ if (!room) {
+ return undefined;
+ }
+ return this.orch.getConverters().get('rooms').convertRoom(room);
+ }
+
async update(room, members = [], appId) {
console.log(`The App ${ appId } is updating a room.`);
diff --git a/packages/rocketchat-authorization/server/startup.js b/packages/rocketchat-authorization/server/startup.js
index 9da43268023c..db5114060f32 100644
--- a/packages/rocketchat-authorization/server/startup.js
+++ b/packages/rocketchat-authorization/server/startup.js
@@ -21,6 +21,7 @@ Meteor.startup(function() {
{ _id: 'create-c', roles : ['admin', 'user', 'bot'] },
{ _id: 'create-d', roles : ['admin', 'user', 'bot'] },
{ _id: 'create-p', roles : ['admin', 'user', 'bot'] },
+ { _id: 'create-personal-access-tokens', roles : ['admin', 'user'] },
{ _id: 'create-user', roles : ['admin'] },
{ _id: 'clean-channel-history', roles : ['admin'] },
{ _id: 'delete-c', roles : ['admin', 'owner'] },
@@ -48,6 +49,7 @@ Meteor.startup(function() {
{ _id: 'mention-here', roles : ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'mute-user', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'remove-user', roles : ['admin', 'owner', 'moderator'] },
+ { _id: 'reset-other-user-e2e-key', roles : ['admin'] },
{ _id: 'run-import', roles : ['admin'] },
{ _id: 'run-migration', roles : ['admin'] },
{ _id: 'set-moderator', roles : ['admin', 'owner'] },
diff --git a/packages/rocketchat-crowd/package.js b/packages/rocketchat-crowd/package.js
index 09e462205350..83c5bcd53537 100644
--- a/packages/rocketchat-crowd/package.js
+++ b/packages/rocketchat-crowd/package.js
@@ -14,6 +14,7 @@ Package.onUse(function(api) {
'templating',
'accounts-base',
'accounts-password',
+ 'littledata:synced-cron',
]);
api.mainModule('client/index.js', 'client');
diff --git a/packages/rocketchat-custom-sounds/client/admin/adminSounds.js b/packages/rocketchat-custom-sounds/client/admin/adminSounds.js
index 8a6669d75a42..aeacec75b331 100644
--- a/packages/rocketchat-custom-sounds/client/admin/adminSounds.js
+++ b/packages/rocketchat-custom-sounds/client/admin/adminSounds.js
@@ -3,6 +3,8 @@ import { RocketChatTabBar } from 'meteor/rocketchat:lib';
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
+import { RocketChat } from 'meteor/rocketchat:lib';
+import { SideNav } from 'meteor/rocketchat:ui';
import s from 'underscore.string';
Template.adminSounds.helpers({
diff --git a/packages/rocketchat-custom-sounds/client/admin/soundEdit.js b/packages/rocketchat-custom-sounds/client/admin/soundEdit.js
index 818548631a45..65594d0d0a2b 100644
--- a/packages/rocketchat-custom-sounds/client/admin/soundEdit.js
+++ b/packages/rocketchat-custom-sounds/client/admin/soundEdit.js
@@ -1,6 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
+import { t } from 'meteor/rocketchat:ui';
+import { handleError } from 'meteor/rocketchat:lib';
import toastr from 'toastr';
import s from 'underscore.string';
diff --git a/packages/rocketchat-custom-sounds/client/admin/soundInfo.js b/packages/rocketchat-custom-sounds/client/admin/soundInfo.js
index 20ace93335fc..db3853e0b74e 100644
--- a/packages/rocketchat-custom-sounds/client/admin/soundInfo.js
+++ b/packages/rocketchat-custom-sounds/client/admin/soundInfo.js
@@ -1,6 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
+import { t, modal } from 'meteor/rocketchat:ui';
+import { handleError } from 'meteor/rocketchat:lib';
Template.soundInfo.helpers({
name() {
diff --git a/packages/rocketchat-custom-sounds/client/admin/startup.js b/packages/rocketchat-custom-sounds/client/admin/startup.js
index e17d7389925b..c9e888e96850 100644
--- a/packages/rocketchat-custom-sounds/client/admin/startup.js
+++ b/packages/rocketchat-custom-sounds/client/admin/startup.js
@@ -1,3 +1,5 @@
+import { RocketChat } from 'meteor/rocketchat:lib';
+
RocketChat.AdminBox.addOption({
href: 'custom-sounds',
i18nLabel: 'Custom_Sounds',
diff --git a/packages/rocketchat-custom-sounds/client/index.js b/packages/rocketchat-custom-sounds/client/index.js
new file mode 100644
index 000000000000..204f894d7b3a
--- /dev/null
+++ b/packages/rocketchat-custom-sounds/client/index.js
@@ -0,0 +1,15 @@
+import '../assets/stylesheets/customSoundsAdmin.css';
+import './lib/CustomSounds';
+import './models/CustomSounds';
+import './notifications/deleteCustomSound';
+import './notifications/updateCustomSound';
+import './admin/adminSoundEdit.html';
+import './admin/adminSoundInfo.html';
+import './admin/adminSounds.html';
+import './admin/adminSounds';
+import './admin/soundEdit.html';
+import './admin/soundEdit';
+import './admin/soundInfo.html';
+import './admin/soundInfo';
+import './admin/route';
+import './admin/startup';
diff --git a/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js b/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js
index 5f3775b10256..69bf7c7c6acb 100644
--- a/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js
+++ b/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js
@@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
+import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';
class CustomSounds {
diff --git a/packages/rocketchat-custom-sounds/client/models/CustomSounds.js b/packages/rocketchat-custom-sounds/client/models/CustomSounds.js
index 59c847dd1b79..b43ee109d9f7 100644
--- a/packages/rocketchat-custom-sounds/client/models/CustomSounds.js
+++ b/packages/rocketchat-custom-sounds/client/models/CustomSounds.js
@@ -1,3 +1,5 @@
+import { RocketChat } from 'meteor/rocketchat:lib';
+
class CustomSounds extends RocketChat.models._Base {
constructor() {
super();
diff --git a/packages/rocketchat-custom-sounds/client/notifications/deleteCustomSound.js b/packages/rocketchat-custom-sounds/client/notifications/deleteCustomSound.js
index 7ddde5d45c1b..91560d7d28df 100644
--- a/packages/rocketchat-custom-sounds/client/notifications/deleteCustomSound.js
+++ b/packages/rocketchat-custom-sounds/client/notifications/deleteCustomSound.js
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
Meteor.startup(() =>
RocketChat.CachedCollectionManager.onLogin(() =>
diff --git a/packages/rocketchat-custom-sounds/client/notifications/updateCustomSound.js b/packages/rocketchat-custom-sounds/client/notifications/updateCustomSound.js
index 75a65b6cbdeb..75903369bd06 100644
--- a/packages/rocketchat-custom-sounds/client/notifications/updateCustomSound.js
+++ b/packages/rocketchat-custom-sounds/client/notifications/updateCustomSound.js
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
Meteor.startup(() =>
RocketChat.CachedCollectionManager.onLogin(() =>
diff --git a/packages/rocketchat-custom-sounds/package.js b/packages/rocketchat-custom-sounds/package.js
index ff5f1505b424..afd358d9bf4e 100644
--- a/packages/rocketchat-custom-sounds/package.js
+++ b/packages/rocketchat-custom-sounds/package.js
@@ -13,40 +13,10 @@ Package.onUse(function(api) {
'templating',
'reactive-var',
'webapp',
+ 'kadira:flow-router',
+ 'kadira:blaze-layout',
]);
- api.use('kadira:flow-router', 'client');
- api.use('kadira:blaze-layout', 'client');
-
- api.addFiles('server/startup/custom-sounds.js', 'server');
- api.addFiles('server/startup/permissions.js', 'server');
- api.addFiles('server/startup/settings.js', 'server');
-
- api.addFiles('server/models/CustomSounds.js', 'server');
- api.addFiles('server/publications/customSounds.js', 'server');
-
- api.addFiles([
- 'server/methods/deleteCustomSound.js',
- 'server/methods/insertOrUpdateSound.js',
- 'server/methods/listCustomSounds.js',
- 'server/methods/uploadCustomSound.js',
- ], 'server');
-
- api.addFiles('assets/stylesheets/customSoundsAdmin.css', 'client');
-
- api.addFiles('client/admin/startup.js', 'client');
- api.addFiles('client/admin/adminSounds.html', 'client');
- api.addFiles('client/admin/adminSounds.js', 'client');
- api.addFiles('client/admin/adminSoundEdit.html', 'client');
- api.addFiles('client/admin/adminSoundInfo.html', 'client');
- api.addFiles('client/admin/soundEdit.html', 'client');
- api.addFiles('client/admin/soundEdit.js', 'client');
- api.addFiles('client/admin/soundInfo.html', 'client');
- api.addFiles('client/admin/soundInfo.js', 'client');
- api.addFiles('client/admin/route.js', 'client');
-
- api.addFiles('client/lib/CustomSounds.js', 'client');
- api.addFiles('client/models/CustomSounds.js', 'client');
- api.addFiles('client/notifications/updateCustomSound.js', 'client');
- api.addFiles('client/notifications/deleteCustomSound.js', 'client');
+ api.mainModule('client/index.js', 'client');
+ api.mainModule('server/index.js', 'server');
});
diff --git a/packages/rocketchat-custom-sounds/server/index.js b/packages/rocketchat-custom-sounds/server/index.js
new file mode 100644
index 000000000000..9caeb06c2abe
--- /dev/null
+++ b/packages/rocketchat-custom-sounds/server/index.js
@@ -0,0 +1,9 @@
+import './startup/custom-sounds';
+import './startup/permissions';
+import './startup/settings';
+import './models/CustomSounds';
+import './methods/deleteCustomSound';
+import './methods/insertOrUpdateSound';
+import './methods/listCustomSounds';
+import './methods/uploadCustomSound';
+import './publications/customSounds';
diff --git a/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js b/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js
index b6aba7a7b17f..d74871c90ca9 100644
--- a/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js
+++ b/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js
@@ -1,5 +1,6 @@
-/* globals RocketChatFileCustomSoundsInstance */
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
+import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds';
Meteor.methods({
deleteCustomSound(_id) {
diff --git a/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js b/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js
index e5b91e95d6e2..cad6c03d1e85 100644
--- a/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js
+++ b/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js
@@ -1,5 +1,6 @@
-/* globals RocketChatFileCustomSoundsInstance */
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
+import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds';
import s from 'underscore.string';
Meteor.methods({
diff --git a/packages/rocketchat-custom-sounds/server/methods/listCustomSounds.js b/packages/rocketchat-custom-sounds/server/methods/listCustomSounds.js
index 9aeb28d8b45f..9b38e382fbd1 100644
--- a/packages/rocketchat-custom-sounds/server/methods/listCustomSounds.js
+++ b/packages/rocketchat-custom-sounds/server/methods/listCustomSounds.js
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
Meteor.methods({
listCustomSounds() {
diff --git a/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js b/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js
index 2c530c383f8c..2cc8bf2404a9 100644
--- a/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js
+++ b/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js
@@ -1,5 +1,7 @@
-/* globals RocketChatFileCustomSoundsInstance */
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
+import { RocketChatFile } from 'meteor/rocketchat:file';
+import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds';
Meteor.methods({
uploadCustomSound(binaryContent, contentType, soundData) {
diff --git a/packages/rocketchat-custom-sounds/server/models/CustomSounds.js b/packages/rocketchat-custom-sounds/server/models/CustomSounds.js
index 8447d7d5e750..9c05dab8a6fa 100644
--- a/packages/rocketchat-custom-sounds/server/models/CustomSounds.js
+++ b/packages/rocketchat-custom-sounds/server/models/CustomSounds.js
@@ -1,3 +1,5 @@
+import { RocketChat } from 'meteor/rocketchat:lib';
+
class CustomSounds extends RocketChat.models._Base {
constructor() {
super('custom_sounds');
diff --git a/packages/rocketchat-custom-sounds/server/publications/customSounds.js b/packages/rocketchat-custom-sounds/server/publications/customSounds.js
index b474e416ebb9..2da7176ef499 100644
--- a/packages/rocketchat-custom-sounds/server/publications/customSounds.js
+++ b/packages/rocketchat-custom-sounds/server/publications/customSounds.js
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
import s from 'underscore.string';
Meteor.publish('customSounds', function(filter, limit) {
diff --git a/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js b/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js
index 226ed972cbfe..1d6fb8a79ba5 100644
--- a/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js
+++ b/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js
@@ -1,8 +1,11 @@
-/* globals RocketChatFileCustomSoundsInstance */
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
+import { RocketChatFile } from 'meteor/rocketchat:file';
+import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';
+export let RocketChatFileCustomSoundsInstance;
+
Meteor.startup(function() {
let storeType = 'GridFS';
@@ -25,13 +28,11 @@ Meteor.startup(function() {
}
}
- this.RocketChatFileCustomSoundsInstance = new RocketChatStore({
+ RocketChatFileCustomSoundsInstance = new RocketChatStore({
name: 'custom_sounds',
absolutePath: path,
});
- self = this;
-
return WebApp.connectHandlers.use('/custom-sounds/', Meteor.bindEnvironment(function(req, res/* , next*/) {
const params =
{ sound: decodeURIComponent(req.url.replace(/^\//, '').replace(/\?.*$/, '')) };
diff --git a/packages/rocketchat-custom-sounds/server/startup/permissions.js b/packages/rocketchat-custom-sounds/server/startup/permissions.js
index 0b947797c09c..90c5ca5dffdb 100644
--- a/packages/rocketchat-custom-sounds/server/startup/permissions.js
+++ b/packages/rocketchat-custom-sounds/server/startup/permissions.js
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
Meteor.startup(() => {
if (RocketChat.models && RocketChat.models.Permissions) {
diff --git a/packages/rocketchat-custom-sounds/server/startup/settings.js b/packages/rocketchat-custom-sounds/server/startup/settings.js
index 4d04f2d8b2a3..67c1fbeb769e 100644
--- a/packages/rocketchat-custom-sounds/server/startup/settings.js
+++ b/packages/rocketchat-custom-sounds/server/startup/settings.js
@@ -1,3 +1,5 @@
+import { RocketChat } from 'meteor/rocketchat:lib';
+
RocketChat.settings.addGroup('CustomSoundsFilesystem', function() {
this.add('CustomSounds_Storage_Type', 'GridFS', {
type: 'select',
diff --git a/packages/rocketchat-e2e/client/rocketchat.e2e.js b/packages/rocketchat-e2e/client/rocketchat.e2e.js
index 8a401a6b8f2c..2aec83f981fe 100644
--- a/packages/rocketchat-e2e/client/rocketchat.e2e.js
+++ b/packages/rocketchat-e2e/client/rocketchat.e2e.js
@@ -67,6 +67,10 @@ class E2E {
_id: roomId,
});
+ if (!room) {
+ return;
+ }
+
if (room.encrypted !== true) {
return;
}
@@ -185,6 +189,7 @@ class E2E {
}
async stopClient() {
+ console.log('E2E -> Stop Client');
// This flag is used to avoid closing unrelated alerts.
if (showingE2EAlert) {
alerts.close();
@@ -192,7 +197,16 @@ class E2E {
localStorage.removeItem('public_key');
localStorage.removeItem('private_key');
+ this.instancesByRoomId = {};
+ this.privateKey = null;
+ this.enabled.set(false);
+ this._ready.set(false);
this.started = false;
+
+ this.readyPromise = new Deferred();
+ this.readyPromise.then(() => {
+ this._ready.set(true);
+ });
}
setupListeners() {
@@ -236,6 +250,7 @@ class E2E {
async loadKeysFromDB() {
try {
const { public_key, private_key } = await call('e2e.fetchMyKeys');
+
this.db_public_key = public_key;
this.db_private_key = private_key;
} catch (error) {
@@ -280,6 +295,12 @@ class E2E {
} catch (error) {
return console.error('E2E -> Error exporting private key: ', error);
}
+
+ this.requestSubscriptionKeys();
+ }
+
+ async requestSubscriptionKeys() {
+ call('e2e.requestSubscriptionKeys');
}
createRandomPassword() {
diff --git a/packages/rocketchat-e2e/server/index.js b/packages/rocketchat-e2e/server/index.js
index 9380368df0e2..c7167c3f6fd3 100644
--- a/packages/rocketchat-e2e/server/index.js
+++ b/packages/rocketchat-e2e/server/index.js
@@ -9,6 +9,8 @@ import './methods/getUsersOfRoomWithoutKey';
import './methods/updateGroupKey';
import './methods/setRoomKeyID';
import './methods/fetchMyKeys';
+import './methods/resetUserE2EKey';
+import './methods/requestSubscriptionKeys';
RocketChat.callbacks.add('afterJoinRoom', (user, room) => {
RocketChat.Notifications.notifyRoom('e2e.keyRequest', room._id, room.e2eKeyId);
diff --git a/packages/rocketchat-e2e/server/methods/requestSubscriptionKeys.js b/packages/rocketchat-e2e/server/methods/requestSubscriptionKeys.js
new file mode 100644
index 000000000000..50d15ce4814d
--- /dev/null
+++ b/packages/rocketchat-e2e/server/methods/requestSubscriptionKeys.js
@@ -0,0 +1,33 @@
+import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
+
+Meteor.methods({
+ 'e2e.requestSubscriptionKeys'() {
+ if (!Meteor.userId()) {
+ throw new Meteor.Error('error-invalid-user', 'Invalid user', {
+ method: 'requestSubscriptionKeys',
+ });
+ }
+
+ // Get all encrypted rooms that the user is subscribed to and has no E2E key yet
+ const subscriptions = RocketChat.models.Subscriptions.findByUserIdWithoutE2E(Meteor.userId());
+ const roomIds = subscriptions.map((subscription) => subscription.rid);
+
+ // For all subscriptions without E2E key, get the rooms that have encryption enabled
+ const query = {
+ e2eKeyId : {
+ $exists: true,
+ },
+ _id : {
+ $in: roomIds,
+ },
+ };
+
+ const rooms = RocketChat.models.Rooms.find(query);
+ rooms.forEach((room) => {
+ RocketChat.Notifications.notifyRoom('e2e.keyRequest', room._id, room.e2eKeyId);
+ });
+
+ return true;
+ },
+});
diff --git a/packages/rocketchat-e2e/server/methods/resetUserE2EKey.js b/packages/rocketchat-e2e/server/methods/resetUserE2EKey.js
new file mode 100644
index 000000000000..53599f16d284
--- /dev/null
+++ b/packages/rocketchat-e2e/server/methods/resetUserE2EKey.js
@@ -0,0 +1,25 @@
+import { Meteor } from 'meteor/meteor';
+import { RocketChat } from 'meteor/rocketchat:lib';
+
+Meteor.methods({
+ 'e2e.resetUserE2EKey'(userId) {
+ if (!Meteor.userId()) {
+ throw new Meteor.Error('error-invalid-user', 'Invalid user', {
+ method: 'resetUserE2EKey',
+ });
+ }
+
+ if (RocketChat.authz.hasPermission(Meteor.userId(), 'reset-other-user-e2e-key') !== true) {
+ throw new Meteor.Error('error-not-allowed', 'Not allowed', {
+ method: 'resetUserE2EKey',
+ });
+ }
+
+ RocketChat.models.Users.resetE2EKey(userId);
+ RocketChat.models.Subscriptions.resetUserE2EKey(userId);
+
+ // Force the user to logout, so that the keys can be generated again
+ RocketChat.models.Users.removeResumeService(userId);
+ return true;
+ },
+});
diff --git a/packages/rocketchat-e2e/server/models/Subscriptions.js b/packages/rocketchat-e2e/server/models/Subscriptions.js
index 88af4c7d357b..2ab46b438e54 100644
--- a/packages/rocketchat-e2e/server/models/Subscriptions.js
+++ b/packages/rocketchat-e2e/server/models/Subscriptions.js
@@ -17,3 +17,24 @@ RocketChat.models.Subscriptions.findByRidWithoutE2EKey = function(rid, options)
return this.find(query, options);
};
+
+RocketChat.models.Subscriptions.resetUserE2EKey = function(userId) {
+ this.update({ 'u._id': userId }, {
+ $unset: {
+ E2EKey: '',
+ },
+ }, {
+ multi: true,
+ });
+};
+
+RocketChat.models.Subscriptions.findByUserIdWithoutE2E = function(userId, options) {
+ const query = {
+ 'u._id': userId,
+ E2EKey: {
+ $exists: false,
+ },
+ };
+
+ return this.find(query, options);
+};
diff --git a/packages/rocketchat-e2e/server/models/Users.js b/packages/rocketchat-e2e/server/models/Users.js
index ac072f960d45..3a099808b0d9 100644
--- a/packages/rocketchat-e2e/server/models/Users.js
+++ b/packages/rocketchat-e2e/server/models/Users.js
@@ -34,3 +34,11 @@ RocketChat.models.Users.findByIdsWithPublicE2EKey = function(ids, options) {
return this.find(query, options);
};
+
+RocketChat.models.Users.resetE2EKey = function(userId) {
+ this.update({ _id: userId }, {
+ $unset: {
+ e2e: '',
+ },
+ });
+};
diff --git a/packages/rocketchat-favico/client/favico.js b/packages/rocketchat-favico/client/favico.js
index 00f6f5e60fa3..b85f9b4a4ee1 100644
--- a/packages/rocketchat-favico/client/favico.js
+++ b/packages/rocketchat-favico/client/favico.js
@@ -23,9 +23,8 @@
* });
*/
/* eslint-disable */
-(function() {
- var Favico = (function(opt) {
+ export const Favico = (function(opt) {
'use strict';
opt = (opt) ? opt : {};
var _def = {
@@ -843,20 +842,3 @@
}
};
});
-
- // AMD / RequireJS
- if (typeof define !== 'undefined' && define.amd) {
- define([], function() {
- return Favico;
- });
- }
- // CommonJS
- else if (typeof module !== 'undefined' && module.exports) {
- module.exports = Favico;
- }
- // included directly via