diff options
author | Hordur Freyr Yngvason <hfyngvason@gitlab.com> | 2019-09-27 14:35:37 +0300 |
---|---|---|
committer | Hordur Freyr Yngvason <hfyngvason@gitlab.com> | 2019-11-04 18:14:34 +0300 |
commit | cd39502d5911bdcd0d6e4162d12e990d0f643486 (patch) | |
tree | b27949c0513e406ce3e2fa7ebf0590eeff816599 /config | |
parent | 393a5bdafa26459006982869ee779825aadf4add (diff) |
Use Gitlab::HTTP for all chat notifications
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/hangouts_chat_http_override.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/config/initializers/hangouts_chat_http_override.rb b/config/initializers/hangouts_chat_http_override.rb new file mode 100644 index 00000000000..4fd886697e4 --- /dev/null +++ b/config/initializers/hangouts_chat_http_override.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module HangoutsChat + class Sender + class HTTP + module GitlabHTTPOverride + extend ::Gitlab::Utils::Override + + attr_reader :uri + + # see https://github.com/enzinia/hangouts-chat/blob/6a509f61a56e757f8f417578b393b94423831ff7/lib/hangouts_chat/http.rb + override :post + def post(payload) + httparty_response = Gitlab::HTTP.post( + uri, + body: payload.to_json, + headers: { 'Content-Type' => 'application/json' }, + parse: nil # disables automatic response parsing + ) + net_http_response = httparty_response.response + # The rest of the integration expects a Net::HTTP response + net_http_response + end + end + + prepend GitlabHTTPOverride + end + end +end |