Don't allow the archive commands to be run in a direct message room

pull/6737/head
Bradley Hilton 9 years ago
parent 490432f5da
commit 42dc2bc26f
No known key found for this signature in database
GPG Key ID: 0666B2C24C43C358
  1. 5
      packages/rocketchat-slashcommands-archiveroom/server.js
  2. 9
      packages/rocketchat-slashcommands-unarchiveroom/server.js

@ -14,6 +14,11 @@ function Archive(command, params, item) {
room = RocketChat.models.Rooms.findOneByName(channel);
}
// You can not archive direct messages.
if (room.t === 'd') {
return;
}
const user = Meteor.users.findOne(Meteor.userId());
if (room.archived) {

@ -13,6 +13,12 @@ function Unarchive(command, params, item) {
channel = channel.replace('#', '');
room = RocketChat.models.Rooms.findOneByName(channel);
}
// You can not archive direct messages.
if (room.t === 'd') {
return;
}
const user = Meteor.users.findOne(Meteor.userId());
if (!room.archived) {
@ -27,7 +33,9 @@ function Unarchive(command, params, item) {
});
return;
}
Meteor.call('unarchiveRoom', room._id);
RocketChat.models.Messages.createRoomUnarchivedByRoomIdAndUser(room._id, Meteor.user());
RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
_id: Random.id(),
@ -38,6 +46,7 @@ function Unarchive(command, params, item) {
sprintf: [channel]
}, user.language)
});
return Unarchive;
}

Loading…
Cancel
Save