Skip to content

Commit

Permalink
Merge pull request #6919 from phutchins/feature/deleteAnyMessagePermi…
Browse files Browse the repository at this point in the history
…ssion

[NEW] Feature/delete any message permission
  • Loading branch information
rodrigok authored May 10, 2017
2 parents e7dd4b8 + 9cf1bcc commit d6883a0
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 40 deletions.
8 changes: 4 additions & 4 deletions client/methods/deleteMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Meteor.methods({
message = ChatMessage.findOne({ _id: message._id });

const hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid);
const forceDelete = RocketChat.authz.hasAtLeastOnePermission('force-delete-message', message.rid);
const deleteAllowed = RocketChat.settings.get('Message_AllowDeleting');
let deleteOwn = false;

if (message && message.u && message.u._id) {
deleteOwn = message.u._id === Meteor.userId();
}

if (!(hasPermission || (deleteAllowed && deleteOwn))) {
if (!(forceDelete || hasPermission || (deleteAllowed && deleteOwn))) {
return false;
}

const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
if (_.isNumber(blockDeleteInMinutes) && blockDeleteInMinutes !== 0) {
if (!(forceDelete) || (_.isNumber(blockDeleteInMinutes) && blockDeleteInMinutes !== 0)) {
if (message.ts) {
const msgTs = moment(message.ts);
if (msgTs) {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Meteor.startup(function() {
{ _id: 'edit-other-user-password', roles : ['admin'] },
{ _id: 'edit-privileged-setting', roles : ['admin'] },
{ _id: 'edit-room', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'force-delete-message', roles : ['admin', 'owner'] },
{ _id: 'join-without-join-code', roles : ['admin', 'bot'] },
{ _id: 'manage-assets', roles : ['admin'] },
{ _id: 'manage-emoji', roles : ['admin'] },
Expand Down
Loading

0 comments on commit d6883a0

Please sign in to comment.