Skip to content
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-5610 notify users when a bookmark or series they have created is hidden #4760

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
29bf722
Create series notification mailer action
walshyb Mar 1, 2024
a7130a0
Create series model admin_hidden update handler
walshyb Mar 1, 2024
ecd02f8
Add series mailer content and en translation
walshyb Mar 1, 2024
c64d3b8
remove unnecessary end
walshyb Mar 1, 2024
611b27d
Add hidden bookmark notification email
walshyb Oct 12, 2024
8d7fe01
Remove explicit html_safe call
walshyb Oct 12, 2024
bc5800f
Merge master
walshyb Oct 12, 2024
9974615
Add hidden bookmark mailer and preview
walshyb Oct 12, 2024
1fbd9eb
Update hidden bookmark mailer locale
walshyb Oct 12, 2024
787407d
Update hidden series mailer locale and add preview
walshyb Oct 12, 2024
87af757
Remove explicit html_safe
walshyb Oct 12, 2024
a67f8c5
Fix incorrect filename
walshyb Oct 12, 2024
0518c97
Remove unnecessary parentheses
walshyb Oct 12, 2024
34558af
Linting fixes
walshyb Oct 12, 2024
65899ff
Merge branch 'master' into AO3-5610-Notify-users-when-a-bookmark-or-s…
walshyb Jan 10, 2025
305d684
Move placement of after_update callback
walshyb Jan 10, 2025
5c300ea
Move after_update callback
walshyb Jan 10, 2025
1224b15
Remove unnecessary single quote
walshyb Jan 10, 2025
208da7d
Create user for hidden bookmark mailer test
walshyb Jan 10, 2025
a079f72
Create user for hidden series mailer test
walshyb Jan 10, 2025
2de2360
Change var from bookmark_url to bookmark_link
walshyb Jan 10, 2025
7251c16
Merge branch 'AO3-5610-Notify-users-when-a-bookmark-or-series-they-ha…
walshyb Jan 10, 2025
695a6ca
Change var from bookmark_url to bookmark_link
walshyb Jan 10, 2025
6b0784a
Update hidden bookmark mailer text to include bookmark title
walshyb Jan 10, 2025
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
12 changes: 12 additions & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ def admin_deleted_work_notification(user, work)
end
end

def admin_hidden_series_notification(creation_id, user_id)
walshyb marked this conversation as resolved.
Show resolved Hide resolved
@user = User.find_by(id: user_id)
@series = Series.find_by(id: creation_id)

I18n.with_locale(@user.preference.locale.iso) do
mail(
to: @user.email,
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME)
walshyb marked this conversation as resolved.
Show resolved Hide resolved
)
end
end

# Sends email to creators when a creation is hidden by an admin
def admin_hidden_work_notification(creation_id, user_id)
@user = User.find_by(id: user_id)
Expand Down
11 changes: 11 additions & 0 deletions app/models/series.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
maximum: ArchiveConfig.TITLE_MAX,
too_long: ts("must be less than %{max} letters long.", max: ArchiveConfig.TITLE_MAX)

after_update :admin_hidden_series_notification, if: :hidden_by_admin_changed?
walshyb marked this conversation as resolved.
Show resolved Hide resolved

# return title.html_safe to overcome escaping done by sanitiser
def title
read_attribute(:title).try(:html_safe)
Expand Down Expand Up @@ -304,4 +306,13 @@
def work_types
works.map(&:work_types).flatten.uniq
end

private

def admin_hidden_series_notification
return unless hidden_by_admin?

Check warning on line 313 in app/models/series.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Add empty line after guard clause. Raw Output: app/models/series.rb:313:5: C: Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
users.each do |user|
UserMailer.send_series_hidden_notification(id, user.id).deliver_later
end
end
end
14 changes: 14 additions & 0 deletions app/views/user_mailer/admin_hidden_series_notification.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% content_for :message do %>
<p><%= t("mailer.general.greeting.formal", name: style_bold(@user.login)).html_safe %></p>

<p><%= t(".html.hidden", title: style_creation_link(@series.title, @series)).html_safe %></p>
walshyb marked this conversation as resolved.
Show resolved Hide resolved

<p><%= t(".access") %></p>

<p><%= t(".check_email") %></p>

<p><%= t(".html.tos_violation", tos_link: tos_link(t ".tos")).html_safe %></p>

Check failure on line 10 in app/views/user_mailer/admin_hidden_series_notification.html.erb

View workflow job for this annotation

GitHub Actions / ERB Lint runner

[] reported by reviewdog 🐶 Style/NestedParenthesizedCalls: Add parentheses to nested method call `t ".tos"`. Raw Output: app/views/user_mailer/admin_hidden_series_notification.html.erb:10:53: Style/NestedParenthesizedCalls: Add parentheses to nested method call `t ".tos"`.
walshyb marked this conversation as resolved.
Show resolved Hide resolved

<p><%= t(".html.help", contact_abuse_link: abuse_link(t ".contact_abuse")).html_safe %></p>

Check failure on line 12 in app/views/user_mailer/admin_hidden_series_notification.html.erb

View workflow job for this annotation

GitHub Actions / ERB Lint runner

[] reported by reviewdog 🐶 Style/NestedParenthesizedCalls: Add parentheses to nested method call `t ".contact_abuse"`. Raw Output: app/views/user_mailer/admin_hidden_series_notification.html.erb:12:56: Style/NestedParenthesizedCalls: Add parentheses to nested method call `t ".contact_abuse"`.
<% end %>

Check failure on line 14 in app/views/user_mailer/admin_hidden_series_notification.html.erb

View workflow job for this annotation

GitHub Actions / ERB Lint runner

[] reported by reviewdog 🐶 Remove multiple trailing newline at the end of the file. Raw Output: app/views/user_mailer/admin_hidden_series_notification.html.erb:14:0: Remove multiple trailing newline at the end of the file.
14 changes: 14 additions & 0 deletions app/views/user_mailer/admin_hidden_series_notification.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% content_for :message do %>
<%= t("mailer.general.greeting.formal", name: @user.login) %>

<%= t(".text.hidden", title: @series.title, series_url: series_url(@series)) %>

<%= t(".access") %>

<%= t(".check_email") %>

<%= t(".text.tos_violation", tos_url: tos_url) %>

<%= t(".text.help", contact_abuse_url: new_abuse_report_url) %>
<% end %>

Loading
Loading