Added option for own image_url (app logo image is not possible to use, looks bad in slack).

This commit is contained in:
Martin Edenhofer 2016-04-18 08:38:19 +02:00
parent 94d348d90e
commit 9b22b3679b
2 changed files with 9 additions and 3 deletions

View file

@ -24,9 +24,10 @@ class Index extends App.ControllerIntegrationBase
configureAttributes = [ configureAttributes = [
{ name: 'types', display: 'Trigger', tag: 'checkbox', options: options, 'null': false, class: 'vertical', note: 'Where notification is sent.' }, { 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: '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: '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: '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 = [] settings = []

View file

@ -29,7 +29,6 @@ backend.perform
def perform def perform
return if @item[:object] != 'Ticket' return if @item[:object] != 'Ticket'
return if !Setting.get('slack_integration') 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') config = Setting.get('slack_config')
return if !config return if !config
@ -115,12 +114,18 @@ backend.perform
next if item['group_ids'].to_s != ticket.group_id.to_s next if item['group_ids'].to_s != ticket.group_id.to_s
end 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']})" Rails.logger.debug "sent webhook (#{@item[:type]}/#{ticket.id}/#{item['webhook']})"
notifier = Slack::Notifier.new( notifier = Slack::Notifier.new(
item['webhook'], item['webhook'],
channel: item['channel'], channel: item['channel'],
username: item['username'], username: item['username'],
#icon_url: logo_url, icon_url: logo_url,
mrkdwn: true, mrkdwn: true,
http_client: Transaction::Slack::Client, http_client: Transaction::Slack::Client,
) )