From 9b22b3679ba94bd50f3b3c69403b3c9829b97ced Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 18 Apr 2016 08:38:19 +0200 Subject: [PATCH] Added option for own image_url (app logo image is not possible to use, looks bad in slack). --- .../app/controllers/_integration/slack.coffee | 3 ++- app/models/transaction/slack.rb | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_integration/slack.coffee b/app/assets/javascripts/app/controllers/_integration/slack.coffee index 906c92d69..8ecfd085d 100644 --- a/app/assets/javascripts/app/controllers/_integration/slack.coffee +++ b/app/assets/javascripts/app/controllers/_integration/slack.coffee @@ -24,9 +24,10 @@ class Index extends App.ControllerIntegrationBase configureAttributes = [ { name: 'types', display: 'Trigger', tag: 'checkbox', options: options, 'null': false, class: 'vertical', note: 'Where notification is sent.' }, { name: 'group_id', display: 'Group', tag: 'select', relation: 'Group', multiple: true, 'null': false, note: 'Only for this groups.' }, - { name: 'webhook', display: 'Webhook', tag: 'input', type: 'text', limit: 200, 'null': false, placeholder: 'https://hooks.slack.com/services/...' }, + { name: 'webhook', display: 'Webhook', tag: 'input', type: 'url', limit: 200, 'null': false, placeholder: 'https://hooks.slack.com/services/...' }, { name: 'username', display: 'Username', tag: 'input', type: 'text', limit: 100, 'null': false, placeholder: 'username' }, { name: 'channel', display: 'Channel', tag: 'input', type: 'text', limit: 100, 'null': true, placeholder: '#channel' }, + { name: 'icon_url', display: 'Icon Url', tag: 'input', type: 'url', limit: 200, 'null': true, placeholder: 'http://example.com/logo.png' }, ] settings = [] diff --git a/app/models/transaction/slack.rb b/app/models/transaction/slack.rb index 963ac5f0d..7a6bb9752 100644 --- a/app/models/transaction/slack.rb +++ b/app/models/transaction/slack.rb @@ -29,7 +29,6 @@ backend.perform def perform return if @item[:object] != 'Ticket' return if !Setting.get('slack_integration') - logo_url = "#{Setting.get('http_type')}://#{Setting.get('fqdn')}/assets/images/#{Setting.get('product_logo')}" config = Setting.get('slack_config') return if !config @@ -115,12 +114,18 @@ backend.perform next if item['group_ids'].to_s != ticket.group_id.to_s end + logo_url = 'https://zammad.com/assets/images/logo-200x200.png' + if !item['logo_url'].empty? + logo_url = item['logo_url'] + end + Rails.logger.debug "sent webhook (#{@item[:type]}/#{ticket.id}/#{item['webhook']})" + notifier = Slack::Notifier.new( item['webhook'], channel: item['channel'], username: item['username'], - #icon_url: logo_url, + icon_url: logo_url, mrkdwn: true, http_client: Transaction::Slack::Client, )