Skip to content

Instantly share code, notes, and snippets.

@lossendae
Forked from povodok/task.rb
Created February 15, 2018 20:58
Show Gist options
  • Save lossendae/c7f46046f85707c2882e64d7216ee3f1 to your computer and use it in GitHub Desktop.
Save lossendae/c7f46046f85707c2882e64d7216ee3f1 to your computer and use it in GitHub Desktop.
require 'uri'
require 'net/http'
require 'json'
class UpdatesIssuesNotifierListener < Redmine::Hook::Listener
CALLBACK_URL = 'https://localhost:3333'.freeze
def controller_issues_edit_after_save(context)
data = {
'issueid' => context[:issue].id,
'userid' => User.current.id,
'datetime' => context[:issue].updated_on.strftime('%Y-%m-%d %H:%M:%S')
}
uri = URI(CALLBACK_URL)
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
req.body = { 'data' => data }.to_json
Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment