diff options
author | Jonne Haß <me@mrzyx.de> | 2014-03-09 02:49:14 +0400 |
---|---|---|
committer | Jonne Haß <me@mrzyx.de> | 2014-03-15 20:16:17 +0400 |
commit | 8280556a476295f05acdd6dfed15380645a4ea98 (patch) | |
tree | 93edcc8199adb50ce9afa7436ffa80a71ccf6b34 /app/mailers | |
parent | 8f67e1eb174b691d4db58120720589ca39fabb84 (diff) |
Introduce message renderer
This new class replaces all existing server side message
rendering helpers and is the new global entry point for such
needs. All models with relevant fields now expose an instance
of MessageRenderer for those. MessageRenderer acts as
gateway between the existing processing solutions for markdown,
mentions and tags and provides a very flexible interface for
all output needs. This makes the API to obtain a message
in a certain format clear. As a result of centralizing the
processing a lot of duplication is eliminated. Centralizing
the message processing also makes it clear where to change
its behaviour, add new representations and what options
are already available.
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/notification_mailers/also_commented.rb | 6 | ||||
-rw-r--r-- | app/mailers/notification_mailers/base.rb | 2 | ||||
-rw-r--r-- | app/mailers/notification_mailers/comment_on_post.rb | 6 | ||||
-rw-r--r-- | app/mailers/notifier.rb | 5 |
4 files changed, 4 insertions, 15 deletions
diff --git a/app/mailers/notification_mailers/also_commented.rb b/app/mailers/notification_mailers/also_commented.rb index c0957e5aa..d5ef2d3f4 100644 --- a/app/mailers/notification_mailers/also_commented.rb +++ b/app/mailers/notification_mailers/also_commented.rb @@ -1,8 +1,5 @@ module NotificationMailers class AlsoCommented < NotificationMailers::Base - include ActionView::Helpers::TextHelper - include MarkdownifyHelper - attr_accessor :comment delegate :post, to: :comment, prefix: true @@ -11,8 +8,7 @@ module NotificationMailers if mail? @headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" - @headers[:subject] = truncate(strip_markdown(@comment.comment_email_subject.squish), :length => TRUNCATION_LEN) - @headers[:subject] = "Re: #{@headers[:subject]}" + @headers[:subject] = "Re: #{@comment.comment_email_subject}" end end diff --git a/app/mailers/notification_mailers/base.rb b/app/mailers/notification_mailers/base.rb index 06d21ad5d..ec2950bfb 100644 --- a/app/mailers/notification_mailers/base.rb +++ b/app/mailers/notification_mailers/base.rb @@ -1,6 +1,4 @@ module NotificationMailers - TRUNCATION_LEN = 70 - class Base attr_accessor :recipient, :sender diff --git a/app/mailers/notification_mailers/comment_on_post.rb b/app/mailers/notification_mailers/comment_on_post.rb index 18faa2df7..de01804bb 100644 --- a/app/mailers/notification_mailers/comment_on_post.rb +++ b/app/mailers/notification_mailers/comment_on_post.rb @@ -1,16 +1,12 @@ module NotificationMailers class CommentOnPost < NotificationMailers::Base - include ActionView::Helpers::TextHelper - include MarkdownifyHelper - attr_accessor :comment def set_headers(comment_id) @comment = Comment.find(comment_id) @headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" - @headers[:subject] = truncate(strip_markdown(@comment.comment_email_subject.squish), :length => TRUNCATION_LEN) - @headers[:subject] = "Re: #{@headers[:subject]}" + @headers[:subject] = "Re: #{@comment.comment_email_subject}" end end end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index c922f2744..5abce9ee0 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -1,9 +1,8 @@ class Notifier < ActionMailer::Base helper :application - helper :markdownify helper :notifier helper :people - + def self.admin(string, recipients, opts = {}) mails = [] recipients.each do |rec| @@ -16,7 +15,7 @@ class Notifier < ActionMailer::Base def single_admin(string, recipient, opts={}) @receiver = recipient @string = string.html_safe - + if attach = opts.delete(:attachments) attach.each{ |f| attachments[f[:name]] = f[:file] |