Added ExpiringProScheduler with email for expired GabPRO users

• Added:
- ExpiringProScheduler with email for expired GabPRO users
This commit is contained in:
mgabdev 2020-08-31 19:50:02 -05:00
parent e4e3b2d82c
commit 991dd7a743
8 changed files with 101 additions and 0 deletions

View File

@ -8,6 +8,15 @@ class UserMailer < Devise::Mailer
add_template_helper RoutingHelper
def pro_expired(user)
@resource = user
return if @resource.disabled?
I18n.with_locale(@resource.locale || I18n.default_locale) do
mail to: @resource.email, subject: I18n.t('user_mailer.pro_expired.subject')
end
end
def confirmation_instructions(user, token, **)
@resource = user
@token = token

View File

@ -0,0 +1,30 @@
%tr
%td{:align => "center", :style => ""}
%h1{:style => "margin:0;font-weight:bold;font-size:20px;color:#444;text-align:center;"}= t 'user_mailer.pro_expired.title', name: @resource.account.username, date: @resource.account.pro_expires_at.strftime('%F')
%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;"} Your GabPRO Membership Has Expired
%tr
%td{:align => "center", :cellspacing => "0", :style => "vertical-align:middle"}
%table
%tbody
%tr
%p{ :style => "margin:0 0 15px 0;text-align:left;" }
%span{ :style => "font-size:16px;color:#444;text-align:left;" } Thank you for supporting our mission of defending free speech online. We appreciate your support and hope youll consider extending or renewing your GabPRO membership to help us keep building.
%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,11 @@
<%= t 'user_mailer.pro_expired.title', name: @resource.account.username, date: @resource.account.pro_expires_at.strftime('%F') %>
---
Thank you for supporting our mission of defending free speech online. We appreciate your support and hope youll consider extending or renewing your GabPRO membership to help us keep building.
===
Go to PRO.GAB.COM to renew your membership
https://pro.gab.com

View File

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

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
class Scheduler::ExpiringProScheduler
include Sidekiq::Worker
sidekiq_options retry: 1
def perform
expired_accounts.find_each do |acct|
ExpireAccountProWorker.perform_async(acct.id)
end
end
private
def expired_accounts
Account.where('is_pro=TRUE AND pro_expires_at < ?', Time.now.utc)
end
end

View File

@ -1067,6 +1067,9 @@ en:
explanation_1: Thanks for your patience. We've reviewed your request and verified your account.
explanation_2: The proof you sent has been deleted from our servers completely.
explanation_3: Thank you 🐸
pro_expired:
subject: Your GabPRO Membership Has Expired
title: Hello %{name}, your GabPRO membership has expired on %{date}.
backup_ready:
explanation: You requested a full backup of your Gab Social account. It's now ready for download!
subject: Your archive is ready for download

View File

@ -1000,6 +1000,9 @@ en_GB:
setup: Set up
wrong_code: The entered code was invalid! Are server time and device time correct?
user_mailer:
pro_expired:
subject: Your GabPRO Membership Has Expired
title: Hello %{name}, your GabPRO membership has expired on %{date}.
backup_ready:
explanation: You requested a full backup of your Gab Social account. It's now ready for download!
subject: Your archive is ready for download

View File

@ -6,6 +6,9 @@
- [mailers, 2]
- [pull]
:schedule:
expiring_pro_scheduler:
cron: '0 7 * * *'
class: Scheduler::ExpiringProScheduler
scheduled_statuses_scheduler:
every: '1m'
class: Scheduler::ScheduledStatusesScheduler