Skip to content

Commit

Permalink
Merge branch 'develop' into improvements/more-streams
Browse files Browse the repository at this point in the history
  • Loading branch information
engelgabriel committed Jun 2, 2016
2 parents a86001f + 680027f commit 6045fd2
Show file tree
Hide file tree
Showing 40 changed files with 1,710 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ module.exports = {
'EJSON' : false,
'Email' : false,
'FlowRouter' : false,
'HTTP' : false,
'getNextAgent' : false,
'handleError' : false,
'getAvatarUrlFromUsername' : false,
'LivechatCustomField' : false,
'LivechatDepartment' : false,
'LivechatDepartmentAgents' : false,
Expand Down
3 changes: 3 additions & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ rocketchat:otr
rocketchat:piwik
rocketchat:push-notifications
rocketchat:reactions
rocketchat:slackbridge
rocketchat:slashcommands-invite
rocketchat:slashcommands-join
rocketchat:slashcommands-kick
Expand Down Expand Up @@ -144,3 +145,5 @@ todda00:friendly-slugs
underscorestring:underscore.string
yasaricli:slugify
yasinuslu:blaze-meta

rocketchat:action-links
4 changes: 3 additions & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jparker:[email protected]
[email protected]
kadira:[email protected]
kadira:[email protected]
kenton:accounts-sandstorm@0.3.0
kenton:accounts-sandstorm@0.4.0
konecty:[email protected]
konecty:[email protected]
konecty:[email protected]
Expand Down Expand Up @@ -129,6 +129,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
Expand Down Expand Up @@ -172,6 +173,7 @@ rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
Expand Down
9 changes: 0 additions & 9 deletions lib/ua-parser.min.js

This file was deleted.

26 changes: 26 additions & 0 deletions packages/rocketchat-action-links/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
RocketChat Action Links
============

Action Links are a way to add custom javascript functions to RocketChat messages. The links appear as a horizontal list below the message they correspond to, and by clicking the link will run a function you define server-side.

Usage
------------

Add 'actionLinks' to any message object as in the example below. It should be an array of object, each containing a 'label' (this will be the text printed to click on), a method_id (this is the name of the method that will be run), and params (this is the parameters passed to the method_id function).

~~~
message.actionLinks = [{ label: "Another Option", method_id: "anotherFunction", params: "stuff"}, { label: "An Option", method_id: "functOne", params: ""}];
~~~





The functions to be run need to be added to the actionLinkFuncts namespace. This is done by calling the RocketChat.actionLinks.register method. Your custom functions should take two parameters: the original message from the database, and the 'params' object given for that function.
~~~
RocketChat.actionLinks.register('functOne', function (origDbMsg, params) {
console.log("I did some stuff!");
});
~~~
15 changes: 15 additions & 0 deletions packages/rocketchat-action-links/client/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Template.room.events({
'click .action-link'(event) {
event.preventDefault();
event.stopPropagation();
const data = Blaze.getData(event.currentTarget);

if (data && data._arguments && data._arguments[1] && data._arguments[1]._id) {
Meteor.call('actionLinkHandler', event.currentTarget.childNodes[1].name, data._arguments[1]._id, (err) => {
if (err) {
handleError(err);
}
});
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.message {
.actionLinks {
padding: 0;
margin-top: 4px;
text-align: center;
li {
cursor: pointer;
position: relative;
padding-right: 2px;
color: #036;

list-style: none;
display: inline;


&:hover {
color: #369;
}
}

li:after { content: " \25CF"; }
li:last-child:after { content: none; }
}
}
3 changes: 3 additions & 0 deletions packages/rocketchat-action-links/loadStylesheets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RocketChat.theme.addPackageAsset(function() {
return Assets.getText('client/stylesheets/actionLinks.less');
});
24 changes: 24 additions & 0 deletions packages/rocketchat-action-links/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Package.describe({
name: 'rocketchat:action-links',
version: '0.0.1',
summary: 'Add custom actions that call functions',
git: '',
});

Package.onUse(function(api) {
api.versionsFrom('1.0');

api.use('ecmascript');
api.use('templating');
api.use('rocketchat:lib');
api.use('rocketchat:theme');
api.use('rocketchat:ui');

api.addFiles('client/init.js', 'client');
api.addAssets('client/stylesheets/actionLinks.less', 'server');
api.addFiles('loadStylesheets.js', 'server');

api.addFiles('server/registerActionLinkFuncts.js', 'server');
api.addFiles('server/actionLinkHandler.js', 'server');

});
25 changes: 25 additions & 0 deletions packages/rocketchat-action-links/server/actionLinkHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Action Links Handler. This method will be called off the client.

Meteor.methods({
actionLinkHandler(name, messageId) {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'actionLinkHandler' });
}

var message = RocketChat.models.Messages.findOneById(messageId);
if (!message) {
throw new Meteor.Error('error-invalid-message', 'Invalid message', { method: 'actionLinkHandler' });
}

var actionLink = message.actionLinks[name];
if (!message.actionLinks || !actionLink || !RocketChat.actionLinks || !RocketChat.actionLinks[actionLink.method_id]) {
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link', { method: 'actionLinkHandler' });
}

if (!Meteor.call('canAccessRoom', message.rid, Meteor.userId())) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'actionLinkHandler' });
}

RocketChat.actionLinks[actionLink.method_id](message, actionLink.params);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//Action Links namespace creation.

RocketChat.actionLinks = {
register : function(name, funct) {
RocketChat.actionLinks[name] = funct;
}
};
6 changes: 5 additions & 1 deletion packages/rocketchat-importer-slack/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Importer.Slack = class Importer.Slack extends Importer.Base

if existantUser
user.rocketId = existantUser._id
RocketChat.models.Users.update { _id: user.rocketId }, { $addToSet: { importIds: user.id } }
@userTags.push
slack: "<@#{user.id}>"
slackLong: "<@#{user.id}|#{user.name}>"
Expand All @@ -136,6 +137,8 @@ Importer.Slack = class Importer.Slack extends Importer.Base
if user.tz_offset
Meteor.call 'updateUserUtcOffset', user.tz_offset / 3600

RocketChat.models.Users.update { _id: userId }, { $addToSet: { importIds: user.id } }

if user.profile.real_name
RocketChat.models.Users.setName userId, user.profile.real_name
#Deleted users are 'inactive' users in Rocket.Chat
Expand All @@ -159,6 +162,7 @@ Importer.Slack = class Importer.Slack extends Importer.Base
if channel.is_general and channel.name isnt existantRoom?.name
Meteor.call 'saveRoomSettings', 'GENERAL', 'roomName', channel.name
channel.rocketId = if channel.is_general then 'GENERAL' else existantRoom._id
RocketChat.models.Rooms.update { _id: channel.rocketId }, { $addToSet: { importIds: channel.id } }
else
users = []
for member in channel.members when member isnt channel.creator
Expand Down Expand Up @@ -189,7 +193,7 @@ Importer.Slack = class Importer.Slack extends Importer.Base
if not _.isEmpty(channel.purpose?.value) and channel.purpose.last_set > lastSetTopic
roomUpdate.topic = channel.purpose.value

RocketChat.models.Rooms.update { _id: channel.rocketId }, { $set: roomUpdate }
RocketChat.models.Rooms.update { _id: channel.rocketId }, { $set: roomUpdate, $addToSet: { importIds: channel.id } }

@addCountCompleted 1
@collection.update { _id: @channels._id }, { $set: { 'channels': @channels.channels }}
Expand Down
Loading

0 comments on commit 6045fd2

Please sign in to comment.