slash command archive room

pull/3587/head
Deepak Kothandan 10 years ago
parent a26d955a78
commit 92641f4130
  1. 1
      .meteor/packages
  2. 1
      .meteor/versions
  3. 3
      packages/rocketchat-lib/i18n/en.i18n.json
  4. 4
      packages/rocketchat-slashcommands-archiveroom/client.js
  5. 22
      packages/rocketchat-slashcommands-archiveroom/package.js
  6. 41
      packages/rocketchat-slashcommands-archiveroom/server.js

@ -147,3 +147,4 @@ todda00:friendly-slugs
underscorestring:underscore.string
yasaricli:slugify
yasinuslu:blaze-meta
rocketchat:slashcommands-archive

@ -174,6 +174,7 @@ rocketchat:piwik@0.0.1
rocketchat:push-notifications@0.0.1
rocketchat:reactions@0.0.1
rocketchat:slackbridge@0.0.1
rocketchat:slashcommands-archive@0.0.1
rocketchat:slashcommands-asciiarts@0.0.1
rocketchat:slashcommands-invite@0.0.1
rocketchat:slashcommands-join@0.0.1

@ -209,6 +209,7 @@
"Certificates_and_Keys" : "Certificates and Keys",
"Changing_email" : "Changing email",
"Channel" : "Channel",
"Channel_Archived" : "Channel with name `#%s` has been archived successfully",
"Channel_doesnt_exist" : "The channel `#%s` does not exist.",
"Channels" : "Channels",
"Channels_list" : "List of public channels",
@ -291,7 +292,7 @@
"Dry_run" : "Dry run",
"Dry_run_description" : "Will only send one email, to the same address as in From. The email must belong to a valid user.",
"Duplicate_channel_name" : "A Channel with name '%s' exists",
"Duplicate_archived_channel_name" : "An archived Channel with name '%s' exists",
"Duplicate_archived_channel_name" : "An archived Channel with name `#%s` exists",
"Duplicate_archived_private_group_name" : "An archived Private Group with name '%s' exists",
"Duplicate_private_group_name" : "A Private Group with name '%s' exists",
"Edit" : "Edit",

@ -0,0 +1,4 @@
RocketChat.slashCommands.add('archive', null, {
description: TAPi18n.__('Archive'),
params: '#channel'
});

@ -0,0 +1,22 @@
Package.describe({
name: 'rocketchat:slashcommands-archive',
version: '0.0.1',
summary: 'Command handler for the /room command',
git: ''
});
Package.onUse(function(api) {
api.versionsFrom('1.0');
api.use([
'ecmascript',
'check',
'rocketchat:lib'
]);
api.use('templating', 'client');
api.addFiles('client.js', 'client');
api.addFiles('server.js', 'server');
});

@ -0,0 +1,41 @@
function Archive(command, params, item) {
var channel, room, user;
if (command !== 'archive' || !Match.test(params, String)) {
return;
}
channel = params.trim();
if (channel === '') {
return;
}
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(),
rid: item.rid,
ts: new Date(),
msg: TAPi18n.__('Duplicate_archived_channel_name', {
postProcess: 'sprintf',
sprintf: [channel]
}, user.language)
});
return;
}
Meteor.call('archiveRoom', room._id);
RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
_id: Random.id(),
rid: item.rid,
ts: new Date(),
msg: TAPi18n.__('Channel_Archived', {
postProcess: 'sprintf',
sprintf: [channel]
}, user.language)
});
return Archive;
}
RocketChat.slashCommands.add('archive', Archive);
Loading…
Cancel
Save