Merge branch 'feat/activejob' into rails-v5
This commit is contained in:
commit
27aeb2aae7
183 changed files with 520 additions and 1468 deletions
2
.rspec
2
.rspec
|
@ -1,2 +1,2 @@
|
|||
--color
|
||||
--require spec_helper
|
||||
--require rails_helper
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -5,7 +5,6 @@ source 'https://rubygems.org'
|
|||
ruby '2.5.1'
|
||||
gem 'rails', '~> 5.2.3'
|
||||
gem 'bootsnap', '~> 1.4', require: false # Large rails application booting enhancer
|
||||
gem 'delayed_job_active_record', '~> 4.1'
|
||||
gem 'font_assets', '~> 0.1.14' # for serving fonts on cdn https://github.com/ericallam/font_assets
|
||||
gem 'hamster', '~> 3.0' # Thread-safe collection classes for Ruby
|
||||
gem 'parallel', '~> 1.17' # run processes in parallel
|
||||
|
|
|
@ -153,11 +153,6 @@ GEM
|
|||
debase-ruby_core_source (0.10.5)
|
||||
debug_inspector (0.0.3)
|
||||
deep_merge (1.2.1)
|
||||
delayed_job (4.1.7)
|
||||
activesupport (>= 3.0, < 5.3)
|
||||
delayed_job_active_record (4.1.3)
|
||||
activerecord (>= 3.0, < 5.3)
|
||||
delayed_job (>= 3.0, < 5)
|
||||
descendants_tracker (0.0.4)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
devise (4.6.2)
|
||||
|
@ -519,7 +514,6 @@ DEPENDENCIES
|
|||
countries (~> 3.0)
|
||||
database_cleaner (~> 1.7)
|
||||
debase (~> 0.2.3)
|
||||
delayed_job_active_record (~> 4.1)
|
||||
devise (~> 4.4)
|
||||
devise-async (~> 1.0)
|
||||
dotenv-rails (~> 2.7, >= 2.7.5)
|
||||
|
|
|
@ -6,7 +6,7 @@ class EmailsController < ApplicationController
|
|||
|
||||
def create
|
||||
email = params[:email]
|
||||
GenericMailer.delay.generic_mail(email[:from_email], email[:from_name], email[:message], email[:subject], email[:to_email], email[:to_name])
|
||||
GenericMailer.generic_mail(email[:from_email], email[:from_name], email[:message], email[:subject], email[:to_email], email[:to_name]).deliver_later
|
||||
render json: { notification: 'Email successfully sent' }, status: :created
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ module Nonprofits
|
|||
def resend_confirmation
|
||||
npo = current_nonprofit
|
||||
ba = npo.bank_account
|
||||
NonprofitMailer.delay.new_bank_account_notification(ba) if ba.valid?
|
||||
BankAccountCreateJob.perform_later(ba) if ba.valid?
|
||||
respond_to { |format| format.json { render json: {} } }
|
||||
end
|
||||
|
||||
|
|
|
@ -9,13 +9,7 @@ module Nonprofits
|
|||
# post /nonprofits/:nonprofit_id/imports
|
||||
def create
|
||||
render_json do
|
||||
InsertImport.delay.from_csv_safe(
|
||||
nonprofit_id: import_params[:nonprofit_id],
|
||||
user_id: current_user.id,
|
||||
user_email: current_user.email,
|
||||
file_uri: import_params[:file_uri],
|
||||
header_matches: import_params[:header_matches]
|
||||
)
|
||||
ImportCreationJob.perform_later(import_params, current_user)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ module Nonprofits
|
|||
return
|
||||
end
|
||||
|
||||
DelayedJobHelper.enqueue_job(EmailSupporters, :deliver, [ids, params[:supporter_email]])
|
||||
render json: { count: ids.count }, status: :ok
|
||||
end
|
||||
|
||||
|
|
|
@ -116,3 +116,4 @@ module Nonprofits
|
|||
params.require(:supporter).permit(:name, :address, :city, :state_code, :country, :address_line2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
6
app/jobs/admin_failed_gift_job.rb
Normal file
6
app/jobs/admin_failed_gift_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class AdminFailedGiftJob < EmailJob
|
||||
|
||||
def perform(donation, campaign_gift_option)
|
||||
AdminMailer.notify_failed_gift(donation, campaign_gift_option).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/bank_account_create_job.rb
Normal file
6
app/jobs/bank_account_create_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class BankAccountCreateJob < EmailJob
|
||||
|
||||
def perform(bank_account)
|
||||
NonprofitMailer.new_bank_account_notification(bank_account).deliver_now
|
||||
end
|
||||
end
|
13
app/jobs/campaign_create_job.rb
Normal file
13
app/jobs/campaign_create_job.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class CampaignCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(campaign)
|
||||
if campaign.child_campaign?
|
||||
CampaignCreationFederatedEmailJob.perform_later(campaign)
|
||||
else
|
||||
CampaignCreationEmailFollowupJob.perform_later(campaign)
|
||||
end
|
||||
|
||||
SupporterFundraiserCreateJob.perform_later(campaign)
|
||||
end
|
||||
end
|
6
app/jobs/campaign_creation_email_followup_job.rb
Normal file
6
app/jobs/campaign_creation_email_followup_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class CampaignCreationEmailFollowupJob < EmailJob
|
||||
|
||||
def perform(campaign)
|
||||
CampaignMailer.creation_followup(campaign).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/campaign_creation_federated_email_job.rb
Normal file
6
app/jobs/campaign_creation_federated_email_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class CampaignCreationFederatedEmailJob < EmailJob
|
||||
|
||||
def perform(campaign)
|
||||
CampaignMailer.federated_creation_followup(campaign).deliver_now
|
||||
end
|
||||
end
|
8
app/jobs/direct_debit_create_job.rb
Normal file
8
app/jobs/direct_debit_create_job.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class DirectDebitCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(donation_id, locale)
|
||||
DirectDebitCreateNotifyDonorJob.perform_later donation_id, locale
|
||||
DirectDebitCreateNotifyNonprofitJob.perform_later donation_id, locale
|
||||
end
|
||||
end
|
6
app/jobs/direct_debit_create_notify_donor_job.rb
Normal file
6
app/jobs/direct_debit_create_notify_donor_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class DirectDebitCreateNotifyDonorJob < EmailJob
|
||||
|
||||
def perform(donation_id, locale)
|
||||
DonationMailer.donor_direct_debit_notification(donation_id, locale).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/direct_debit_create_notify_nonprofit_job.rb
Normal file
6
app/jobs/direct_debit_create_notify_nonprofit_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class DirectDebitCreateNotifyNonprofitJob < EmailJob
|
||||
|
||||
def perform(donation_id)
|
||||
DonationMailer.nonprofit_payment_notification(donation_id).deliver_now
|
||||
end
|
||||
end
|
5
app/jobs/email_job.rb
Normal file
5
app/jobs/email_job.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class EmailJob < ApplicationJob
|
||||
queue_as :email_queue
|
||||
|
||||
retry_on Exception, wait: ->(executions) { executions **2.195 }, attempts: MAX_EMAIL_JOB_ATTEMPTS || 1
|
||||
end
|
7
app/jobs/email_list_create_job.rb
Normal file
7
app/jobs/email_list_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class EmailListCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(npo_id)
|
||||
UpdateEmailLists.populate_lists_on_mailchimp(npo_id)
|
||||
end
|
||||
end
|
6
app/jobs/event_create_creator_email_job.rb
Normal file
6
app/jobs/event_create_creator_email_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class EventCreateCreatorEmailJob < EmailJob
|
||||
|
||||
def perform(event)
|
||||
EventMailer.creation_followup(event).deliver_now
|
||||
end
|
||||
end
|
7
app/jobs/event_create_job.rb
Normal file
7
app/jobs/event_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class EventCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(event)
|
||||
EventCreateCreatorEmailJob.perform_later(event)
|
||||
end
|
||||
end
|
6
app/jobs/export_payments_completed_job.rb
Normal file
6
app/jobs/export_payments_completed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportPaymentsCompletedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_payments_completed_notification(export).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/export_payments_failed_job.rb
Normal file
6
app/jobs/export_payments_failed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportPaymentsFailedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_payments_failed_notification(export).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/export_recurring_donations_completed_job.rb
Normal file
6
app/jobs/export_recurring_donations_completed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportRecurringDonationsCompletedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_recurring_donations_completed_notification(@export).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/export_recurring_donations_failed_job.rb
Normal file
6
app/jobs/export_recurring_donations_failed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportRecurringDonationsFailedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_recurring_donations_failed_notification(export).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/export_supporter_notes_completed_job.rb
Normal file
6
app/jobs/export_supporter_notes_completed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportSupporterNotesCompletedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_supporter_notes_completed_notification(export).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/export_supporter_notes_failed_job.rb
Normal file
6
app/jobs/export_supporter_notes_failed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportSupporterNotesFailedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_supporter_notes_failed_notification(export).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/export_supporters_completed_job.rb
Normal file
6
app/jobs/export_supporters_completed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportSupportersCompletedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_supporters_completed_notification(export).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/export_supporters_failed_job.rb
Normal file
6
app/jobs/export_supporters_failed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ExportSupportersFailedJob < EmailJob
|
||||
|
||||
def perform(export)
|
||||
ExportMailer.export_supporters_failed_notification(export).deliver_now
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class FailedRecurringDonationPaymentDonorEmailJob < EmailJob
|
||||
|
||||
def perform(donation)
|
||||
DonationMailer.donor_failed_recurring_donation(donation.id).deliver_now
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class FailedRecurringDonationPaymentNonprofitEmailJob < EmailJob
|
||||
|
||||
def perform(donation)
|
||||
DonationMailer.nonprofit_failed_recurring_donation(donation.id).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/import_completed_job.rb
Normal file
6
app/jobs/import_completed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class ImportCompletedJob < EmailJob
|
||||
|
||||
def perform(import)
|
||||
ImportMailer.import_completed_notification(import.id).deliver_now
|
||||
end
|
||||
end
|
13
app/jobs/import_creation_job.rb
Normal file
13
app/jobs/import_creation_job.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class ImportCreationJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(import_params, current_user)
|
||||
InsertImport.from_csv_safe(
|
||||
nonprofit_id: import_params[:nonprofit_id],
|
||||
user_id: current_user.id,
|
||||
user_email: current_user.email,
|
||||
file_uri: import_params[:file_uri],
|
||||
header_matches: import_params[:header_matches]
|
||||
)
|
||||
end
|
||||
end
|
7
app/jobs/mailchimp_supporter_sync_job.rb
Normal file
7
app/jobs/mailchimp_supporter_sync_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class MailchimpSupporterSyncJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(np_id, supporter_ids, tag_data)
|
||||
Mailchimp.sync_supporters_to_list_from_tag_joins(np_id, supporter_ids, tag_data)
|
||||
end
|
||||
end
|
6
app/jobs/nonprofit_create_job.rb
Normal file
6
app/jobs/nonprofit_create_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class NonprofitCreateJob < EmailJob
|
||||
|
||||
def perform(nonprofit)
|
||||
NonprofitMailer.welcome(nonprofit.id).deliver_now
|
||||
end
|
||||
end
|
7
app/jobs/pay_recurring_donation_job.rb
Normal file
7
app/jobs/pay_recurring_donation_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class PayRecurringDonationJob < ApplicationJob
|
||||
queue_as :rec_don_payments
|
||||
|
||||
def perform(id)
|
||||
PayRecurringDonation.with_stripe(id)
|
||||
end
|
||||
end
|
9
app/jobs/pay_recurring_donations_job.rb
Normal file
9
app/jobs/pay_recurring_donations_job.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class PayRecurringDonationsJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(*ids)
|
||||
ids.each do |id|
|
||||
PayRecurringDonationJob.perform_later(id)
|
||||
end
|
||||
end
|
||||
end
|
7
app/jobs/payment_export_create_job.rb
Normal file
7
app/jobs/payment_export_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class PaymentExportCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(npo_id, params, user_id, export_id)
|
||||
ExportPayments.run_export(npo_id, params, user_id, export_id)
|
||||
end
|
||||
end
|
6
app/jobs/payment_notification_email_donor_job.rb
Normal file
6
app/jobs/payment_notification_email_donor_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class PaymentNotificationEmailDonorJob < EmailJob
|
||||
|
||||
def perform(donation, locale)
|
||||
DonationMailer.donor_payment_notification(donation.id, locale).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/payment_notification_email_nonprofit_job.rb
Normal file
6
app/jobs/payment_notification_email_nonprofit_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class PaymentNotificationEmailNonprofitJob < EmailJob
|
||||
|
||||
def perform(donation, user=nil)
|
||||
DonationMailer.nonprofit_payment_notification(donation.id, user&.id).deliver_now
|
||||
end
|
||||
end
|
8
app/jobs/payment_notification_job.rb
Normal file
8
app/jobs/payment_notification_job.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class PaymentNotificationJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(donation, locale, user=nil)
|
||||
PaymentNotificationEmailDonorJob.perform_later donation, locale
|
||||
PaymentNotificationEmailNonprofitJob.perform_later donation, user
|
||||
end
|
||||
end
|
6
app/jobs/payout_pending_job.rb
Normal file
6
app/jobs/payout_pending_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class PayoutPendingJob < EmailJob
|
||||
|
||||
def perform(payout)
|
||||
NonprofitMailer.pending_payout_notification(payout.id).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/recurring_donation_cancelled_job.rb
Normal file
6
app/jobs/recurring_donation_cancelled_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class RecurringDonationCancelledJob < EmailJob
|
||||
|
||||
def perform(donation)
|
||||
DonationMailer.nonprofit_recurring_donation_cancellation(donation.id).deliver_now
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class RecurringDonationChangeAmountDonorEmailJob < EmailJob
|
||||
|
||||
def perform(recurring_donation, previous_amount)
|
||||
DonationMailer.donor_recurring_donation_change_amount(recurring_donation.id, previous_amount).deliver_now
|
||||
end
|
||||
end
|
8
app/jobs/recurring_donation_change_amount_job.rb
Normal file
8
app/jobs/recurring_donation_change_amount_job.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class RecurringDonationChangeAmountJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(recurring_donation, previous_amount)
|
||||
RecurringDonationChangeAmountDonorEmailJob.perform_later(recurring_donation, previous_amount)
|
||||
RecurringDonationChangeAmountNonprofitEmailJob.perform_later(recurring_donation, previous_amount)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class RecurringDonationChangeAmountNonprofitEmailJob < EmailJob
|
||||
|
||||
def perform(recurring_donation, previous_amount)
|
||||
DonationMailer.nonprofit_recurring_donation_change_amount(recurring_donation.id, previous_amount).deliver_now
|
||||
end
|
||||
end
|
7
app/jobs/recurring_donations_export_create_job.rb
Normal file
7
app/jobs/recurring_donations_export_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class RecurringDonationsExportCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(*args)
|
||||
ExportRecurringDonations.run_export(*args)
|
||||
end
|
||||
end
|
6
app/jobs/refund_notification_donor_email_job.rb
Normal file
6
app/jobs/refund_notification_donor_email_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class RefundNotificationDonorEmailJob < EmailJob
|
||||
|
||||
def perform(refund)
|
||||
UserMailer.refund_receipt(refund).deliver_now
|
||||
end
|
||||
end
|
7
app/jobs/refund_notification_job.rb
Normal file
7
app/jobs/refund_notification_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class RefundNotificationJob < EmailJob
|
||||
|
||||
def perform(refund)
|
||||
RefundNotificationDonorEmailJob.perform_later(refund)
|
||||
RefundNotificationNonprofitEmailJob.perform_later(refund)
|
||||
end
|
||||
end
|
6
app/jobs/refund_notification_nonprofit_email_job.rb
Normal file
6
app/jobs/refund_notification_nonprofit_email_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class RefundNotificationNonprofitEmailJob < EmailJob
|
||||
|
||||
def perform(refund)
|
||||
NonprofitMailer.refund_notification(refund.id).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/role_added_job.rb
Normal file
6
app/jobs/role_added_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class RoleAddedJob < EmailJob
|
||||
|
||||
def perform(role)
|
||||
NonprofitAdminMailer.existing_invite(role).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/stripe_account_create_job.rb
Normal file
6
app/jobs/stripe_account_create_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class StripeAccountCreateJob < EmailJob
|
||||
|
||||
def perform(nonprofit)
|
||||
NonprofitMailer.setup_verification(nonprofit.id).deliver_now
|
||||
end
|
||||
end
|
7
app/jobs/supporter_fundraiser_create_job.rb
Normal file
7
app/jobs/supporter_fundraiser_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class SupporterFundraiserCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(fundraiser)
|
||||
NonprofitAdminMailer.supporter_fundraiser(fundraiser).deliver_now unless QueryRoles.is_nonprofit_user?(fundraiser.profile.user.id, fundraiser.nonprofit.id)
|
||||
end
|
||||
end
|
7
app/jobs/supporter_notes_export_create_job.rb
Normal file
7
app/jobs/supporter_notes_export_create_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class SupporterNotesExportCreateJob < EmailJob
|
||||
queue_as :default
|
||||
|
||||
def perform(npo_id, params, user_id, export_id)
|
||||
ExportSupporterNotes.run_export(npo_id, params, user_id, export_id)
|
||||
end
|
||||
end
|
6
app/jobs/supporters_export_create_job.rb
Normal file
6
app/jobs/supporters_export_create_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class SupportersExportCreateJob < EmailJob
|
||||
|
||||
def perform(*args)
|
||||
ExportSupporters.run_export(*args)
|
||||
end
|
||||
end
|
8
app/jobs/ticket_create_job.rb
Normal file
8
app/jobs/ticket_create_job.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class TicketCreateJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(ticket_ids, charge, user=nil)
|
||||
TicketMailer.followup(ticket_ids, charge_id).deliver_later
|
||||
TicketMailer.receipt_admin(ticket_ids, user.id).deliver_later
|
||||
end
|
||||
end
|
6
app/jobs/user_invite_create_job.rb
Normal file
6
app/jobs/user_invite_create_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class UserInviteCreateJob < EmailJob
|
||||
|
||||
def perform(role, raw_token)
|
||||
NonprofitAdminMailer.new_invite(role, raw_token).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/verification_completed_job.rb
Normal file
6
app/jobs/verification_completed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class VerificationCompletedJob < EmailJob
|
||||
|
||||
def perform(nonprofit)
|
||||
NonprofitMailer.successful_verification_notice(nonprofit).deliver_now
|
||||
end
|
||||
end
|
6
app/jobs/verification_failed_job.rb
Normal file
6
app/jobs/verification_failed_job.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class VerificationFailedJob < EmailJob
|
||||
|
||||
def perform(nonprofit)
|
||||
NonprofitMailer.failed_verification_notice(onprofit).deliver_now
|
||||
end
|
||||
end
|
7
app/jobs/we_move_execute_for_donations_job.rb
Normal file
7
app/jobs/we_move_execute_for_donations_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class WeMoveExecuteForDonationsJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(donation)
|
||||
QueueDonations.execute_for_donation(donation.id)
|
||||
end
|
||||
end
|
|
@ -7,9 +7,9 @@ class PaymentMailer < BaseMailer
|
|||
def resend_admin_receipt(payment_id, user_id)
|
||||
payment = Payment.find(payment_id)
|
||||
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
||||
return Delayed::Job.enqueue JobTypes::NonprofitPaymentNotificationJob.new(payment.donation.id, user_id)
|
||||
PaymentNotificationEmailNonprofitJob.perform_later(payment.donation, User.find(user_id))
|
||||
elsif payment.kind == 'Ticket'
|
||||
return TicketMailer.receipt_admin(payment.donation.id, user_id).deliver
|
||||
return TicketMailer.receipt_admin(payment.donation.id, user_id).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -18,9 +18,9 @@ class PaymentMailer < BaseMailer
|
|||
def resend_donor_receipt(payment_id)
|
||||
payment = Payment.find(payment_id)
|
||||
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
||||
Delayed::Job.enqueue JobTypes::DonorPaymentNotificationJob.new(payment.donation.id)
|
||||
PaymentNotificationEmailDonorJob.perform_later payment.donation
|
||||
elsif payment.kind == 'Ticket'
|
||||
return TicketMailer.followup(payment.tickets.pluck(:id), payment.charge.id).deliver
|
||||
return TicketMailer.followup(payment.tickets.pluck(:id), payment.charge).deliver_later
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -99,13 +99,7 @@ class Campaign < ApplicationRecord
|
|||
after_create do
|
||||
user = profile.user
|
||||
Role.create(name: :campaign_editor, user_id: user.id, host: self)
|
||||
if child_campaign?
|
||||
CampaignMailer.delay.federated_creation_followup(self)
|
||||
else
|
||||
CampaignMailer.delay.creation_followup(self)
|
||||
end
|
||||
|
||||
NonprofitAdminMailer.delay.supporter_fundraiser(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
||||
CampaignCreateJob.perform_later(self)
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class Event < ApplicationRecord
|
|||
after_create do
|
||||
user = profile.user
|
||||
Role.create(name: :event_editor, user_id: user.id, host: self)
|
||||
EventMailer.delay.creation_followup(self)
|
||||
EventCreateJob.perform_later self
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ end
|
|||
return role unless role.valid?
|
||||
|
||||
if user.confirmed?
|
||||
NonprofitAdminMailer.delay.existing_invite(role)
|
||||
RoleAddedJob.perform_later role
|
||||
else
|
||||
NonprofitAdminMailer.delay.new_invite(role, user.make_confirmation_token!)
|
||||
UserInviteCreateJob.perform_later role, user.make_confirmation_token!
|
||||
end
|
||||
role
|
||||
end
|
||||
|
|
|
@ -3,7 +3,18 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require_relative 'boot'
|
||||
|
||||
require 'rails/all'
|
||||
require "rails"
|
||||
# Pick the frameworks you want:
|
||||
require "active_model/railtie"
|
||||
require "active_job/railtie"
|
||||
require "active_record/railtie"
|
||||
require "active_storage/engine"
|
||||
require "action_controller/railtie"
|
||||
require "action_mailer/railtie"
|
||||
require "action_view/railtie"
|
||||
# require "action_cable/engine"
|
||||
# require "sprockets/railtie"
|
||||
# require "rails/test_unit/railtie"
|
||||
|
||||
# Require the gems listed in Gemfile, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
Delayed::Worker.max_attempts = 1
|
|
@ -16,8 +16,8 @@ module CreateCampaign
|
|||
# do notifications
|
||||
user = campaign.profile.user
|
||||
Role.create(name: :campaign_editor, user_id: user.id, host: self)
|
||||
CampaignMailer.delay.creation_followup(self)
|
||||
NonprofitAdminMailer.delay.supporter_fundraiser(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
||||
CampaignCreateJob.perform_later(self)
|
||||
SupporterFundraiserCreateJob.perform_later(self) unless QueryRoles.is_nonprofit_user?(user.id, nonprofit_id)
|
||||
|
||||
return { errors: campaign.errors.messages }.as_json unless campaign.errors.empty?
|
||||
|
||||
|
|
|
@ -38,12 +38,12 @@ module CreateCampaignGift
|
|||
if !donation.recurring_donation.nil? && (!campaign_gift_option.amount_recurring.nil? && campaign_gift_option.amount_recurring > 0)
|
||||
# it's a recurring_donation. Is it enough? for the gift level?
|
||||
unless donation.recurring_donation.amount == campaign_gift_option.amount_recurring
|
||||
AdminMailer.delay.notify_failed_gift(donation, campaign_gift_option)
|
||||
AdminFailedGiftJob.perform_later(donation, campaign_gift_option)
|
||||
raise ParamValidation::ValidationError.new("#{params[:campaign_gift_option_id]} gift options requires a recurring donation of #{campaign_gift_option.amount_recurring} for donation #{donation.id}", key: :campaign_gift_option_id)
|
||||
end
|
||||
else
|
||||
unless donation.amount == campaign_gift_option.amount_one_time
|
||||
AdminMailer.delay.notify_failed_gift(donation, campaign_gift_option)
|
||||
AdminFailedGiftJob.perform_later(donation, campaign_gift_option)
|
||||
raise ParamValidation::ValidationError.new("#{params[:campaign_gift_option_id]} gift options requires a donation of #{campaign_gift_option.amount_one_time} for donation #{donation.id}", key: :campaign_gift_option_id)
|
||||
end
|
||||
end
|
||||
|
@ -56,7 +56,7 @@ module CreateCampaignGift
|
|||
return gift
|
||||
end
|
||||
end
|
||||
AdminMailer.delay.notify_failed_gift(donation, campaign_gift_option)
|
||||
AdminFailedGiftJob.perform_later(donation, campaign_gift_option)
|
||||
raise ParamValidation::ValidationError.new("#{params[:campaign_gift_option_id]} has no more inventory", key: :campaign_gift_option_id)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'qx'
|
||||
require 'delayed_job'
|
||||
|
||||
module DelayedJobHelper
|
||||
# Create a serialized delayed job handler for use in inserting new delayed jobs with raw sql
|
||||
# Be sure to wrap the handler in double quotes when inserting, not single
|
||||
def self.create_handler(obj, method_name, args)
|
||||
Delayed::PerformableMethod.new(obj, method_name, args).to_yaml.to_s
|
||||
end
|
||||
|
||||
# Manually enqueue a job
|
||||
def self.enqueue_job(obj, method_name, args, options = {})
|
||||
handler = Delayed::PerformableMethod.new(obj, method_name, args).to_yaml.to_s
|
||||
Qx.insert_into(:delayed_jobs)
|
||||
.values(
|
||||
created_at: Time.current,
|
||||
updated_at: Time.current,
|
||||
priority: options[:priority] || 0,
|
||||
attempts: 0,
|
||||
handler: handler,
|
||||
run_at: options[:run_at] || Time.current,
|
||||
queue: options[:queue]
|
||||
).returning('*').execute
|
||||
end
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module EmailJobQueue
|
||||
def self.queue(klass, *args)
|
||||
Delayed::Job.enqueue klass.new(*args)
|
||||
end
|
||||
end
|
|
@ -20,7 +20,7 @@ module ExportPayments
|
|||
|
||||
e = Export.create(nonprofit: npo, user: user, status: :queued, export_type: 'ExportPayments', parameters: params.to_json)
|
||||
|
||||
DelayedJobHelper.enqueue_job(ExportPayments, :run_export, [npo_id, params.to_json, user_id, e.id])
|
||||
PaymentExportCreateJob.perform_later(npo_id, params.to_json, user_id, e.id)
|
||||
end
|
||||
|
||||
def self.run_export(npo_id, params, user_id, export_id)
|
||||
|
@ -61,14 +61,14 @@ module ExportPayments
|
|||
export.ended = Time.now
|
||||
export.save!
|
||||
|
||||
ExportMailer.delay.export_payments_completed_notification(export)
|
||||
ExportPaymentsCompletedJob.perform_later(export)
|
||||
rescue StandardError => e
|
||||
if export
|
||||
export.status = :failed
|
||||
export.exception = e.to_s
|
||||
export.ended = Time.now
|
||||
export.save!
|
||||
ExportMailer.delay.export_payments_failed_notification(export) if user
|
||||
ExportPaymentsFailedJob.perform_later(export) if user
|
||||
raise e
|
||||
end
|
||||
raise e
|
||||
|
|
|
@ -20,7 +20,7 @@ module ExportRecurringDonations
|
|||
|
||||
e = Export.create(nonprofit: npo, user: user, status: :queued, export_type: 'ExportRecurringDonations', parameters: params.to_json)
|
||||
|
||||
DelayedJobHelper.enqueue_job(ExportRecurringDonations, :run_export, [npo_id, params.to_json, user_id, e.id])
|
||||
RecurringDonationsExportCreateJob.perform_later(npo_id, params.to_json, user_id, e.id)
|
||||
end
|
||||
|
||||
def self.run_export(npo_id, params, user_id, export_id)
|
||||
|
@ -61,7 +61,7 @@ module ExportRecurringDonations
|
|||
export.ended = Time.now
|
||||
export.save!
|
||||
|
||||
ExportMailer.delay.export_recurring_donations_completed_notification(export)
|
||||
ExportRecurringDonationsCompletedJob.perform_later(export)
|
||||
rescue StandardError => e
|
||||
if export
|
||||
export.status = :failed
|
||||
|
@ -69,7 +69,7 @@ module ExportRecurringDonations
|
|||
export.ended = Time.now
|
||||
export.save!
|
||||
if user
|
||||
ExportMailer.delay.export_recurring_donations_failed_notification(export)
|
||||
ExportRecurringDonationsFailedJob.perform_later(export)
|
||||
end
|
||||
raise e
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ module ExportSupporterNotes
|
|||
|
||||
e = Export.create(nonprofit: npo, user: user, status: :queued, export_type: 'ExportSupporterNotes', parameters: params.to_json)
|
||||
|
||||
DelayedJobHelper.enqueue_job(ExportSupporterNotes, :run_export, [npo_id, params.to_json, user_id, e.id])
|
||||
SupporterNotesExportCreateJob.perform_later(npo_id, params.to_json, user_id, e.id)
|
||||
end
|
||||
|
||||
def self.run_export(npo_id, params, user_id, export_id)
|
||||
|
@ -59,8 +59,7 @@ module ExportSupporterNotes
|
|||
export.status = :completed
|
||||
export.ended = Time.now
|
||||
export.save!
|
||||
|
||||
EmailJobQueue.queue(JobTypes::ExportSupporterNotesCompletedJob, export)
|
||||
ExportSupporterNotesCompletedJob.perform_later(export)
|
||||
rescue StandardError => e
|
||||
if export
|
||||
export.status = :failed
|
||||
|
@ -68,7 +67,7 @@ module ExportSupporterNotes
|
|||
export.ended = Time.now
|
||||
export.save!
|
||||
if user
|
||||
EmailJobQueue.queue(JobTypes::ExportSupporterNotesFailedJob, export)
|
||||
ExportSupporterNotesFailedJob.perform_later export
|
||||
end
|
||||
raise e
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ module ExportSupporters
|
|||
|
||||
e = Export.create(nonprofit: npo, user: user, status: :queued, export_type: 'ExportSupporters', parameters: params.to_json)
|
||||
|
||||
DelayedJobHelper.enqueue_job(ExportSupporters, :run_export, [npo_id, params.to_json, user_id, e.id])
|
||||
SupportersExportCreateJob.perform_later(npo_id, params.to_json, user_id, e.id)
|
||||
end
|
||||
|
||||
def self.run_export(npo_id, params, user_id, export_id)
|
||||
|
@ -58,14 +58,14 @@ module ExportSupporters
|
|||
export.ended = Time.now
|
||||
export.save!
|
||||
|
||||
EmailJobQueue.queue(JobTypes::ExportSupportersCompletedJob, export)
|
||||
ExportSupportersCompletedJob.perform_later export
|
||||
rescue StandardError => e
|
||||
if export
|
||||
export.status = :failed
|
||||
export.exception = e.to_s
|
||||
export.ended = Time.now
|
||||
export.save!
|
||||
EmailJobQueue.queue(JobTypes::ExportSupportersFailedJob, export) if user
|
||||
ExportSupportersFailedJob.perform_later(export) if user
|
||||
raise e
|
||||
end
|
||||
raise e
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
Description:
|
||||
Create a new EmailJob subclass in lib/job_types
|
||||
|
||||
Example:
|
||||
rails generate email_job JobName arg1 arg2
|
||||
|
||||
This will create:
|
||||
A file called lib/job_types/job_name_job.rb with a module named JobNameJob
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
class EmailJobGenerator < Rails::Generators::NamedBase
|
||||
argument :attribs, type: :array
|
||||
source_root File.expand_path('templates', __dir__)
|
||||
def copy_file_to_lib
|
||||
template 'email_job_template.erb', "lib/job_types/#{name.underscore}.rb"
|
||||
template 'email_job_spec_template.erb', "spec/lib/job_types/#{name.underscore}_spec.rb"
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails_helper.rb'
|
||||
|
||||
describe JobTypes::<%= name %> do
|
||||
describe '.perform' do
|
||||
it 'calls the correct active mailer' do
|
||||
expect(fail).to receive(:fail).with(fail).and_wrap_original{|m, *args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer}
|
||||
|
||||
job = JobTypes::<%= name %>.new(fail)
|
||||
job.perform
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class <%= name %> < EmailJob
|
||||
attr_reader <%= attribs.map{|i| ":#{i}"}.join(", ") %>
|
||||
|
||||
def initialize(<%= attribs.join(", ") %>)<% attribs.each {|i| %>
|
||||
@<%= i %> = <%= i %><% }%>
|
||||
end
|
||||
|
||||
def perform
|
||||
fail
|
||||
end
|
||||
end
|
||||
end
|
|
@ -53,7 +53,7 @@ module InsertBankAccount
|
|||
pending_verification: true
|
||||
)
|
||||
|
||||
NonprofitMailer.delay.new_bank_account_notification(bank_account)
|
||||
BankAccountCreateJob.perform_later(bank_account)
|
||||
return bank_account
|
||||
rescue Stripe::StripeError => error
|
||||
params[:failure_message] = "Failed to connect the bank account: #{error.inspect}"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'delayed_job_helper'
|
||||
require 'qx'
|
||||
require 'update/update_custom_field_joins'
|
||||
|
||||
|
|
|
@ -43,9 +43,8 @@ module InsertDonation
|
|||
result['donation'] = insert_donation(data, entities)
|
||||
update_donation_keys(result)
|
||||
result['activity'] = InsertActivities.for_one_time_donations([result['payment'].id])
|
||||
EmailJobQueue.queue(JobTypes::NonprofitPaymentNotificationJob, result['donation'].id)
|
||||
EmailJobQueue.queue(JobTypes::DonorPaymentNotificationJob, result['donation'].id, entities[:supporter_id].locale)
|
||||
QueueDonations.delay.execute_for_donation(result['donation'].id)
|
||||
PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale
|
||||
WeMoveExecuteForDonationsJob.perform_later(result['donation'])
|
||||
result
|
||||
end
|
||||
|
||||
|
@ -86,7 +85,7 @@ module InsertDonation
|
|||
]).returning('*')
|
||||
).first
|
||||
result['activity'] = InsertActivities.for_offsite_donations([result['payment']['id']])
|
||||
QueueDonations.delay.execute_for_donation(result['donation'].id)
|
||||
WeMoveExecuteForDonationsJob.perform_later(result['donation'])
|
||||
{ status: 200, json: result }
|
||||
end
|
||||
|
||||
|
@ -106,10 +105,9 @@ module InsertDonation
|
|||
result['donation'] = insert_donation(data, entities)
|
||||
update_donation_keys(result)
|
||||
|
||||
EmailJobQueue.queue(JobTypes::NonprofitPaymentNotificationJob, result['donation'].id)
|
||||
EmailJobQueue.queue(JobTypes::DonorDirectDebitNotificationJob, result['donation'].id, locale_for_supporter(result['donation'].supporter.id))
|
||||
DirectDebitCreateJob.perform_later(result['donation'].id, locale_for_supporter(result['donation'].supporter.id))
|
||||
|
||||
QueueDonations.delay.execute_for_donation(result['donation'].id)
|
||||
WeMoveExecuteForDonationsJob.perform_later(result['donation'])
|
||||
# do this for making test consistent
|
||||
result['activity'] = {}
|
||||
result
|
||||
|
|
|
@ -36,7 +36,7 @@ module InsertEmailLists
|
|||
.returning('*')
|
||||
.execute
|
||||
|
||||
UpdateEmailLists.delay.populate_lists_on_mailchimp(npo_id)
|
||||
EmailListCreateJob.perform_later(npo_id)
|
||||
|
||||
{ deleted: deleted, deleted_result: result, inserted_lists: inserted_lists, inserted_result: lists }
|
||||
end
|
||||
|
|
|
@ -164,7 +164,7 @@ module InsertImport
|
|||
.returning('*')
|
||||
.execute.first
|
||||
InsertFullContactInfos.enqueue(supporter_ids) if supporter_ids.any?
|
||||
ImportMailer.delay.import_completed_notification(import['id'])
|
||||
ImportCompletedJob.perform_later(Import.find(import['id']))
|
||||
import
|
||||
end
|
||||
end
|
||||
|
|
|
@ -69,7 +69,7 @@ module InsertPayout
|
|||
).first
|
||||
# Create PaymentPayout records linking all the payments to the payout
|
||||
pps = Psql.execute(Qexpr.new.insert('payment_payouts', payment_ids.map { |id| { payment_id: id.to_i } }, common_data: { payout_id: payout['id'].to_i }))
|
||||
NonprofitMailer.delay.pending_payout_notification(payout['id'].to_i)
|
||||
PayoutPendingJob.perform_later(Payout.find(payout['id'].to_i))
|
||||
return payout
|
||||
end
|
||||
rescue Stripe::StripeError => e
|
||||
|
|
|
@ -70,9 +70,8 @@ module InsertRecurringDonation
|
|||
result['activity'] = InsertActivities.for_recurring_donations([result['payment'].id])
|
||||
end
|
||||
# Send receipts
|
||||
EmailJobQueue.queue(JobTypes::NonprofitPaymentNotificationJob, result['donation'].id)
|
||||
EmailJobQueue.queue(JobTypes::DonorPaymentNotificationJob, result['donation'].id, entities[:supporter_id].locale)
|
||||
QueueDonations.delay.execute_for_donation(result['donation']['id'])
|
||||
PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale
|
||||
WeMoveExecuteForDonationsJob.perform_later(result['donation'])
|
||||
result
|
||||
end
|
||||
|
||||
|
@ -95,10 +94,9 @@ module InsertRecurringDonation
|
|||
|
||||
InsertDonation.update_donation_keys(result) if result['payment']
|
||||
|
||||
DonationMailer.delay.nonprofit_payment_notification(result['donation']['id'])
|
||||
DonationMailer.delay.donor_direct_debit_notification(result['donation']['id'], locale_for_supporter(result['donation']['supporter_id']))
|
||||
DonorDirectDebitNotificationJob.perform_later(Donation.find(result['donation']['id']), locale_for_supporter(result['donation']['supporter_id']));
|
||||
|
||||
QueueDonations.delay.execute_for_donation(result['donation']['id'])
|
||||
WeMoveExecuteForDonationsJob.perform_later(result['donation'])
|
||||
|
||||
{ status: 200, json: result }
|
||||
end
|
||||
|
|
|
@ -66,8 +66,7 @@ module InsertRefunds
|
|||
# Update original payment to increment its refund_total for any future refund attempts
|
||||
Qx.update(:payments).set("refund_total=refund_total + #{h['amount'].to_i}").ts.where(id: original_payment['id']).execute
|
||||
# Send the refund receipts in a delayed job
|
||||
Delayed::Job.enqueue JobTypes::DonorRefundNotificationJob.new(refund_row['id'])
|
||||
Delayed::Job.enqueue JobTypes::NonprofitRefundNotificationJob.new(refund_row['id'])
|
||||
RefundNotificationJob.perform_later Refund.find(refund_row['id'])
|
||||
{ 'payment' => payment_row, 'refund' => refund_row }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -82,8 +82,8 @@ module InsertSupporter
|
|||
supp_cols = data.select { |key, _val| !key.match(/^field_/) && !key.match(/^tag_/) }
|
||||
supporter = create_or_update(np_id, supp_cols)
|
||||
|
||||
InsertTagJoins.delay.find_or_create(np_id, [supporter['id']], tags) if tags.any?
|
||||
InsertCustomFieldJoins.delay.find_or_create(np_id, [supporter['id']], fields) if fields.any?
|
||||
InsertTagJoins.find_or_create(np_id, [supporter['id']], tags) if tags.any?
|
||||
InsertCustomFieldJoins.find_or_create(np_id, [supporter['id']], fields) if fields.any?
|
||||
|
||||
supporter
|
||||
end
|
||||
|
|
|
@ -81,7 +81,7 @@ module InsertTagJoins
|
|||
# activities = Psql.execute( Qexpr.new.insert(:activities, activity_data) )
|
||||
|
||||
# Sync mailchimp lists, if present
|
||||
Mailchimp.delay.sync_supporters_to_list_from_tag_joins(np_id, supporter_ids, tag_data)
|
||||
MailchimpSupporterSyncJob.perform_later(np_id, supporter_ids, tag_data.as_json)
|
||||
|
||||
{ json: { inserted_count: tags.count, removed_count: deleted.count }, status: :ok }
|
||||
end
|
||||
|
|
|
@ -100,8 +100,7 @@ module InsertTickets
|
|||
ticket_ids = result['tickets'].map(&:id)
|
||||
charge_id = result['charge'] ? result['charge'].id : nil
|
||||
|
||||
EmailJobQueue.queue(JobTypes::TicketMailerReceiptAdminJob, ticket_ids)
|
||||
EmailJobQueue.queue(JobTypes::TicketMailerFollowupJob, ticket_ids, charge_id)
|
||||
TicketCreateJob.perform_later(ticket_ids, charge_id && Charge.find(result['charge']&.id))
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class AdminFailedGiftJob < EmailJob
|
||||
attr_reader :donation, :campaign_gift_option
|
||||
|
||||
def initialize(donation, campaign_gift_option)
|
||||
@donation = donation
|
||||
@campaign_gift_option = campaign_gift_option
|
||||
end
|
||||
|
||||
def perform
|
||||
AdminMailer.notify_failed_gift(@donation, @campaign_gift_option).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class AdminNoticeJob < EmailJob
|
||||
attr_reader :options
|
||||
|
||||
def initialize(options)
|
||||
@options = options
|
||||
end
|
||||
|
||||
def perform
|
||||
GenericMailer.admin_notice(@options).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class CampaignCreationFollowupJob < EmailJob
|
||||
attr_reader :campaign
|
||||
|
||||
def initialize(campaign)
|
||||
@campaign = campaign
|
||||
end
|
||||
|
||||
def perform
|
||||
CampaignMailer.creation_followup(@campaign).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class DonorDirectDebitNotificationJob < EmailJob
|
||||
attr_reader :donation_id
|
||||
|
||||
def initialize(donation_id, locale = I18n.locale)
|
||||
@donation_id = donation_id
|
||||
@locale = locale
|
||||
end
|
||||
|
||||
def perform
|
||||
DonationMailer.donor_direct_debit_notification(@donation_id, @locale).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class DonorFailedRecurringDonationJob < EmailJob
|
||||
attr_reader :donation_id
|
||||
|
||||
def initialize(donation_id)
|
||||
@donation_id = donation_id
|
||||
end
|
||||
|
||||
def perform
|
||||
DonationMailer.donor_failed_recurring_donation(@donation_id).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class DonorPaymentNotificationJob < EmailJob
|
||||
attr_reader :donation_id
|
||||
def initialize(donation_id, locale = I18n.locale)
|
||||
@donation_id = donation_id
|
||||
@locale = locale
|
||||
end
|
||||
|
||||
def perform
|
||||
DonationMailer.donor_payment_notification(@donation_id, @locale).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class DonorRecurringDonationChangeAmountJob < EmailJob
|
||||
attr_reader :donation_id, :previous_amount
|
||||
def initialize(donation_id, previous_amount = nil)
|
||||
@donation_id = donation_id
|
||||
@previous_amount = previous_amount
|
||||
end
|
||||
|
||||
def perform
|
||||
DonationMailer.donor_recurring_donation_change_amount(@donation_id, @previous_amount).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class DonorRefundNotificationJob < EmailJob
|
||||
attr_reader :refund_id
|
||||
def initialize(refund_id)
|
||||
@refund_id = refund_id
|
||||
end
|
||||
|
||||
def perform
|
||||
UserMailer.refund_receipt(@refund_id).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class EmailJob
|
||||
def perform
|
||||
raise 'You need to override this'
|
||||
end
|
||||
|
||||
def max_attempts
|
||||
MAX_EMAIL_JOB_ATTEMPTS || 1
|
||||
end
|
||||
|
||||
def destroy_failed_jobs?
|
||||
false
|
||||
end
|
||||
|
||||
def error(job, exception); end
|
||||
|
||||
def reschedule_at(current_time, attempts)
|
||||
current_time + attempts**2.195
|
||||
end
|
||||
|
||||
def queue_name
|
||||
'email_queue'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class EventCreationFollowupJob < EmailJob
|
||||
attr_reader :event
|
||||
|
||||
def initialize(event)
|
||||
@event = event
|
||||
end
|
||||
|
||||
def perform
|
||||
EventMailer.creation_followup(@event).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class ExportPaymentCompletedJob < EmailJob
|
||||
attr_reader :export
|
||||
|
||||
def initialize(export)
|
||||
@export = export
|
||||
end
|
||||
|
||||
def perform
|
||||
ExportMailer.export_payments_completed_notification(export).deliver
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
module JobTypes
|
||||
class ExportPaymentFailedJob < EmailJob
|
||||
attr_reader :export
|
||||
|
||||
def initialize(export)
|
||||
@export = export
|
||||
end
|
||||
|
||||
def perform
|
||||
ExportMailer.export_payments_failed_notification(export).deliver
|
||||
end
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue