Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions app/mailers/gift_exchange_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
class GiftExchangeMailer < ApplicationMailer
def assignment_default_notification(collection_id, assignment_id, email)
@assignment = ChallengeAssignment.find(assignment_id)

return unless @assignment.offer_signup && @assignment.request_signup

@collection = Collection.find(collection_id)
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(
app_name: ArchiveConfig.APP_SHORT_NAME,
collection_title: @collection.title,
offer_byline: @assignment.offering_pseud.byline
)
)
end

def assignments_sent_notification(collection_id, email)
@collection = Collection.find(collection_id)
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME, collection_title: @collection.title)
)
end

def invalid_signup_notification(collection_id, invalid_signup_ids, email)
@collection = Collection.find(collection_id)
@invalid_signups = invalid_signup_ids
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME, collection_title: @collection.title)
)
end

def no_potential_matches_notification(collection_id, email)
@collection = Collection.find(collection_id)
@is_collection_email = (email == @collection.collection_email)
Expand All @@ -7,4 +43,15 @@ def no_potential_matches_notification(collection_id, email)
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME, collection_title: @collection.title)
)
end

# This is sent at the end of matching, i.e., after assignments are generated.
# It is also sent when assignments are regenerated.
def potential_match_generation_notification(collection_id, email)
@collection = Collection.find(collection_id)
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME, collection_title: @collection.title)
)
end
end
47 changes: 0 additions & 47 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,53 +157,6 @@ def invite_request_declined(user_id, total, reason)
)
end

def assignments_sent_notification(collection_id, email)
@collection = Collection.find(collection_id)
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME, collection_title: @collection.title)
)
end

def assignment_default_notification(collection_id, assignment_id, email)
@assignment = ChallengeAssignment.find(assignment_id)

return unless @assignment.offer_signup && @assignment.request_signup

@collection = Collection.find(collection_id)
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(
app_name: ArchiveConfig.APP_SHORT_NAME,
collection_title: @collection.title,
offer_byline: @assignment.offering_pseud.byline
)
)
end

def invalid_signup_notification(collection_id, invalid_signup_ids, email)
@collection = Collection.find(collection_id)
@invalid_signups = invalid_signup_ids
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME, collection_title: @collection.title)
)
end

# This is sent at the end of matching, i.e., after assignments are generated.
# It is also sent when assignments are regenerated.
def potential_match_generation_notification(collection_id, email)
@collection = Collection.find(collection_id)
@is_collection_email = (email == @collection.collection_email)
mail(
to: email,
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME, collection_title: @collection.title)
)
end

def challenge_assignment_notification(collection_id, assigned_user_id, assignment_id)
@collection = Collection.find(collection_id)
@assigned_user = User.find(assigned_user_id)
Expand Down
4 changes: 2 additions & 2 deletions app/models/challenge_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ def self.delayed_generate(collection_id)
end

if collection.collection_email.present?
UserMailer.potential_match_generation_notification(collection.id, collection.collection_email).deliver_later
GiftExchangeMailer.potential_match_generation_notification(collection.id, collection.collection_email).deliver_later
else
collection.maintainers_list.each do |user|
I18n.with_locale(user.preference.locale_for_mails) do
UserMailer.potential_match_generation_notification(collection.id, user.email).deliver_later
GiftExchangeMailer.potential_match_generation_notification(collection.id, user.email).deliver_later
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,25 +326,25 @@ def collection_email

def notify_maintainers_assignments_sent
if self.collection_email.present?
UserMailer.assignments_sent_notification(self.id, self.collection_email).deliver_later
GiftExchangeMailer.assignments_sent_notification(self.id, self.collection_email).deliver_later
else
# if collection email is not set and collection parent email is not set, loop through maintainers and send each a notice via email
self.maintainers_list.each do |user|
I18n.with_locale(user.preference.locale_for_mails) do
UserMailer.assignments_sent_notification(self.id, user.email).deliver_later
GiftExchangeMailer.assignments_sent_notification(self.id, user.email).deliver_later
end
end
end
end

