|
2 | 2 |
|
3 | 3 | module BetterTogether |
4 | 4 | class EventInvitationNotifier < ApplicationNotifier # rubocop:todo Style/Documentation |
5 | | - deliver_by :action_cable, channel: 'BetterTogether::NotificationsChannel', message: :build_message |
6 | | - deliver_by :email, mailer: 'BetterTogether::EventInvitationsMailer', method: :invite, params: :email_params |
| 5 | + deliver_by :action_cable, channel: 'BetterTogether::NotificationsChannel', message: :build_message, |
| 6 | + queue: :notifications |
| 7 | + deliver_by :email, mailer: 'BetterTogether::EventInvitationsMailer', method: :invite, params: :email_params, |
| 8 | + queue: :mailers |
7 | 9 |
|
8 | | - param :invitation |
| 10 | + required_param :invitation |
9 | 11 |
|
10 | | - notification_methods do |
11 | | - def invitation = params[:invitation] |
12 | | - def event = invitation.invitable |
| 12 | + def event |
| 13 | + params[:invitation].invitable |
13 | 14 | end |
14 | 15 |
|
15 | 16 | def title |
16 | | - I18n.t('better_together.notifications.event_invitation.title', |
17 | | - event_name: event&.name, default: 'You have been invited to an event') |
| 17 | + I18n.with_locale(params[:invitation].locale) do |
| 18 | + I18n.t('better_together.notifications.event_invitation.title', |
| 19 | + event_name: event&.name, default: 'You have been invited to an event') |
| 20 | + end |
18 | 21 | end |
19 | 22 |
|
20 | 23 | def body |
21 | | - I18n.t('better_together.notifications.event_invitation.body', |
22 | | - event_name: event&.name, default: 'Invitation to %<event_name>s') |
| 24 | + I18n.with_locale(params[:invitation].locale) do |
| 25 | + I18n.t('better_together.notifications.event_invitation.body', |
| 26 | + event_name: event&.name, default: 'Invitation to %<event_name>s') |
| 27 | + end |
23 | 28 | end |
24 | 29 |
|
25 | 30 | def build_message(_notification) |
26 | | - { title:, body:, url: invitation.url_for_review } |
| 31 | + { title:, body:, url: params[:invitation].url_for_review } |
27 | 32 | end |
28 | 33 |
|
29 | 34 | def email_params(_notification) |
30 | | - { invitation: } |
| 35 | + params[:invitation] |
31 | 36 | end |
32 | 37 | end |
33 | 38 | end |
0 commit comments