lib/capistrano/ops/notification/slack.rb in capistrano-ops-0.2.2 vs lib/capistrano/ops/notification/slack.rb in capistrano-ops-0.2.3

- old
+ new

@@ -21,34 +21,33 @@ }.to_json response = http.request(request) puts response.body end - def backup_notification(result, date, database, backup_path, notification_level) + def backup_notification(result, title, content, notification_level) return if @slack_secret.nil? || @slack_channel.nil? return if notification_level == 'error' && result uri = URI.parse("#{@slack_base_url}chat.postMessage") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, initHeader = {'Content-Type' =>'application/json', 'Authorization' => 'Bearer ' + @slack_secret}) - message_one = "Backup of #{database} successfully finished at #{Time.now}" - message_two = "Backup path:\`#{backup_path}/#{database}_#{date}.dump\`" + data = { channel: @slack_channel, blocks: [ { type: 'header', text: { type: 'plain_text', - text: ENV['DEFAULT_URL'] || "#{database} Backup", + text: title || "#{Rails.env} Message", emoji: true } }, { type: 'section', text: { type: 'mrkdwn', - text: result ? "#{message_one}\n#{message_two}" : "Backup of #{database} failed at #{Time.now}" + text: content || 'No content' } } ] } request.body = data.to_json