Skip to content

Commit f5f65a8

Browse files
committed
Merge pull request #208 from just3ws/master
WIP#374 Handle unsubscribes
2 parents e4c93c1 + 410c44b commit f5f65a8

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

Gemfile.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
GIT
2+
remote: git://github.com/emberjs/ember-rails.git
3+
revision: 5e5a398f3c67c3a3b84b7513b93b22bf81055cc9
4+
specs:
5+
ember-rails (0.15.0)
6+
active_model_serializers
7+
barber (>= 0.4.1)
8+
ember-data-source (>= 1.0.0.beta.5)
9+
ember-source (>= 1.1.0)
10+
execjs (>= 1.2)
11+
handlebars-source (> 1.0.0)
12+
jquery-rails (>= 1.0.17)
13+
railties (>= 3.1)
14+
115
GIT
216
remote: git://github.com/nixme/jazz_hands.git
317
revision: 5e4b48f145883ecb14b55bf04eacc28ac9662676
@@ -24,20 +38,6 @@ GIT
2438
mime-types (>= 1.25, < 3.0)
2539
rest-client (~> 1.4)
2640

27-
GIT
28-
remote: git://github.com/emberjs/ember-rails.git
29-
revision: 5e5a398f3c67c3a3b84b7513b93b22bf81055cc9
30-
specs:
31-
ember-rails (0.15.0)
32-
active_model_serializers
33-
barber (>= 0.4.1)
34-
ember-data-source (>= 1.0.0.beta.5)
35-
ember-source (>= 1.1.0)
36-
execjs (>= 1.2)
37-
handlebars-source (> 1.0.0)
38-
jquery-rails (>= 1.0.17)
39-
railties (>= 3.1)
40-
4141
GEM
4242
remote: https://rubygems.org/
4343
remote: https://rails-assets.org/

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)