Merge pull request #1778 from RocketChat/intregation-improvements

Intregation improvements - fixes #1759
pull/1783/head
Gabriel Engel 10 years ago
commit f45aac94de
  1. 3
      packages/rocketchat-cors/cors.coffee
  2. 4
      packages/rocketchat-integrations/server/api/api.coffee
  3. 3
      packages/rocketchat-lib/package.js
  4. 10
      packages/rocketchat-lib/server/lib/debug.js
  5. 7
      packages/rocketchat-message-attachments/client/messageAttachment.coffee

@ -12,6 +12,9 @@ WebApp.rawConnectHandlers.use (req, res, next) ->
req.setEncoding('utf8')
req.on 'data', (chunk) -> buf += chunk
req.on 'end', ->
if RocketChat?.debugLevel? and RocketChat.debugLevel is 'debug'
console.log '[request]'.green, req.method, req.url, '\nheaders ->', req.headers, '\nbody ->', buf
try
req.body = JSON.parse(buf)
catch err

@ -73,7 +73,7 @@ Api.addRoute ':integrationId/:userId/:token', authRequired: true,
message =
alias: @bodyParams.username or @bodyParams.alias or integration.alias
msg: @bodyParams.text or @bodyParams.msg or ''
msg: _.trim(@bodyParams.text or @bodyParams.msg or '')
attachments: @bodyParams.attachments
parseUrls: false
bot:
@ -92,7 +92,7 @@ Api.addRoute ':integrationId/:userId/:token', authRequired: true,
if _.isArray message.attachments
for attachment in message.attachments
if attachment.msg
attachment.text = attachment.msg
attachment.text = _.trim(attachment.msg)
delete attachment.msg
RocketChat.sendMessage user, message, room, {}

@ -25,11 +25,12 @@ Package.onUse(function(api) {
api.use('rocketchat:version');
api.use('kadira:flow-router', 'client');
api.addFiles('lib/core.coffee');
// DEBUGGER
api.addFiles('server/lib/debug.js', 'server');
// COMMON LIB
api.addFiles('lib/core.coffee');
api.addFiles('lib/settings.coffee');
api.addFiles('lib/callbacks.coffee');
api.addFiles('lib/slashCommand.coffee');

@ -1,21 +1,21 @@
var debugLevel = 'debug';
RocketChat.debugLevel = 'debug';
Meteor.startup(function() {
RocketChat.settings.onload('Debug_Level', function(key, value, initialLoad) {
if (value) {
debugLevel = value;
RocketChat.debugLevel = value;
}
});
var value = RocketChat.settings.get('Debug_Level');
if (value) {
debugLevel = value;
RocketChat.debugLevel = value;
}
});
var wrapMethods = function(name, originalHandler, methodsMap) {
methodsMap[name] = function() {
if (debugLevel === 'debug') {
if (RocketChat.debugLevel === 'debug') {
console.log('[methods]'.green, name, '-> userId:', Meteor.userId(), ', arguments: ', arguments);
}
@ -36,7 +36,7 @@ var originalMeteorPublish = Meteor.publish;
Meteor.publish = function(name, func) {
return originalMeteorPublish(name, function() {
if (debugLevel === 'debug') {
if (RocketChat.debugLevel === 'debug') {
console.log('[publish]'.green, name, '-> userId:', this.userId, ', arguments: ', arguments);
}

@ -21,3 +21,10 @@ Template.messageAttachment.helpers
getImageHeight: (height) ->
return height or 200
color: ->
switch @color
when 'good' then return '#35AC19'
when 'warning' then return '#FCB316'
when 'danger' then return '#D30230'
else return @color

Loading…
Cancel
Save