]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/notifier.rb
Set the reported_user in a callback
[rails.git] / app / models / notifier.rb
index 8e386edf84bbcfe2baf78f9c3fc58f91608f2b88..54eb9b41852c71622f772a7fb4894558db31172e 100644 (file)
@@ -4,6 +4,7 @@ class Notifier < ActionMailer::Base
           :auto_submitted => "auto-generated"
   helper :application
   before_action :set_shared_template_vars
+  before_action :attach_project_logo
 
   def signup_confirm(user, token)
     with_recipient_locale user do
@@ -166,6 +167,7 @@ class Notifier < ActionMailer::Base
 
   def changeset_comment_notification(comment, recipient)
     with_recipient_locale recipient do
+      @to_user = recipient.display_name
       @changeset_url = changeset_url(comment.changeset, :host => SERVER_URL)
       @comment = comment.body
       @owner = recipient == comment.changeset.user
@@ -187,15 +189,25 @@ class Notifier < ActionMailer::Base
     end
   end
 
+  def new_issue_notification(issue_id, recipient)
+    with_recipient_locale recipient do
+      @url = url_for(:host => SERVER_URL,
+                     :controller => "issues",
+                     :action => "show",
+                     :id => issue_id)
+      subject = I18n.t("notifier.new_issue_notification.subject")
+      mail :to => recipient.email, :subject => subject
+    end
+  end
+
   private
 
   def set_shared_template_vars
     @root_url = root_url(:host => SERVER_URL)
-    attach_project_logo
   end
 
   def attach_project_logo
-    attachments.inline["logo.png"] = File.read("#{Rails.root}/app/assets/images/osm_logo_30.png")
+    attachments.inline["logo.png"] = File.read(Rails.root.join("app", "assets", "images", "osm_logo_30.png"))
   end
 
   def attach_user_avatar(user)
@@ -207,7 +219,7 @@ class Notifier < ActionMailer::Base
     if image && image.file?
       return image.path(:small)
     else
-      return "#{Rails.root}/app/assets/images/users/images/small.png"
+      return Rails.root.join("app", "assets", "images", "users", "images", "small.png")
     end
   end