Class: Decidim::NotificationsDigestMailer
- Inherits:
-
ApplicationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- Decidim::NotificationsDigestMailer
- Defined in:
- decidim-core/app/mailers/decidim/notifications_digest_mailer.rb
Overview
A custom mailer for sending notifications to users when a events are received.
Constant Summary collapse
- SIZE_LIMIT =
10
Instance Method Summary collapse
Methods included from OrganizationHelper
#current_organization_name, #organization_colors, #organization_description_label, #organization_name
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods included from SanitizeHelper
#decidim_escape_translated, #decidim_html_escape, #decidim_rich_text, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included
Instance Method Details
#digest_mail(user, notification_ids) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'decidim-core/app/mailers/decidim/notifications_digest_mailer.rb', line 10 def digest_mail(user, notification_ids) with_user(user) do notifications = Decidim::Notification.where(id: notification_ids) @user = user @organization = user.organization @notifications_digest = Decidim::NotificationsDigestPresenter.new(user) @display_see_more_message = notifications.size > SIZE_LIMIT # Note that this could be improved by adding a "type" column to the notifications table # This fix can generate lists of notifications that are below the SIZE_LIMIT @notifications = notifications[0...SIZE_LIMIT].filter_map do |notification| next unless notification.event_class_instance.respond_to?(:email_intro) Decidim::NotificationToMailerPresenter.new(notification) end mail(to: user.email, subject: @notifications_digest.subject) end end |