Remove HipChat integration

As of February 15th, HipChat has been declared end-of-life. For more information, see https://community.atlassian.com/t5/Stride-articles/Stride-and-Hipchat-Cloud-have-reached-End-of-Life-updated/ba-p/940248
This commit is contained in:
David Taylor 2019-04-15 17:56:01 +01:00
parent 28b4195467
commit bf30b755cf
6 changed files with 0 additions and 155 deletions

View File

@ -112,22 +112,6 @@ en:
title: Webhook URL
help: The webhook URL created in your Discord server settings
#######################################
########### HIPCHAT STRINGS ###########
#######################################
hipchat:
title: "HipChat"
param:
name:
title: "Name"
help: "A name to describe the channel. It is not used for the connection to HipChat."
webhook_url:
title: Webhook URL
help: The webhook URL created in your HipChat integration
color:
title: Color
help: The colour of the message in HipChat. Must be one of yellow,green,red,purple,gray,random
#######################################
######### MATTERMOST STRINGS ##########
#######################################

View File

@ -32,13 +32,6 @@ en:
chat_integration_discord_message_content: "The message to include above the summary when sending a notification to Discord"
chat_integration_discord_excerpt_length: "Discord post excerpt length"
#######################################
########## HIPCHAT SETTINGS ###########
#######################################
chat_integration_hipchat_enabled: "Enable the Hipchat chat-integration provider"
chat_integration_hipchat_icon_url: "Icon for posts to Hipchat (defaults to forum logo)"
chat_integration_hipchat_excerpt_length: "Hipchat post excerpt length"
#######################################
######## MATTERMOST SETTINGS ##########
#######################################

View File

@ -50,16 +50,6 @@ chat_integration:
chat_integration_discord_excerpt_length:
default: 400
#######################################
########## HIPCHAT SETTINGS ###########
#######################################
chat_integration_hipchat_enabled:
default: false
chat_integration_hipchat_icon_url:
default: ''
chat_integration_hipchat_excerpt_length:
default: 400
#######################################
######## MATTERMOST SETTINGS ##########
#######################################

View File

@ -92,7 +92,6 @@ end
require_relative "provider/slack/slack_provider"
require_relative "provider/telegram/telegram_provider"
require_relative "provider/discord/discord_provider"
require_relative "provider/hipchat/hipchat_provider"
require_relative "provider/mattermost/mattermost_provider"
require_relative "provider/matrix/matrix_provider"
require_relative "provider/zulip/zulip_provider"

View File

@ -1,93 +0,0 @@
module DiscourseChat
module Provider
module HipchatProvider
PROVIDER_NAME = "hipchat".freeze
PROVIDER_ENABLED_SETTING = :chat_integration_hipchat_enabled
CHANNEL_PARAMETERS = [
{ key: "name", regex: '^\S+' },
{ key: "webhook_url", regex: '^\S+$', unique: true, hidden: true },
{ key: "color", regex: '^(yellow|green|red|purple|gray|random)$' }
]
def self.send_message(url, message)
uri = URI(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
req.body = message.to_json
response = http.request(req)
return response
end
def self.generate_hipchat_message(post)
display_name = "@#{post.user.username}"
full_name = post.user.name || ""
if !(full_name.strip.empty?) && (full_name.strip.gsub(' ', '_').casecmp(post.user.username) != 0) && (full_name.strip.gsub(' ', '').casecmp(post.user.username) != 0)
display_name = "#{full_name} @#{post.user.username}"
end
topic = post.topic
message_text = I18n.t(
"chat_integration.provider.hipchat.message",
user: display_name,
post_url: post.full_url,
title: CGI::escapeHTML(topic.title),
)
icon_url =
if SiteSetting.chat_integration_hipchat_icon_url.present?
UrlHelper.absolute(SiteSetting.chat_integration_hipchat_icon_url)
elsif (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?
UrlHelper.absolute(url)
end
message = {
message: message_text, # Fallback for clients that don't support the card markup
notify: true,
card: {
style: "application",
url: post.full_url,
format: "medium",
id: "discoursecard:#{post.id}",
title: topic.title,
description: post.excerpt(SiteSetting.chat_integration_hipchat_excerpt_length, text_entities: true, strip_links: true, remap_emoji: true),
icon: {
url: icon_url,
},
activity: {
html: message_text
}
}
}
return message
end
def self.trigger_notification(post, channel)
webhook_url = channel.data['webhook_url']
message = generate_hipchat_message(post)
message[:color] = channel.data['color']
response = send_message(webhook_url, message)
if !response.kind_of?(Net::HTTPSuccess)
error_key = nil
raise ::DiscourseChat::ProviderError.new info: { error_key: error_key, message: message, response_body: response.body }
end
end
end
end
end

View File

@ -1,28 +0,0 @@
require 'rails_helper'
RSpec.describe DiscourseChat::Provider::HipchatProvider do
let(:post) { Fabricate(:post) }
describe '.trigger_notifications' do
before do
SiteSetting.chat_integration_hipchat_enabled = true
end
let(:chan1) { DiscourseChat::Channel.create!(provider: 'hipchat', data: { name: "Awesome Channel", webhook_url: 'https://blah.hipchat.com/abcd', color: "red" }) }
it 'sends a webhook request' do
stub1 = stub_request(:post, 'https://blah.hipchat.com/abcd').to_return(status: 200)
described_class.trigger_notification(post, chan1)
expect(stub1).to have_been_requested.once
end
it 'handles errors correctly' do
stub1 = stub_request(:post, "https://blah.hipchat.com/abcd").to_return(status: 400)
expect(stub1).to have_been_requested.times(0)
expect { described_class.trigger_notification(post, chan1) }.to raise_exception(::DiscourseChat::ProviderError)
expect(stub1).to have_been_requested.once
end
end
end