Skip to content

Commit 410c44b

Browse files
committed
WIP#374 Handle unsubscribe requests and piggy-back off the old Weekly Digest settings
1 parent 16f1510 commit 410c44b

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

app/controllers/emails_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def unsubscribe
88
elsif params[:email_type] == NotifierMailer::ACTIVITY_EVENT
99
user = User.where(email: params[:recipient]).first
1010
user.update_attribute(:notify_on_award, false)
11-
elsif params[:email_type] == NotifierMailer::WEEKLY_DIGEST_EVENT
11+
elsif params[:email_type] == NotifierMailer::POPULAR_PROTIPS_EVENT
12+
# Piggybacking off the old 'weekly_digest' subscription list
1213
user = User.where(email: params[:recipient]).first
1314
user.update_attribute(:receive_weekly_digest, false)
1415
end
@@ -37,5 +38,4 @@ def mailgun?(api_key, token, timestamp, signature)
3738
def encrypt_signature(api_key, timestamp, token)
3839
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), api_key, '%s%s' % [timestamp, token])
3940
end
40-
4141
end

app/mailers/protip_mailer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ProtipMailer < ActionMailer::Base
1818
}
1919
CAMPAIGN_ID = 'protip_mailer-popular_protips'
2020
ACTIVITY_SUBJECT_PREFIX = '[Coderwall]'
21+
POPULAR_PROTIPS_EVENT = 'coderwall-popular_protips'
2122

2223
#################################################################################
2324
def popular_protips(user, protips, from, to)
@@ -68,7 +69,7 @@ def self.already_sent?(mailable, user)
6869

6970
def campaign_params
7071
{
71-
utm_campaign: 'coderwall-popular_protips',
72+
utm_campaign: POPULAR_PROTIPS_EVENT,
7273
utm_content: Date.today.midnight,
7374
utm_medium: 'email'
7475
}

app/views/protip_mailer/popular_protips.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
%p{style: "color: #c9c9c9; font-size: 12px; #{sans_serif}"}
177177
%preferences{style: "color: #3ca7dd; text-decoration: none;"}>
178178
%strong
179-
%a{href: "https: //coderwall.com/settings#email", style: "color: #3ca7dd; text-decoration: none;"}
179+
%a{ href: 'https://coderwall.com/settings#email', style: 'color: #3ca7dd; text-decoration: none;' }
180180
Edit your subscription
181181
 |  
182182
%unsubscribe{style: "color: #3ca7dd; text-decoration: none;"}

app/workers/protip_mailer_popular_protips_worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def perform(from, to)
1313

1414
fail "Only #{protip_ids.count} protips but expected 10" unless protip_ids.count == 10
1515

16-
User.order('updated_at desc').find_each(batch_size: 100) do |user|
16+
User.receives_digest.order('updated_at desc').find_each(batch_size: 100) do |user|
1717
ProtipMailerPopularProtipsSendWorker.perform_async(user.id, protip_ids, from, to)
1818
end
1919
end

0 commit comments

Comments
 (0)