-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ails TAN-2224/co sponsors emails
- Loading branch information
Showing
15 changed files
with
432 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...engines/free/email_campaigns/app/mailers/email_campaigns/cosponsor_of_your_idea_mailer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module EmailCampaigns | ||
class CosponsorOfYourIdeaMailer < ApplicationMailer | ||
protected | ||
|
||
def subject | ||
format_message('subject', values: { cosponsorName: event.post_cosponsor_name }) | ||
end | ||
|
||
def header_title | ||
format_message('main_header', values: { cosponsorName: event.post_cosponsor_name }) | ||
end | ||
|
||
private | ||
|
||
def header_message | ||
format_message('event_description', values: { cosponsorName: event.post_cosponsor_name }) | ||
end | ||
|
||
def preheader | ||
format_message('preheader', values: { cosponsorName: event.post_cosponsor_name }) | ||
end | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
...s/free/email_campaigns/app/mailers/email_campaigns/invitation_to_cosponsor_idea_mailer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module EmailCampaigns | ||
class InvitationToCosponsorIdeaMailer < ApplicationMailer | ||
protected | ||
|
||
def subject | ||
format_message('subject') | ||
end | ||
|
||
def header_title | ||
format_message('main_header') | ||
end | ||
|
||
private | ||
|
||
def header_message | ||
format_message('event_description', values: { authorName: event.post_author_name }) | ||
end | ||
|
||
def preheader | ||
format_message('preheader', values: { authorName: event.post_author_name }) | ||
end | ||
end | ||
end |
95 changes: 95 additions & 0 deletions
95
...gines/free/email_campaigns/app/models/email_campaigns/campaigns/cosponsor_of_your_idea.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: email_campaigns_campaigns | ||
# | ||
# id :uuid not null, primary key | ||
# type :string not null | ||
# author_id :uuid | ||
# enabled :boolean | ||
# sender :string | ||
# reply_to :string | ||
# schedule :jsonb | ||
# subject_multiloc :jsonb | ||
# body_multiloc :jsonb | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# deliveries_count :integer default(0), not null | ||
# context_id :uuid | ||
# | ||
# Indexes | ||
# | ||
# index_email_campaigns_campaigns_on_author_id (author_id) | ||
# index_email_campaigns_campaigns_on_context_id (context_id) | ||
# index_email_campaigns_campaigns_on_type (type) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (author_id => users.id) | ||
# | ||
module EmailCampaigns | ||
class Campaigns::CosponsorOfYourIdea < Campaign | ||
include Consentable | ||
include ActivityTriggerable | ||
include RecipientConfigurable | ||
include Disableable | ||
include Trackable | ||
include LifecycleStageRestrictable | ||
allow_lifecycle_stages only: %w[trial active] | ||
|
||
recipient_filter :filter_notification_recipient | ||
|
||
def mailer_class | ||
CosponsorOfYourIdeaMailer | ||
end | ||
|
||
def activity_triggers | ||
{ 'Notifications::CosponsorOfYourIdea' => { 'created' => true } } | ||
end | ||
|
||
def filter_notification_recipient(users_scope, activity:, time: nil) | ||
users_scope.where(id: activity.item.recipient.id) | ||
end | ||
|
||
def self.recipient_role_multiloc_key | ||
'email_campaigns.admin_labels.recipient_role.registered_users' | ||
end | ||
|
||
def self.recipient_segment_multiloc_key | ||
'email_campaigns.admin_labels.recipient_segment.user_who_published_the_proposal' | ||
end | ||
|
||
def self.content_type_multiloc_key | ||
'email_campaigns.admin_labels.content_type.proposals' | ||
end | ||
|
||
def self.trigger_multiloc_key | ||
'email_campaigns.admin_labels.trigger.user_accepts_invitation_to_cosponsor_a_proposal' | ||
end | ||
|
||
def generate_commands(recipient:, activity:) | ||
idea = activity.item.post | ||
cosponsor = activity.item.initiating_user | ||
name_service = UserDisplayNameService.new(AppConfiguration.instance, recipient) | ||
|
||
[{ | ||
event_payload: { | ||
post_title_multiloc: idea.title_multiloc, | ||
post_body_multiloc: idea.body_multiloc, | ||
post_author_name: name_service.display_name!(idea.author), | ||
post_cosponsor_name: name_service.display_name!(cosponsor), | ||
post_url: Frontend::UrlService.new.model_to_url(idea, locale: Locale.new(recipient.locale)), | ||
post_image_medium_url: post_image_medium_url(idea) | ||
} | ||
}] | ||
end | ||
|
||
private | ||
|
||
def post_image_medium_url(idea) | ||
image = idea&.idea_images&.first | ||
image.image.versions[:medium].url if image&.image&.versions | ||
end | ||
end | ||
end |
93 changes: 93 additions & 0 deletions
93
...free/email_campaigns/app/models/email_campaigns/campaigns/invitation_to_cosponsor_idea.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# frozen_string_literal: true | ||
|
||
# == Schema Information | ||
# | ||
# Table name: email_campaigns_campaigns | ||
# | ||
# id :uuid not null, primary key | ||
# type :string not null | ||
# author_id :uuid | ||
# enabled :boolean | ||
# sender :string | ||
# reply_to :string | ||
# schedule :jsonb | ||
# subject_multiloc :jsonb | ||
# body_multiloc :jsonb | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# deliveries_count :integer default(0), not null | ||
# context_id :uuid | ||
# | ||
# Indexes | ||
# | ||
# index_email_campaigns_campaigns_on_author_id (author_id) | ||
# index_email_campaigns_campaigns_on_context_id (context_id) | ||
# index_email_campaigns_campaigns_on_type (type) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (author_id => users.id) | ||
# | ||
module EmailCampaigns | ||
class Campaigns::InvitationToCosponsorIdea < Campaign | ||
include Consentable | ||
include ActivityTriggerable | ||
include RecipientConfigurable | ||
include Disableable | ||
include Trackable | ||
include LifecycleStageRestrictable | ||
allow_lifecycle_stages only: %w[trial active] | ||
|
||
recipient_filter :filter_notification_recipient | ||
|
||
def mailer_class | ||
InvitationToCosponsorIdeaMailer | ||
end | ||
|
||
def activity_triggers | ||
{ 'Notifications::InvitationToCosponsorIdea' => { 'created' => true } } | ||
end | ||
|
||
def filter_notification_recipient(users_scope, activity:, time: nil) | ||
users_scope.where(id: activity.item.recipient.id) | ||
end | ||
|
||
def self.recipient_role_multiloc_key | ||
'email_campaigns.admin_labels.recipient_role.registered_users' | ||
end | ||
|
||
def self.recipient_segment_multiloc_key | ||
'email_campaigns.admin_labels.recipient_segment.user_who_is_invited_to_cosponsor_a_proposal' | ||
end | ||
|
||
def self.content_type_multiloc_key | ||
'email_campaigns.admin_labels.content_type.proposals' | ||
end | ||
|
||
def self.trigger_multiloc_key | ||
'email_campaigns.admin_labels.trigger.user_is_invited_to_cosponsor_a_proposal' | ||
end | ||
|
||
def generate_commands(recipient:, activity:) | ||
idea = activity.item.post | ||
name_service = UserDisplayNameService.new(AppConfiguration.instance, recipient) | ||
|
||
[{ | ||
event_payload: { | ||
post_title_multiloc: idea.title_multiloc, | ||
post_body_multiloc: idea.body_multiloc, | ||
post_author_name: name_service.display_name!(idea.author), | ||
post_url: Frontend::UrlService.new.model_to_url(idea, locale: Locale.new(recipient.locale)), | ||
post_image_medium_url: post_image_medium_url(idea) | ||
} | ||
}] | ||
end | ||
|
||
private | ||
|
||
def post_image_medium_url(idea) | ||
image = idea&.idea_images&.first | ||
image.image.versions[:medium].url if image&.image&.versions | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...mail_campaigns/app/views/email_campaigns/cosponsor_of_your_idea_mailer/campaign_mail.mjml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= render 'email_campaigns/posts/post_with_image', post_image_url: event&.post_image_medium_url, post_title_multiloc: event.post_title_multiloc, post_body_multiloc: event.post_body_multiloc %> | ||
<%= render partial: 'application/cta_button', locals: { href: event.post_url, message: format_message('cta_reply_to', values: { authorName: event.post_author_name }) } %> |
26 changes: 26 additions & 0 deletions
26
...ampaigns/app/views/email_campaigns/invitation_to_cosponsor_idea_mailer/campaign_mail.mjml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<mj-section padding="0 25px 0 25px"> | ||
<mj-column> | ||
<mj-text> | ||
<p><%= format_message('event_description_cosponsoring', escape_html: false) %></p> | ||
</mj-text> | ||
</mj-column> | ||
</mj-section> | ||
|
||
<mj-section padding="0 25px 0 25px"> | ||
<mj-column> | ||
<mj-text> | ||
<p><%= format_message('event_description_before_action', escape_html: false) %></p> | ||
</mj-text> | ||
</mj-column> | ||
</mj-section> | ||
|
||
<mj-section padding="0 25px 0 25px"> | ||
<mj-column> | ||
<mj-text> | ||
<p><%= format_message('event_description_action') %></p> | ||
</mj-text> | ||
</mj-column> | ||
</mj-section> | ||
|
||
<%= render 'email_campaigns/posts/post_with_image', post_image_url: event&.post_image_medium_url, post_title_multiloc: event.post_title_multiloc, post_body_multiloc: event.post_body_multiloc %> | ||
<%= render partial: 'application/cta_button', locals: { href: event.post_url, message: format_message('cta_reply_to', values: { authorName: event.post_author_name }) } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.