-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
184 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
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 |
---|---|---|
|
@@ -76,3 +76,30 @@ docker-compose up -d | |
``` | ||
|
||
Now the application should be running on http://localhost:3000 | ||
|
||
### Seeding data | ||
|
||
``` | ||
TRUNCATE TABLE subscriptions; | ||
TRUNCATE TABLE subscribers; | ||
TRUNCATE TABLE authors; | ||
INSERT INTO authors (secret, email, email_verified, created_at, updated_at) | ||
VALUES | ||
('secret1', '[email protected]', true, NOW(), NOW()), | ||
('secret2', '[email protected]', true, NOW(), NOW()), | ||
('secret3', '[email protected]', true, NOW(), NOW()); | ||
INSERT INTO subscribers (email, created_at, updated_at) | ||
VALUES | ||
('[email protected]', NOW(), NOW()), | ||
('[email protected]', NOW(), NOW()), | ||
('[email protected]', NOW(), NOW()); | ||
INSERT INTO subscriptions (author_id, subscriber_id, token, verified, frequency, created_at, updated_at) | ||
VALUES | ||
(1, 1, 'token1', true, 'daily', NOW(), NOW()), | ||
(2, 2, 'token2', true, 'daily', NOW(), NOW()), | ||
(3, 3, 'token3', true, 'daily', NOW(), NOW()); | ||
``` |
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
10 changes: 10 additions & 0 deletions
10
app/views/subscription_mailer/privacy_policy_update.html.erb
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,10 @@ | ||
<%= react_component("SubscriptionMailerPrivacyUpdate", props: { | ||
subscriber: @subscriber.as_json( | ||
only: :email | ||
), | ||
author: @author.as_json( | ||
only: [], | ||
methods: [:title, :url] | ||
), | ||
unsubscribeUrl: @unsubscribe_url | ||
}) %> |
57 changes: 57 additions & 0 deletions
57
client/app/components/subscription_mailer/PrivacyUpdate.jsx
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,57 @@ | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
|
||
const PrivacyUpdate = ({ subscriber, author, unsubscribeUrl }) => ( | ||
<div> | ||
<p>Hello {subscriber.email},</p> | ||
|
||
<p> | ||
You are currently subscribed to{" "} | ||
<strong> | ||
<a href={author.url}>{author.title}</a> | ||
</strong> | ||
's blog on Listed. | ||
</p> | ||
|
||
<p>We're writing to inform you about an important update to Listed's privacy policy.</p> | ||
|
||
<p> | ||
Starting next week, blog authors will be able to see the email addresses of their subscribers. Learn more about this update at{" "} | ||
<a href="https://listed.to/@Listed/56444/unlocking-subscriber-portability"> | ||
https://listed.to/@Listed/56444/unlocking-subscriber-portability | ||
</a> | ||
. | ||
</p> | ||
|
||
<p>What this means for you:</p> | ||
<ul> | ||
<li> | ||
<a href={author.url}>{author.title}</a> will be able to see your email address ({subscriber.email}) | ||
</li> | ||
<li>This enables direct communication between you and the author</li> | ||
<li>Your email will only be visible to authors whose blogs you're subscribed to</li> | ||
</ul> | ||
|
||
<p> | ||
If you'd prefer not to share your email address with <a href={author.url}>{author.title}</a>, you can | ||
unsubscribe using the link below before this change takes effect. | ||
</p> | ||
|
||
<div className="links-footer"> | ||
<a href={unsubscribeUrl}>Unsubscribe</a> | ||
</div> | ||
</div> | ||
); | ||
|
||
PrivacyUpdate.propTypes = { | ||
subscriber: PropTypes.shape({ | ||
email: PropTypes.string.isRequired, | ||
}).isRequired, | ||
author: PropTypes.shape({ | ||
title: PropTypes.string.isRequired, | ||
url: PropTypes.string.isRequired, | ||
}).isRequired, | ||
unsubscribeUrl: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default PrivacyUpdate; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace :privacy do | ||
desc 'Send privacy policy update emails to all subscribers' | ||
task notify_subscribers: :environment do | ||
# Get all verified and non-unsubscribed subscriptions | ||
subscriptions = Subscription.where(verified: true, unsubscribed: false) | ||
|
||
total = subscriptions.count | ||
current = 0 | ||
|
||
puts "Sending privacy update emails to #{total} subscriptions..." | ||
|
||
subscriptions.find_each do |subscription| | ||
SubscriptionMailer.privacy_policy_update(subscription).deliver_later | ||
current += 1 | ||
|
||
puts "Processed #{current}/#{total} subscriptions..." if current % 100 == 0 | ||
rescue StandardError => e | ||
puts "Error sending to subscription #{subscription.id}: #{e.message}" | ||
end | ||
|
||
puts 'Completed sending privacy update emails' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
namespace :db do | ||
desc "Seed authors and subscriptions" | ||
task seed_authors: :environment do | ||
# Create 3 authors | ||
3.times do |i| | ||
author = Author.create!( | ||
secret: SecureRandom.hex(10), | ||
username: "author#{i}", | ||
display_name: "Author #{i}", | ||
email: "author#{i}@example.com", | ||
email_verified: true, | ||
bio: "This is author #{i}'s bio" | ||
) | ||
|
||
# Create 5 subscribers for each author | ||
5.times do |j| | ||
subscriber = Subscriber.create!( | ||
email: "subscriber#{i}_#{j}@example.com" | ||
) | ||
|
||
# Create verified subscription | ||
Subscription.create!( | ||
author: author, | ||
subscriber: subscriber, | ||
token: SecureRandom.hex(10), | ||
verified: true, | ||
frequency: ['daily', 'weekly'].sample, | ||
last_mailing: DateTime.now - rand(1..10).days | ||
) | ||
end | ||
|
||
# Create some posts for each author | ||
3.times do |k| | ||
Post.create!( | ||
author: author, | ||
title: "Post #{k} by Author #{i}", | ||
text: "This is the content of post #{k}", | ||
token: SecureRandom.hex(10), | ||
published: true, | ||
author_show: true | ||
) | ||
end | ||
end | ||
|
||
puts "Created 3 authors with 5 verified subscribers each and 3 posts each" | ||
end | ||
end |