discourse/app/helpers/email_helper.rb
Michael Brown d9a02d1336
Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse""
This reverts commit 20780a1eee.

* SECURITY: re-adds accidentally reverted commit:
  03d26cd6: ensure embed_url contains valid http(s) uri
* when the merge commit e62a85cf was reverted, git chose the 2660c2e2 parent to land on
  instead of the 03d26cd6 parent (which contains security fixes)
2020-05-23 00:56:13 -04:00

47 lines
1.0 KiB
Ruby

# frozen_string_literal: true
require 'erb'
module EmailHelper
def mailing_list_topic(topic, post_count)
render(
partial: partial_for("mailing_list_post"),
locals: { topic: topic, post_count: post_count }
)
end
def mailing_list_topic_text(topic)
url, title = extract_details(topic)
raw(@markdown_linker.create(title, url))
end
def private_topic_title(topic)
I18n.t("system_messages.private_topic_title", id: topic.id)
end
def email_topic_link(topic)
url, title = extract_details(topic)
raw "<a href='#{Discourse.base_url}#{url}' style='color: ##{@anchor_color}'>#{title}</a>"
end
def email_html_template
EmailStyle.new.html.sub('%{email_content}', yield).html_safe
end
protected
def extract_details(topic)
if SiteSetting.private_email?
[topic.slugless_url, private_topic_title(topic)]
else
[topic.relative_url, format_topic_title(topic.title)]
end
end
def partial_for(name)
SiteSetting.private_email? ? "email/secure_#{name}" : "email/#{name}"
end
end