Change /archive and /unarchive to actually send a message to the room.

pull/3550/head
Marcelo Schmidt 10 years ago
parent 0e1e65838f
commit b45402f1fe
No known key found for this signature in database
GPG Key ID: CA48C21A7B66097E
  1. 2
      packages/rocketchat-lib/i18n/en.i18n.json
  2. 12
      packages/rocketchat-lib/lib/MessageTypes.coffee
  3. 3
      packages/rocketchat-slashcommands-archiveroom/messages.js
  4. 1
      packages/rocketchat-slashcommands-archiveroom/package.js
  5. 11
      packages/rocketchat-slashcommands-archiveroom/server.js
  6. 3
      packages/rocketchat-slashcommands-unarchiveroom/messages.js
  7. 1
      packages/rocketchat-slashcommands-unarchiveroom/package.js
  8. 11
      packages/rocketchat-slashcommands-unarchiveroom/server.js

@ -1076,6 +1076,8 @@
"This_email_has_already_been_used_and_has_not_been_verified__Please_change_your_password" : "This email has already been used and has not been verified. Please change your password.",
"This_is_a_desktop_notification" : "This is a desktop notification",
"This_is_a_push_test_messsage" : "This is a push test messsage",
"This_room_has_been_archived_by__username_" : "This room has been archived by __username__",
"This_room_has_been_unarchived_by__username_" : "This room has been unarchived by __username__",
"Time_in_seconds" : "Time in seconds",
"Title" : "Title",
"Title_bar_color" : "Title bar color",

@ -97,4 +97,16 @@ Meteor.startup ->
data: (message) ->
return { username: message.msg, role: message.role, user_by: message.u.username }
RocketChat.MessageTypes.registerType
id: 'room-archived'
system: true
message: 'This_room_has_been_archived_by__username_'
data: (message) ->
return { username: message.u.username }
RocketChat.MessageTypes.registerType
id: 'room-unarchived'
system: true
message: 'This_room_has_been_unarchived_by__username_'
data: (message) ->
return { username: message.u.username }

@ -0,0 +1,3 @@
RocketChat.models.Messages.createRoomArchivedByRoomIdAndUser = function(roomId, user) {
return this.createWithTypeRoomIdMessageAndUser('room-archived', roomId, '', user);
};

@ -18,5 +18,6 @@ Package.onUse(function(api) {
api.use('templating', 'client');
api.addFiles('client.js', 'client');
api.addFiles('messages.js', 'server');
api.addFiles('server.js', 'server');
});

@ -5,12 +5,14 @@ function Archive(command, params, item) {
}
channel = params.trim();
if (channel === '') {
return;
room = RocketChat.models.Rooms.findOneById(item.rid)
channel = room.name;
} else {
channel = channel.replace('#', '');
room = RocketChat.models.Rooms.findOneByName(channel);
}
channel = channel.replace('#', '');
user = Meteor.users.findOne(Meteor.userId());
room = RocketChat.models.Rooms.findOneByName(channel);
if (room.archived) {
RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
_id: Random.id(),
@ -25,6 +27,7 @@ function Archive(command, params, item) {
}
Meteor.call('archiveRoom', room._id);
RocketChat.models.Messages.createRoomArchivedByRoomIdAndUser(room._id, Meteor.user());
RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
_id: Random.id(),
rid: item.rid,

@ -0,0 +1,3 @@
RocketChat.models.Messages.createRoomUnarchivedByRoomIdAndUser = function(roomId, user) {
return this.createWithTypeRoomIdMessageAndUser('room-unarchived', roomId, '', user);
};

@ -18,5 +18,6 @@ Package.onUse(function(api) {
api.use('templating', 'client');
api.addFiles('client.js', 'client');
api.addFiles('messages.js', 'server');
api.addFiles('server.js', 'server');
});

@ -5,12 +5,14 @@ function Unarchive(command, params, item) {
}
channel = params.trim();
if (channel === '') {
return;
room = RocketChat.models.Rooms.findOneById(item.rid)
channel = room.name;
} else {
channel = channel.replace('#', '');
room = RocketChat.models.Rooms.findOneByName(channel);
}
channel = channel.replace('#', '');
user = Meteor.users.findOne(Meteor.userId());
room = RocketChat.models.Rooms.findOneByName(channel);
if (!room.archived) {
RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
_id: Random.id(),
@ -24,6 +26,7 @@ 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(),
rid: item.rid,

Loading…
Cancel
Save