Added emails for new users who arent PRO

• Added:
- emails for new users who arent PRO
This commit is contained in:
mgabdev 2020-09-18 22:49:15 -05:00
parent e734a0cb38
commit a4add61342
5 changed files with 109 additions and 0 deletions

View File

@ -46,6 +46,29 @@ class UserMailer < Devise::Mailer
mail to: @resource.email, subject: subject
end
end
def introduce_pro(user, date_range)
valid_date_ranges = ['7', '15', '30']
@date_range = date_range
return unless valid_date_ranges.include?(@date_range)
@resource = user
return if @resource.disabled?
subject = 'Gab Is Powered By You'
case @date_range
when '15'
subject = 'The Silicon Valley Alternative'
when '30'
subject = 'Free Speech Software'
end
I18n.with_locale(@resource.locale || I18n.default_locale) do
mail to: @resource.email, subject: subject
end
end
def confirmation_instructions(user, token, **)
@resource = user
@token = token

View File

@ -0,0 +1,34 @@
<%= "Hello " + @resource.account.username %>
<% if @date_range == '7' %>
On Silicon Valley platforms you and your data are the product being sold to big corporate sponsors. At Gab we pride ourselves on being 100% funded by our community and treating every user with the respect and dignity they deserve.
Have you heard about GabPRO yet? Its our optional subscription service that unlocks additional features on the site and helps us fund the development of the platform. GabPRO members can create groups, get verified, schedule posts, and much more.
We hope youll consider supporting our mission of defending free speech online for all people and thank you again for being a valued member of our growing community!
<% elsif @date_range == '15' %>
At Gab we arent just building a social network, we are building an alternative to Silicon Valley tyranny. Our mission is to defend free speech online at all costs and weve certainly paid the price for standing by this mission.
To date Gab has been banned from dozens of services providers including app stores, payment processors, hosting providers, and even VISA. We spent two years building our own infrastructure from the ground up and thanks to the support from our community we made it happen.
Gab is only possible because we have people like you who help us to fund the development and operation of the Gab platform. We hope youll consider upgrading to GabPRO, our optional subscription service, to unlock additional features on Gab and help us defend free speech online for all people. GabPRO members can create groups, get verified, schedule posts, and much more.
Thanks for being a valued member of our growing community!
<% else %>
Gab is a proud American free speech software company. We build technology products with the primary purpose of defending and exporting the uniquely American value of free speech to the entire world.
Gab also follows American privacy law in regards to protecting user data. We believe that privacy is a human right and that the dignity of a sovereign individual should be respected.
We dont just say these things, we actively defend these values everyday. For example we regularly protect the privacy of international Gab users by turning down speech-related data requests and have been banned from dozens of services providers for our values of free speech.
We hope youll consider upgrading to GabPRO to help us defend free speech and protect digital privacy for millions of people around the world. GabPRO unlocks additional features on Gab and helps us fund the operation and development of the platform.
Thank you for being a valued member of the Gab community!
<% end %>
Andrew Torba
CEO, Gab.com
Click Here to learn more and go GabPRO today!
https://pro.gab.com

View File

@ -0,0 +1,21 @@
# frozen_string_literal: true
class IntroduceAccountProWorker
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.introduce_pro(@acct.user, date_range).deliver_now!
@acct.user.touch(:last_emailed_at)
end
end

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
class Scheduler::IntroduceProScheduler
include Sidekiq::Worker
sidekiq_options retry: 1
def perform
new_accounts(8.days.ago, 7.days.ago).find_each do |acct|
IntroduceAccountProWorker.perform_async(acct.id, '7')
end
new_accounts(16.days.ago, 15.days.ago).find_each do |acct|
IntroduceAccountProWorker.perform_async(acct.id, '15')
end
new_accounts(31.days.ago, 30.days.ago).find_each do |acct|
IntroduceAccountProWorker.perform_async(acct.id, '30')
end
end
private
def new_accounts(start_date, end_date)
Account.where('is_pro=FALSE AND pro_expires_at IS NULL AND created_at BETWEEN ? AND ?', start_date, end_date)
end
end

View File

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