Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Users not being able to activate/deactivate E2E in DMs #18943

Merged
merged 4 commits into from
Sep 18, 2020
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
17 changes: 10 additions & 7 deletions app/channel-settings/server/methods/saveRoomSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,6 @@ Meteor.methods({
});
}

if (!hasPermission(userId, 'edit-room', rid)) {
throw new Meteor.Error('error-action-not-allowed', 'Editing room is not allowed', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}

const room = Rooms.findOneById(rid);

if (!room) {
Expand All @@ -243,6 +236,16 @@ Meteor.methods({
});
}

if (!hasPermission(userId, 'edit-room', rid)) {
if (!(Object.keys(settings).includes('encrypted') && room.t === 'd')) {
throw new Meteor.Error('error-action-not-allowed', 'Editing room is not allowed', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}
settings = { encrypted: settings.encrypted };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @MartinSchoeler , I just stumbled upon this line in the code and can't figure out why it exists. Do you have any context?

}

if (room.broadcast && (settings.readOnly || settings.reactWhenReadOnly)) {
throw new Meteor.Error('error-action-not-allowed', 'Editing readOnly/reactWhenReadOnly are not allowed for broadcast rooms', {
method: 'saveRoomSettings',
Expand Down
9 changes: 8 additions & 1 deletion app/e2e/client/tabbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ Meteor.startup(() => {
call('saveRoomSettings', room._id, 'encrypted', !room.encrypted);
},
order: 13,
condition: () => hasAllPermission('edit-room', Session.get('openedRoom')),
condition: () => {
const session = Session.get('openedRoom');
const room = ChatRoom.findOne(session);
if (room && room.t === 'd') {
return true;
}
return hasAllPermission('edit-room', session);
},
});
} else {
TabBar.removeButton('e2e');
Expand Down
2 changes: 1 addition & 1 deletion app/ui/client/components/header/headerRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Template.headerRoom.events({
event.stopPropagation();
event.preventDefault();
const room = ChatRoom.findOne(this._id);
if (hasAllPermission('edit-room', this._id)) {
if (hasAllPermission('edit-room', this._id) || (room && room.t)) {
call('saveRoomSettings', this._id, 'encrypted', !(room && room.encrypted)).then(() => {
toastr.success(
t('Encrypted_setting_changed_successfully'),
Expand Down