def notify_maintainers_assignment_default(challenge_assignment)
if self.collection_email.present?
UserMailer.assignment_default_notification(self.id, challenge_assignment.id, self.collection_email).deliver_later
GiftExchangeMailer.assignment_default_notification(self.id, challenge_assignment.id, self.collection_email).deliver_later
else
# if collection email is not set and collection parent email is not set, loop through maintainers and send each a notice via email
self.maintainers_list.each do |user|
I18n.with_locale(user.preference.locale_for_mails) do
UserMailer.assignment_default_notification(self.id, challenge_assignment.id, user.email).deliver_later
GiftExchangeMailer.assignment_default_notification(self.id, challenge_assignment.id, user.email).deliver_later
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/potential_match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ def self.generate_in_background(collection_id)
invalid_signup_ids.each { |sid| REDIS_GENERAL.sadd?(invalid_signup_key(collection), sid) }

if collection.collection_email.present?
UserMailer.invalid_signup_notification(collection.id, invalid_signup_ids, collection.collection_email).deliver_later
GiftExchangeMailer.invalid_signup_notification(collection.id, invalid_signup_ids, collection.collection_email).deliver_later
else
collection.maintainers_list.each do |user|
I18n.with_locale(user.preference.locale_for_mails) do
UserMailer.invalid_signup_notification(collection.id, invalid_signup_ids, user.email).deliver_later
GiftExchangeMailer.invalid_signup_notification(collection.id, invalid_signup_ids, user.email).deliver_later
end
end
end
Expand Down
68 changes: 34 additions & 34 deletions config/locales/mailers/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,31 @@ en:
tag: "[%{app_name}] Edited reply to your comment on the tag %{name}"
you_wrote: 'You wrote:'
gift_exchange_mailer:
assignment_default_notification:
assign_pinch_hitter:
collection_assignments_page: collection assignments page
html: You can assign a pinch hitter on the %{collection_assignments_page_link}.
text: 'You can assign a pinch hitter on the collection assignments page: %{collection_assignments_page_url}.'
defaulted_on_assignment:
html: "%{offer_byline} has defaulted on their assignment for %{request_byline} in your gift exchange %{collection_link}."
text: '%{offer_byline} has defaulted on their assignment for %{request_byline} in your gift exchange "%{collection_title}" (%{collection_url}).'
subject: "[%{app_name}][%{collection_title}] Assignment default by %{offer_byline}"
assignments_sent_notification:
all_sent_out:
html: All assignments have now been sent out for your gift exchange %{collection_link}.
text: All assignments have now been sent out for your gift exchange "%{collection_title}" (%{collection_url}).
subject: "[%{app_name}][%{collection_title}] Assignments sent"
invalid_signup_notification:
found_invalid:
html: We have found some invalid sign-ups in your gift exchange %{collection_link}. Potential matches can't be generated until these are cleaned up.
text: We have found some invalid sign-ups in your gift exchange "%{collection_title}" (%{collection_url}). Potential matches can't be generated until these are cleaned up.
see_details:
challenge_matching_help: the challenge matching help
html: Invalid sign-ups may be duplicates, or may not meet the requirements you've set for your challenge. Unfortunately, there is no automatic way to fix them, so you will have to manually edit or delete them. For more details, refer to %{challenge_matching_help_link}.
text: 'Invalid sign-ups may be duplicates, or may not meet the requirements you''ve set for your challenge. Unfortunately, there is no automatic way to fix them, so you will have to manually edit or delete them. For more details, refer to the challenge matching help: %{challenge_matching_help_url}.'
signup: 'Signup #%{signup_id}'
signups_here: 'Here are the invalid sign-ups:'
subject: "[%{app_name}][%{collection_title}] Invalid sign-ups found"
no_potential_matches_notification:
generation_finished:
html: Potential match generation for %{collection_link} has finished. Unfortunately, there were no potential matches found.
Expand All @@ -209,6 +234,15 @@ en:
match_settings: Minimum Number to Match settings
text: Please update your gift exchange's Minimum Number to Match settings (%{match_settings_url}) and try generating potential matches again.
subject: "[%{app_name}][%{collection_title}] No potential matches found"
potential_match_generation_notification:
finished_generating:
html: We have finished generating potential assignments for your gift exchange %{collection_link}.
text: We have finished generating potential assignments for your gift exchange "%{collection_title}" (%{collection_url}).
matches_available:
html: The potential matches and set assignments are available on its %{matching_page_link}.
matching_page: Matching page
text: 'The potential matches and set assignments are available on its Matching page: %{matching_page_url}.'
subject: "[%{app_name}][%{collection_title}] Potential assignment generation complete"
kudo_mailer:
batch_kudo_notification:
guest:
Expand Down Expand Up @@ -412,20 +446,6 @@ en:
work_added:
html: The collection maintainers of %{collection_link} have added your work %{work_link} to their collection!
text: The collection maintainers of "%{collection_title}" (%{collection_url}) have added your work "%{work_title}" (%{work_url}) to their collection!
assignment_default_notification:
assign_pinch_hitter:
collection_assignments_page: collection assignments page
html: You can assign a pinch hitter on the %{collection_assignments_page_link}.
text: 'You can assign a pinch hitter on the collection assignments page: %{collection_assignments_page_url}.'
defaulted_on_assignment:
html: "%{offer_byline} has defaulted on their assignment for %{request_byline} in your gift exchange %{collection_link}."
text: '%{offer_byline} has defaulted on their assignment for %{request_byline} in your gift exchange "%{collection_title}" (%{collection_url}).'
subject: "[%{app_name}][%{collection_title}] Assignment default by %{offer_byline}"
assignments_sent_notification:
all_sent_out:
html: All assignments have now been sent out for your gift exchange %{collection_link}.
text: All assignments have now been sent out for your gift exchange "%{collection_title}" (%{collection_url}).
subject: "[%{app_name}][%{collection_title}] Assignments sent"
batch_subscription_notification:
chapter_summary: Chapter Summary
footer_note:
Expand Down Expand Up @@ -669,17 +689,6 @@ en:
additional_ticket: If you have additional questions or information, do not hesitate to send in another ticket.
introduction: 'We''re working hard to reply to everyone, and we''ll respond to you as soon as we can. Your communication is greatly valued, and it will be reviewed and answered by our volunteer Support team. In the meantime, here is a copy of the information you submitted through the Technical Support and Feedback form:'
subject: "[%{app_name}] Support - %{summary}"
invalid_signup_notification:
found_invalid:
html: We have found some invalid sign-ups in your gift exchange %{collection_link}. Potential matches can't be generated until these are cleaned up.
text: We have found some invalid sign-ups in your gift exchange "%{collection_title}" (%{collection_url}). Potential matches can't be generated until these are cleaned up.
see_details:
challenge_matching_help: the challenge matching help
html: Invalid sign-ups may be duplicates, or may not meet the requirements you've set for your challenge. Unfortunately, there is no automatic way to fix them, so you will have to manually edit or delete them. For more details, refer to %{challenge_matching_help_link}.
text: 'Invalid sign-ups may be duplicates, or may not meet the requirements you''ve set for your challenge. Unfortunately, there is no automatic way to fix them, so you will have to manually edit or delete them. For more details, refer to the challenge matching help: %{challenge_matching_help_url}.'
signup: 'Signup #%{signup_id}'
signups_here: 'Here are the invalid sign-ups:'
subject: "[%{app_name}][%{collection_title}] Invalid sign-ups found"
invitation:
been_invited: You've been invited to join the Archive of Our Own!
features: With an account, you can post fanworks, use bookmarks to keep track of works you enjoyed, receive subscription emails when your favorite creators or works update, customize the way the site looks for you, and more!
Expand Down Expand Up @@ -767,15 +776,6 @@ en:
would_like_to_include:
html: The collection maintainers of %{collection_link} would like to include your work %{work_link} in their collection!
text: The collection maintainers of "%{collection_title}" (%{collection_url}) would like to include your work "%{work_title}" (%{work_url}) in their collection!
potential_match_generation_notification:
finished_generating:
html: We have finished generating potential assignments for your gift exchange %{collection_link}.
text: We have finished generating potential assignments for your gift exchange "%{collection_title}" (%{collection_url}).
matches_available:
html: The potential matches and set assignments are available on its %{matching_page_link}.
matching_page: Matching page
text: 'The potential matches and set assignments are available on its Matching page: %{matching_page_url}.'
subject: "[%{app_name}][%{collection_title}] Potential assignment generation complete"
prompter_notification:
a_response_to_your_prompt:
collection:
Expand Down
Loading
Loading