Added emails for reminding past PRO members to upgrade again

• Added:
- emails for reminding past PRO members to upgrade again
This commit is contained in:
mgabdev 2020-09-18 15:51:24 -05:00
parent 8f57514bc8
commit 8fa3d4d0a9
6 changed files with 177 additions and 0 deletions

View File

@ -17,6 +17,35 @@ class UserMailer < Devise::Mailer
end end
end end
def remind_expired_pro(user, date_range)
@date_range = date_range
valid_date_ranges = ['7', '16', '30', '45', '60', '75', '90']
return unless valid_date_ranges.include?(@date_range)
@resource = user
return if @resource.disabled?
subject = "Renew GabPRO Today"
case @date_range
when '16'
subject = "Gabs Mission"
when '30'
subject = "GabPRO Membership"
when '45'
subject = "Renew GabPRO"
when '60'
subject = "Gab Depends On People Like You"
when '75'
subject = "Free Speech Online Powered By You"
when '90'
subject = "Defend Freedom Online With Us"
end
I18n.with_locale(@resource.locale || I18n.default_locale) do
mail to: @resource.email, subject: subject
end
end
def confirmation_instructions(user, token, **) def confirmation_instructions(user, token, **)
@resource = user @resource = user
@token = token @token = token

View File

@ -0,0 +1,54 @@
%tr
%td{:align => "center", :style => ""}
%h1{:style => "margin:0;font-weight:bold;font-size:20px;color:#444;text-align:center;"}= "Hello " + @resource.account.username
%tr
%td{:align => "center", :cellspacing => "0", :style => "vertical-align:middle"}
%table
%tbody
%tr
%p{:style => "font-size:16px;color:#444;margin:15px 0;text-align:left;"}
%span Your GabPRO membership expired
- if @date_range == '7'
%span last week.
- elsif @date_range == '16'
%span a few weeks ago.
- elsif @date_range == '30'
%span last month.
- elsif @date_range == '45'
%span about a month ago.
- elsif @date_range == '60'
%span two months ago.
- elsif @date_range == '75'
%span a couple months ago.
- elsif @date_range == '90'
%span a few months ago.
- else
%span recently.
%tr
%td{:align => "center", :cellspacing => "0", :style => "vertical-align:middle"}
%table
%tbody
%tr
%p{ :style => "margin:0 0 15px 0;text-align:left;" }
- if ['7', '30', '60'].include?(@date_range)
%span{ :style => "font-size:16px;color:#444;text-align:left;" } Thank you so much for supporting our mission of defending free speech online. We hope you please consider renewing your membership. Gab is 100% funded by people like you.
- elsif ['16', '45', '75'].include?(@date_range)
%span{ :style => "font-size:16px;color:#444;text-align:left;" } Gab is 100% funded by people like you, not special interests or big corporate advertisers. Your GabPRO membership has been expired, but we hope you'll please consider upgrading to GabPRO again today. We depend on people like you to help us keep building and to cover operational costs. Thank you for being a valued member of the Gab community!
- else
%span{ :style => "font-size:16px;color:#444;text-align:left;" } Your GabPRO subscription has been expired for a while now, but we hope you'll please consider upgrading to GabPRO again today. We depend on people like you to help us keep building and to cover operational costs.
%p{ :style => "margin:0 0 15px 0;text-align:left;" }
%span{ :style => "font-size:16px;color:#444;text-align:left;" } If you have any questions or need help with anything please feel free to reach out anytime: support@gab.com
%p{ :style => "margin:0 0 15px 0;text-align:left;" }
%span{ :style => "font-size:16px;color:#444;text-align:left;" } Go to
= link_to "https://pro.gab.com", "https://pro.gab.com", :style => "color:#30CE7D;font-size:16px;font-weight:600;text-decoration:underline;"
%span{ :style => "font-size:16px;color:#444;text-align:left;" } to renew your membership.
%tr
%td{:align => "center", :cellspacing => "0", :style => "vertical-align:middle;padding-top:10px;padding-bottom:30px;"}
%table{ align: 'center', cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td{ :style => "background-color:#30CE7D;height:56px;border-radius:9999px;color:#fff;" }
= link_to "Renew GabPRO", "https://pro.gab.com", :style => "height:56px;padding:20px 30px;text-decoration:none;color:#fff;font-size:16px;margin:0;"

View File

@ -0,0 +1,25 @@
<%= "Hello " + @resource.account.username %>
<% if @date_range == '7' %>
Your GabPRO membership expired last week.
<% elsif @date_range == '16' %>
Your GabPRO membership expired last month.
<% else %>
Your GabPRO membership expired last week.
<% end %>
<% if ['7', '30', '60'].include?(@date_range) %>
Thank you so much for supporting our mission of defending free speech online. We hope you please consider renewing your membership. Gab is 100% funded by people like you.
<% elsif ['16', '45', '75'].include?(@date_range) %>
Gab is 100% funded by people like you, not special interests or big corporate advertisers. Your GabPRO membership has been expired, but we hope you'll please consider upgrading to GabPRO again today. We depend on people like you to help us keep building and to cover operational costs. Thank you for being a valued member of the Gab community!
<% else %>
Your GabPRO subscription has been expired for a while now, but we hope you'll please consider upgrading to GabPRO again today. We depend on people like you to help us keep building and to cover operational costs.
<% end %>
If you have any questions or need help with anything please feel free to reach out anytime: support@gab.com
===
Go to PRO.GAB.COM to renew your membership
https://pro.gab.com

View File

@ -0,0 +1,21 @@
# frozen_string_literal: true
class RemindExpiredAccountProWorker
include Sidekiq::Worker
sidekiq_options queue: 'mailers', retry: 2
attr_reader :user
def perform(acct_id, date_range)
@acct = Account.find(acct_id)
deliver_email(date_range)
end
private
def deliver_email(date_range)
UserMailer.remind_expired_pro(@acct.user, date_range).deliver_now!
@acct.user.touch(:last_emailed_at)
end
end

View File

@ -0,0 +1,45 @@
# frozen_string_literal: true
class Scheduler::RemindExpiredProScheduler
include Sidekiq::Worker
sidekiq_options retry: 1
def perform
expired_accounts(8.days.ago, 7.days.ago).find_each do |acct|
RemindExpiredAccountProWorker.perform_async(acct.id, '7')
end
expired_accounts(17.days.ago, 16.days.ago).find_each do |acct|
RemindExpiredAccountProWorker.perform_async(acct.id, '16')
end
expired_accounts(31.days.ago, 30.days.ago).find_each do |acct|
RemindExpiredAccountProWorker.perform_async(acct.id, '30')
end
expired_accounts(46.days.ago, 45.days.ago).find_each do |acct|
RemindExpiredAccountProWorker.perform_async(acct.id, '45')
end
expired_accounts(61.days.ago, 60.days.ago).find_each do |acct|
RemindExpiredAccountProWorker.perform_async(acct.id, '60')
end
expired_accounts(76.days.ago, 75.days.ago).find_each do |acct|
RemindExpiredAccountProWorker.perform_async(acct.id, '75')
end
expired_accounts(91.days.ago, 90.days.ago).find_each do |acct|
RemindExpiredAccountProWorker.perform_async(acct.id, '90')
end
end
private
def expired_accounts(start_date, end_date)
Account.where('is_pro=FALSE AND pro_expires_at BETWEEN ? AND ?', start_date, end_date)
end
end

View File

@ -6,6 +6,9 @@
- [mailers, 2] - [mailers, 2]
- [pull] - [pull]
:schedule: :schedule:
remind_expired_pro_scheduler:
cron: '0 8 * * *'
class: Scheduler::RemindExpiredProScheduler
expiring_pro_scheduler: expiring_pro_scheduler:
cron: '0 7 * * *' cron: '0 7 * * *'
class: Scheduler::ExpiringProScheduler class: Scheduler::ExpiringProScheduler