Commit eb074021 authored by David Eisner's avatar David Eisner Committed by Airat Shigapov

Absolute URLs for Banzai HTML for HipChat

Using "pipeline: :email" gets "only_path: false" into the context to
produce full URLs instead of /namespace/project/...
parent 8e0c8684
...@@ -89,7 +89,7 @@ class HipchatService < Service ...@@ -89,7 +89,7 @@ class HipchatService < Service
end end
def render_line(text) def render_line(text)
Banzai.render(text.lines.first.chomp, project: project, pipeline: :single_line) if text markdown(text.lines.first.chomp, pipeline: :single_line) if text
end end
def create_push_message(push) def create_push_message(push)
...@@ -125,6 +125,20 @@ class HipchatService < Service ...@@ -125,6 +125,20 @@ class HipchatService < Service
message message
end end
def markdown(text, context = {})
if text
context = ({
project: project,
pipeline: :email
}).merge(context)
html = Banzai.render(text, context)
html = Banzai.post_process(html, context)
else
""
end
end
def create_issue_message(data) def create_issue_message(data)
user_name = data[:user][:name] user_name = data[:user][:name]
...@@ -139,9 +153,7 @@ class HipchatService < Service ...@@ -139,9 +153,7 @@ class HipchatService < Service
issue_link = "<a href=\"#{issue_url}\">issue ##{issue_iid}</a>" issue_link = "<a href=\"#{issue_url}\">issue ##{issue_iid}</a>"
message = "#{user_name} #{state} #{issue_link} in #{project_link}: <b>#{title}</b>" message = "#{user_name} #{state} #{issue_link} in #{project_link}: <b>#{title}</b>"
if description message << markdown(description)
message << Banzai.render(note, project: project)
end
message message
end end
...@@ -161,9 +173,7 @@ class HipchatService < Service ...@@ -161,9 +173,7 @@ class HipchatService < Service
message = "#{user_name} #{state} #{merge_request_link} in " \ message = "#{user_name} #{state} #{merge_request_link} in " \
"#{project_link}: <b>#{title}</b>" "#{project_link}: <b>#{title}</b>"
if description message << markdown(description)
message << Banzai.render(note, project: project)
end
message message
end end
...@@ -180,11 +190,13 @@ class HipchatService < Service ...@@ -180,11 +190,13 @@ class HipchatService < Service
note = obj_attr[:note] note = obj_attr[:note]
note_url = obj_attr[:url] note_url = obj_attr[:url]
noteable_type = obj_attr[:noteable_type] noteable_type = obj_attr[:noteable_type]
commit_id = nil
case noteable_type case noteable_type
when "Commit" when "Commit"
commit_attr = HashWithIndifferentAccess.new(data[:commit]) commit_attr = HashWithIndifferentAccess.new(data[:commit])
subject_desc = commit_attr[:id] commit_id = commit_attr[:id]
subject_desc = commit_id
subject_desc = Commit.truncate_sha(subject_desc) subject_desc = Commit.truncate_sha(subject_desc)
subject_type = "commit" subject_type = "commit"
title = format_title(commit_attr[:message]) title = format_title(commit_attr[:message])
...@@ -212,9 +224,7 @@ class HipchatService < Service ...@@ -212,9 +224,7 @@ class HipchatService < Service
message = "#{user_name} commented on #{subject_html} in #{project_link}: " message = "#{user_name} commented on #{subject_html} in #{project_link}: "
message << title message << title
if note message << markdown(note, ref: commit_id)
message << Banzai.render(note, project: project)
end
message message
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