-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-6268 Fix All challenge owners/moderators get CCed in "Assignments sent" notification #4912
base: master
Are you sure you want to change the base?
Changes from all commits
25e6ed1
fdfca33
c8d8fe2
7fb0d0b
7b51ffd
d4da2da
1f0242e
f9e91ce
5e92d68
a4f6c63
85681cb
13bd956
cde3a74
047a875
450dbeb
c28acc5
ec338b0
e05c37b
ff9a9c0
e86c8a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,9 +30,9 @@ | |
@work = Work.find(work_id) | ||
@collection = Collection.find(collection_id) | ||
mail( | ||
to: @user.email, | ||
subject: "[#{ArchiveConfig.APP_SHORT_NAME}]#{'[' + @collection.title + ']'} Request to include work in a collection" | ||
) | ||
to: @user.email, | ||
subject: "[#{ArchiveConfig.APP_SHORT_NAME}]#{'[' + @collection.title + ']'} Request to include work in a collection" | ||
Check warning on line 34 in app/mailers/user_mailer.rb GitHub Actions / Rubocop
|
||
) | ||
end | ||
|
||
# We use an options hash here, instead of keyword arguments, to avoid | ||
|
@@ -72,7 +72,7 @@ | |
# TODO refactor to make it asynchronous | ||
def invitation(invitation_id) | ||
@invitation = Invitation.find(invitation_id) | ||
@user_name = (@invitation.creator.is_a?(User) ? @invitation.creator.login : '') | ||
@user_name = (@invitation.creator.is_a?(User) ? @invitation.creator.login : "") | ||
mail( | ||
to: @invitation.invitee_email, | ||
subject: t("user_mailer.invitation.subject", app_name: ArchiveConfig.APP_SHORT_NAME) | ||
|
@@ -116,20 +116,22 @@ | |
# then the resque job does not error and we just silently fail. | ||
@subscription = Subscription.find_by(id: subscription_id) | ||
return if @subscription.nil? | ||
|
||
creation_entries = JSON.parse(entries) | ||
@creations = [] | ||
# look up all the creations that have generated updates for this subscription | ||
creation_entries.each do |creation_info| | ||
creation_type, creation_id = creation_info.split("_") | ||
creation = creation_type.constantize.where(id: creation_id).first | ||
next unless creation && creation.try(:posted) | ||
next if (creation.is_a?(Chapter) && !creation.work.try(:posted)) | ||
next if creation.pseuds.any? {|p| p.user == User.orphan_account} # no notifications for orphan works | ||
next if creation.is_a?(Chapter) && !creation.work.try(:posted) | ||
next if creation.pseuds.any? { |p| p.user == User.orphan_account } # no notifications for orphan works | ||
|
||
# TODO: allow subscriptions to orphan_account to receive notifications | ||
|
||
# If the subscription notification is for a user subscription, we don't | ||
# want to send updates about works that have recently become anonymous. | ||
if @subscription.subscribable_type == 'User' | ||
if @subscription.subscribable_type == "User" | ||
next if Subscription.anonymous_creation?(creation) | ||
end | ||
|
||
|
@@ -142,9 +144,7 @@ | |
@creations.uniq! | ||
|
||
subject = @subscription.subject_text(@creations.first) | ||
if @creations.count > 1 | ||
subject += " and #{@creations.count - 1} more" | ||
end | ||
subject += " and #{@creations.count - 1} more" if @creations.count > 1 | ||
I18n.with_locale(@subscription.user.preference.locale.iso) do | ||
mail( | ||
to: @subscription.user.email, | ||
|
@@ -160,7 +160,7 @@ | |
I18n.with_locale(@user.preference.locale.iso) do | ||
mail( | ||
to: @user.email, | ||
subject: "#{t 'user_mailer.invite_increase_notification.subject', app_name: ArchiveConfig.APP_SHORT_NAME}" | ||
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME) | ||
) | ||
end | ||
end | ||
|
@@ -173,37 +173,35 @@ | |
I18n.with_locale(@user.preference.locale.iso) do | ||
mail( | ||
to: @user.email, | ||
subject: t('user_mailer.invite_request_declined.subject', app_name: ArchiveConfig.APP_SHORT_NAME) | ||
subject: t("user_mailer.invite_request_declined.subject", app_name: ArchiveConfig.APP_SHORT_NAME) | ||
) | ||
end | ||
end | ||
|
||
# TODO: This may be sent to multiple users simultaneously. We need to ensure | ||
# each user gets the email for their preferred locale. | ||
def collection_notification(collection_id, subject, message) | ||
def collection_notification(collection_id, subject, message, email) | ||
@message = message | ||
@collection = Collection.find(collection_id) | ||
mail( | ||
to: @collection.get_maintainers_email, | ||
to: email, | ||
subject: "[#{ArchiveConfig.APP_SHORT_NAME}][#{@collection.title}] #{subject}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Regarding your comment on Jira, this is the related issue: The subject locale should include the whole string with the placeholders for the short_name and the collection title, not just the last part. But not relevant for this PR.) |
||
) | ||
end | ||
|
||
def invalid_signup_notification(collection_id, invalid_signup_ids) | ||
def invalid_signup_notification(collection_id, invalid_signup_ids, email) | ||
@collection = Collection.find(collection_id) | ||
@invalid_signups = invalid_signup_ids | ||
mail( | ||
to: @collection.get_maintainers_email, | ||
to: email, | ||
subject: "[#{ArchiveConfig.APP_SHORT_NAME}][#{@collection.title}] Invalid sign-ups found" | ||
) | ||
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) | ||
def potential_match_generation_notification(collection_id, email) | ||
@collection = Collection.find(collection_id) | ||
mail( | ||
to: @collection.get_maintainers_email, | ||
to: email, | ||
subject: "[#{ArchiveConfig.APP_SHORT_NAME}][#{@collection.title}] Potential assignment generation complete" | ||
) | ||
end | ||
|
@@ -227,7 +225,7 @@ | |
I18n.with_locale(@user.preference.locale.iso) do | ||
mail( | ||
to: @user.email, | ||
subject: t('user_mailer.signup_notification.subject', app_name: ArchiveConfig.APP_SHORT_NAME) | ||
subject: t("user_mailer.signup_notification.subject", app_name: ArchiveConfig.APP_SHORT_NAME) | ||
) | ||
end | ||
end | ||
|
@@ -240,7 +238,7 @@ | |
I18n.with_locale(@user.preference.locale.iso) do | ||
mail( | ||
to: @old_email, | ||
subject: t('user_mailer.change_email.subject', app_name: ArchiveConfig.APP_SHORT_NAME) | ||
subject: t("user_mailer.change_email.subject", app_name: ArchiveConfig.APP_SHORT_NAME) | ||
) | ||
end | ||
end | ||
|
@@ -322,7 +320,7 @@ | |
end | ||
|
||
# Emails a prompter to say that a response has been posted to their prompt | ||
def prompter_notification(work_id, collection_id=nil) | ||
def prompter_notification(work_id, collection_id = nil) | ||
@work = Work.find(work_id) | ||
@collection = Collection.find(collection_id) if collection_id | ||
@work.challenge_claims.each do |claim| | ||
|
@@ -351,7 +349,7 @@ | |
I18n.with_locale(@user.preference.locale.iso) do | ||
mail( | ||
to: user.email, | ||
subject: t('user_mailer.delete_work_notification.subject', app_name: ArchiveConfig.APP_SHORT_NAME) | ||
subject: t("user_mailer.delete_work_notification.subject", app_name: ArchiveConfig.APP_SHORT_NAME) | ||
) | ||
end | ||
end | ||
|
@@ -371,7 +369,7 @@ | |
I18n.with_locale(@user.preference.locale.iso) do | ||
mail( | ||
to: user.email, | ||
subject: t('user_mailer.admin_deleted_work_notification.subject', app_name: ArchiveConfig.APP_SHORT_NAME) | ||
subject: t("user_mailer.admin_deleted_work_notification.subject", app_name: ArchiveConfig.APP_SHORT_NAME) | ||
) | ||
end | ||
end | ||
|
@@ -394,8 +392,8 @@ | |
@work = Work.find_by(id: creation_id) | ||
|
||
mail( | ||
to: @user.email, | ||
subject: "[#{ArchiveConfig.APP_SHORT_NAME}] Your work was hidden as spam" | ||
to: @user.email, | ||
subject: "[#{ArchiveConfig.APP_SHORT_NAME}] Your work was hidden as spam" | ||
) | ||
end | ||
|
||
|
@@ -405,6 +403,7 @@ | |
def feedback(feedback_id) | ||
feedback = Feedback.find(feedback_id) | ||
return unless feedback.email | ||
|
||
@summary = feedback.summary | ||
@comment = feedback.comment | ||
@username = feedback.username if feedback.username.present? | ||
|
@@ -428,6 +427,4 @@ | |
) | ||
end | ||
|
||
protected | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be easier to avoid this specific rabbithole of rubocop warnings from reviewdog by not changing this unrelated bit of code at all.