Commit 857852ce authored by Marin Jankovski's avatar Marin Jankovski

Set action on issue/mr creation mail.

parent d65f2bad
...@@ -2,14 +2,16 @@ module EmailsHelper ...@@ -2,14 +2,16 @@ module EmailsHelper
# Google Actions # Google Actions
# https://developers.google.com/gmail/markup/reference/go-to-action # https://developers.google.com/gmail/markup/reference/go-to-action
def email_action(options) def email_action(url)
name = action_title(url)
if name
data = { data = {
"@context" => "http://schema.org", "@context" => "http://schema.org",
"@type" => "EmailMessage", "@type" => "EmailMessage",
"action" => { "action" => {
"@type" => "ViewAction", "@type" => "ViewAction",
"name" => options[:name], "name" => name,
"url" => options[:url], "url" => url,
} }
} }
...@@ -17,4 +19,14 @@ module EmailsHelper ...@@ -17,4 +19,14 @@ module EmailsHelper
data.to_json.html_safe data.to_json.html_safe
end end
end end
end
def action_title(url)
return unless url
["merge_requests", "issues", "commit"].each do |action|
if url.split("/").include?(action)
return "View #{action.humanize.singularize}"
end
end
end
end end
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
You're receiving this notification because you are a member of the #{link_to_unless @target_url, @project.name_with_namespace, project_url(@project)} project team. You're receiving this notification because you are a member of the #{link_to_unless @target_url, @project.name_with_namespace, project_url(@project)} project team.
- if @target_url - if @target_url
#{link_to "View it on GitLab", @target_url} #{link_to "View it on GitLab", @target_url}
= email_action name: "View #{@note.noteable_type.underscore.humanize}", url: @target_url = email_action @target_url
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