Class: Decidim::NotificationsDigestMailer

Inherits:
ApplicationMailer show all
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

Instance Method Details

#digest_mail(user, notification_ids) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'decidim-core/app/mailers/decidim/notifications_digest_mailer.rb', line 11

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
    @notifications = notifications[0...SIZE_LIMIT].map { |notification| Decidim::NotificationToMailerPresenter.new(notification) }

    mail(to: user.email, subject: @notifications_digest.subject)
  end
end