Commit df7612db authored by Luke Duncalfe's avatar Luke Duncalfe

Monkey patch HangoutsChat using a Gitlab::Patch

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61957#note_588685387
parent 68f06a1a
# 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
)
httparty_response.response
# The rest of the integration expects a Net::HTTP response
end
end
prepend GitlabHTTPOverride
end
end
end
HangoutsChat::Sender::HTTP.prepend(Gitlab::Patch::HangoutsChatHTTPOverride)
# frozen_string_literal: true
module Gitlab
module Patch
module HangoutsChatHTTPOverride
attr_reader :uri
# See https://github.com/enzinia/hangouts-chat/blob/6a509f61a56e757f8f417578b393b94423831ff7/lib/hangouts_chat/http.rb
def post(payload)
httparty_response = Gitlab::HTTP.post(
uri,
body: payload.to_json,
headers: { 'Content-Type' => 'application/json' },
parse: nil # Disables automatic response parsing
)
httparty_response.response
# The rest of the integration expects a Net::HTTP response
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment