parent
a26d955a78
commit
92641f4130
@ -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…
Reference in new issue