Initial templates for notifications
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: "from@example.com"
|
||||
default from: "The Fizzy team <support@#{Rails.application.config.hosts.first}>"
|
||||
|
||||
layout "mailer"
|
||||
append_view_path Rails.root.join("app/views/mailers")
|
||||
helper AvatarsHelper, HtmlHelper
|
||||
end
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
class Notification::BundleMailer < ApplicationMailer
|
||||
helper NotificationsHelper
|
||||
|
||||
def notification(bundle)
|
||||
@bundle = bundle
|
||||
@notifications = bundle.notifications
|
||||
|
||||
mail(
|
||||
|
||||
mail \
|
||||
to: bundle.user.email_address,
|
||||
subject: "You have #{@notifications.count} notifications"
|
||||
)
|
||||
subject: "Recent activity in Fizzy"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,9 @@ class Notification::Bundle < ApplicationRecord
|
||||
|
||||
def deliver
|
||||
processing!
|
||||
BundleMailer.notification(self).deliver
|
||||
|
||||
BundleMailer.notification(self).deliver if has_unread_notifications?
|
||||
|
||||
delivered!
|
||||
end
|
||||
|
||||
@@ -48,4 +50,8 @@ class Notification::Bundle < ApplicationRecord
|
||||
def window
|
||||
starts_at..ends_at
|
||||
end
|
||||
|
||||
def has_unread_notifications?
|
||||
notifications.unread.any?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<%= render "notification/bundle_mailer/notification/#{notification.source_type.underscore}/header", notification: notification %>
|
||||
<%= render "notification/bundle_mailer/notification/#{notification.source_type.underscore}/body", notification: notification %>
|
||||
@@ -1,9 +1,5 @@
|
||||
<h2>Your Notifications</h2>
|
||||
<h2>Your Notifications since <%= @bundle.starts_at.strftime("%-l%P on %A, %B %-d") %></h2>
|
||||
|
||||
<p>You have <%= @notifications.count %> notifications:</p>
|
||||
|
||||
<ul>
|
||||
<% @notifications.each do |notification| %>
|
||||
<li>Notification ID: <%= notification.id %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= render partial: "notification/bundle_mailer/notification", collection: @notifications, as: :notification %>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<% event = notification.source %>
|
||||
|
||||
<h3>
|
||||
<%= event_notification_title(event) %>
|
||||
</h3>
|
||||
|
||||
<p>
|
||||
<%= event_notification_body(event) %>
|
||||
</p>
|
||||
@@ -0,0 +1,6 @@
|
||||
<h2> #<%= notification.card.id %> <%= notification.card.collection.name %> </h2>
|
||||
<p>
|
||||
<%= notification.creator.familiar_name %>
|
||||
<%= image_tag user_avatar_url(notification.creator), alt: notification.creator.name, size: 48 %>
|
||||
</p>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<% mention = notification.source %>
|
||||
|
||||
<h3>
|
||||
<%= mention.mentioner.first_name %> mentioned you
|
||||
</h3>
|
||||
|
||||
<p>
|
||||
<%= mention.source.mentionable_content.truncate(200) %>
|
||||
</p>
|
||||
@@ -0,0 +1,6 @@
|
||||
<h2> #<%= notification.card.id %> <%= notification.card.collection.name %> </h2>
|
||||
<p>
|
||||
<%= notification.creator.familiar_name %>
|
||||
<%= image_tag user_avatar_url(notification.creator), alt: notification.creator.name, size: 48 %>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user