Skip to content

Commit

Permalink
AO3-6828 Email users about TOS update and Underage warning rename (#4952
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Bilka2 authored Nov 4, 2024
1 parent 00a9492 commit eb57bf4
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ gem "departure", "~> 6.5"
gem "mail", ">= 2.8"

group :test do
gem "rspec-rails", "~> 4.0.1"
gem "rspec-rails", "~> 6.0"
gem 'pickle'
gem 'shoulda'
gem "capybara"
Expand Down
42 changes: 21 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ GEM
bigdecimal (3.1.6)
brakeman (6.1.2)
racc
builder (3.2.4)
builder (3.3.0)
bullet (7.1.6)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
Expand Down Expand Up @@ -257,7 +257,7 @@ GEM
rainbow
rubocop
smart_properties
erubi (1.12.0)
erubi (1.13.0)
escape_utils (1.2.1)
et-orbi (1.2.11)
tzinfo
Expand Down Expand Up @@ -359,13 +359,13 @@ GEM
rubyntlm (~> 0.6, >= 0.6.3)
webrick (~> 1.7)
webrobots (~> 0.1.2)
method_source (1.0.0)
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0206)
mini_mime (1.1.2)
mini_portile2 (2.8.7)
minitest (5.22.2)
minitest (5.25.1)
mono_logger (1.1.2)
multi_json (1.15.0)
multi_test (1.1.0)
Expand Down Expand Up @@ -397,7 +397,7 @@ GEM
netrc (0.11.0)
nio4r (2.7.0)
nkf (0.2.0)
nokogiri (1.16.5)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
orm_adapter (0.5.0)
Expand Down Expand Up @@ -426,8 +426,8 @@ GEM
pundit (2.3.1)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.0)
rack (2.2.8.1)
racc (1.8.1)
rack (2.2.9)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-dev-mark (0.8.0)
Expand Down Expand Up @@ -474,7 +474,7 @@ GEM
zeitwerk (~> 2.5)
rainbow (3.1.1)
raindrops (0.20.1)
rake (13.1.0)
rake (13.2.1)
redis (3.3.5)
redis-namespace (1.8.2)
redis (>= 3.0.4)
Expand Down Expand Up @@ -504,20 +504,20 @@ GEM
rollout (2.4.3)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
rspec-expectations (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (4.0.2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-rails (6.1.5)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.1)
rubocop (1.22.3)
parallel (~> 1.10)
Expand Down Expand Up @@ -596,7 +596,7 @@ GEM
climate_control
test-unit (3.6.2)
power_assert
thor (1.3.1)
thor (1.3.2)
tilt (2.3.0)
timecop (0.9.8)
timeliness (0.4.5)
Expand Down Expand Up @@ -633,7 +633,7 @@ GEM
will_paginate (4.0.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.13)
zeitwerk (2.6.18)

PLATFORMS
ruby
Expand Down Expand Up @@ -712,7 +712,7 @@ DEPENDENCIES
resque-scheduler
rest-client (~> 2.1.0)
rollout
rspec-rails (~> 4.0.1)
rspec-rails (~> 6.0)
rubocop (= 1.22.3)
rubocop-rails (= 2.12.4)
rubocop-rspec (= 2.6.0)
Expand Down
11 changes: 11 additions & 0 deletions app/mailers/tos_update_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class TosUpdateMailer < ApplicationMailer
# Sent by notifications:send_tos_update
def tos_update_notification(user, admin_post_id)
@username = user.login
@admin_post = admin_post_id
mail(
to: user.email,
subject: "[#{ArchiveConfig.APP_SHORT_NAME}] Updates to #{ArchiveConfig.APP_SHORT_NAME}'s Terms of Service"
)
end
end
16 changes: 16 additions & 0 deletions app/views/tos_update_mailer/tos_update_notification.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% content_for :message do %>
<p><%= t("mailer.general.greeting.formal_html", name: style_bold(@username)) %></p>

<p>In order to make AO3's rules clearer to our users, we intend to update the AO3 Terms of Service (TOS) later this year. Once this occurs, you will need to agree to the updated TOS in order to continue using AO3.</p>

<p>Here are the highlights of the changes in the 2024 version of the TOS:</p>

<ul><li>We've clarified the Content Policy, but we haven't changed what works are or are not allowed. <%= style_bold("If your fanwork was allowed on AO3 before, then it is still allowed.") %></li>
<li>The TOS has been split into three pages (General Principles, Content Policy, and Privacy Policy). This should make it easier to find what you're looking for when you want to know about a specific part of the TOS.</li>
<li>We've simplified the language throughout the TOS and removed redundant or overly specific phrases and passages. When longer explanations would help to provide clarity, we've added new questions to the TOS FAQ instead.</li>
<li>We've updated the descriptions of how we and our subprocessors collect and process user information (including personal information) in the Privacy Policy.</li>
<li>The Abuse Policy has been generalized to provide the AO3 Policy & Abuse committee with greater flexibility to determine how to address TOS violations, while still providing protections for fanworks in accordance with AO3's mission.</li>
<li>The "Underage" Archive Warning, which is used for works that depict or describe underage sex, will be renamed to "Underage Sex". This does not change the meaning of this warning or how it is enforced. When the TOS update occurs, <%= style_bold('all works with the "Underage" Archive Warning will be recategorized automatically to display the new "Underage Sex" Archive Warning label instead.') %> If you have a work that carries the "Underage" warning and you don't want it to display the "Underage Sex" label, you can replace it with the "Creator Chose Not to Use Archive Warnings" label at any time.</li></ul>

<p>You can learn more about the intended changes, access the full draft text, ask questions, and provide public feedback by visiting our <%= style_link(style_bold("news post about the 2024 Terms of Service updates"), admin_post_url(@admin_post)) %>.</p>
<% end %>
16 changes: 16 additions & 0 deletions app/views/tos_update_mailer/tos_update_notification.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% content_for :message do %>
<%= t("mailer.general.greeting.formal_html", name: @username) %>

In order to make AO3's rules clearer to our users, we intend to update the AO3 Terms of Service (TOS) later this year. Once this occurs, you will need to agree to the updated TOS in order to continue using AO3.

Here are the highlights of the changes in the 2024 version of the TOS:

- We've clarified the Content Policy, but we haven't changed what works are or are not allowed. If your fanwork was allowed on AO3 before, then it is still allowed.
- The TOS has been split into three pages (General Principles, Content Policy, and Privacy Policy). This should make it easier to find what you're looking for when you want to know about a specific part of the TOS.
- We've simplified the language throughout the TOS and removed redundant or overly specific phrases and passages. When longer explanations would help to provide clarity, we've added new questions to the TOS FAQ instead.
- We've updated the descriptions of how we and our subprocessors collect and process user information (including personal information) in the Privacy Policy.
- The Abuse Policy has been generalized to provide the AO3 Policy & Abuse committee with greater flexibility to determine how to address TOS violations, while still providing protections for fanworks in accordance with AO3's mission.
- The "Underage" Archive Warning, which is used for works that depict or describe underage sex, will be renamed to "Underage Sex". This does not change the meaning of this warning or how it is enforced. When the TOS update occurs, all works with the "Underage" Archive Warning will be recategorized automatically to display the new "Underage Sex" Archive Warning label instead. If you have a work that carries the "Underage" warning and you don't want it to display the "Underage Sex" label, you can replace it with the "Creator Chose Not to Use Archive Warnings" label at any time.

You can learn more about the intended changes, access the full draft text, ask questions, and provide public feedback by visiting our news post about the 2024 Terms of Service updates: <%= admin_post_url(@admin_post) %>.
<% end %>
26 changes: 22 additions & 4 deletions lib/tasks/notifications.rake
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
namespace :notifications do

desc "Send next set of kudos notifications"
task(:deliver_kudos => :environment) do
task(deliver_kudos: :environment) do
RedisMailQueue.deliver_kudos
end

desc "Send next set of subscription notifications"
task(:deliver_subscriptions => :environment) do
task(deliver_subscriptions: :environment) do
RedisMailQueue.deliver_subscriptions
end

end

# Usage with 10473 as admin post id: rails notifications:send_tos_update[10473]
desc "Send TOS Update notification to all users"
task(:send_tos_update, [:admin_post_id] => [:environment]) do |_t, args|
total_users = User.all.size
total_batches = (total_users + 999) / 1000
puts "Notifying #{total_users} users in #{total_batches} batches"

User.find_in_batches.with_index do |batch, index|
batch.each do |user|
TosUpdateMailer.tos_update_notification(user, args.admin_post_id).deliver_later(queue: :tos_update)
end

batch_number = index + 1
progress_msg = "Batch #{batch_number} of #{total_batches} complete"
puts(progress_msg) && $stdout.flush
end
puts && $stdout.flush
end
end
27 changes: 27 additions & 0 deletions spec/lib/tasks/notifications.rake_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "spec_helper"

describe "rake notifications:send_tos_update" do
let(:admin_post) { create(:admin_post) }

context "with one user" do
let!(:user) { create(:user) }

it "enqueues one tos update notifications" do
ActiveJob::Base.queue_adapter = :test
expect(User.all.size).to eq(1)
expect { subject.invoke(admin_post.id) }
.to have_enqueued_mail(TosUpdateMailer, :tos_update_notification).on_queue(:tos_update).with(user, admin_post.id)
end
end

context "with multiple users" do
before { create_list(:user, 10) }

it "enqueues multiple tos update notifications" do
ActiveJob::Base.queue_adapter = :test
expect(User.all.size).to eq(10)
expect { subject.invoke(admin_post.id) }
.to have_enqueued_mail(TosUpdateMailer, :tos_update_notification).on_queue(:tos_update).with(instance_of(User), admin_post.id).exactly(10)
end
end
end
38 changes: 38 additions & 0 deletions spec/mailers/tos_update_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require "spec_helper"

describe TosUpdateMailer do
describe "#tos_update_notification" do
let(:user) { create(:user) }
let(:admin_post) { create(:admin_post) }
let(:email) { TosUpdateMailer.tos_update_notification(user, admin_post.id) }

it_behaves_like "an email with a valid sender"
it_behaves_like "a multipart email"
it_behaves_like "a translated email"

it "has the correct subject line" do
subject = "[#{ArchiveConfig.APP_SHORT_NAME}] Updates to #{ArchiveConfig.APP_SHORT_NAME}'s Terms of Service"
expect(email).to have_subject(subject)
end

it "delivers to the correct address" do
expect(email).to deliver_to(user.email)
end

describe "HTML version" do
it "has the correct content" do
expect(email).to have_html_part_content("are or are not allowed. <b")
expect(email).to have_html_part_content(">If your fanwork was allowed on AO3 before, then it is still allowed.</b>")
expect(email).to have_html_part_content("href=\"#{admin_post_url(admin_post)}\"><b")
expect(email).to have_html_part_content(">news post about the 2024 Terms of Service updates</b></a>")
end
end

describe "text version" do
it "has the correct content" do
expect(email).to have_text_part_content("are or are not allowed. If your fanwork was allowed on AO3 before, then it is still allowed.")
expect(email).to have_text_part_content("news post about the 2024 Terms of Service updates: #{admin_post_url(admin_post)}")
end
end
end
end
8 changes: 8 additions & 0 deletions test/mailers/previews/tos_update_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class TosUpdateMailerPreview < ApplicationMailerPreview
# Sent by notifications:send_tos_update
def tos_update_notification
user = create(:user, :for_mailer_preview)
admin_post = create(:admin_post)
TosUpdateMailer.tos_update_notification(user, admin_post.id)
end
end

0 comments on commit eb57bf4

Please sign in to comment.