From f27b4b98b40a61bbb5716e3cd0708d916134d6d8 Mon Sep 17 00:00:00 2001 From: Paul Arterburn Date: Fri, 13 Dec 2024 20:22:51 -0700 Subject: [PATCH] Better FROM, remove mailchimp --- .github/workflows/test.yml | 2 -- Gemfile | 1 - README.md | 7 +------ app/jobs/import_job.rb | 2 +- app/jobs/user_job.rb | 18 ------------------ app/mailers/user_mailer.rb | 2 +- app/models/user.rb | 6 ------ config/initializers/devise.rb | 2 +- 8 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 app/jobs/user_job.rb diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index efbd064e..f927c24d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -86,8 +86,6 @@ jobs: DEVISE_SECRET_KEY: test GUMROAD_PRODUCT_ID: test GUMROAD_SELLER_ID: test - MAILCHIMP_API_KEY: test - MAILCHIMP_LIST_ID: test MAIN_DOMAIN: test PAYPAL_SELLER_ID: test SMTP_DOMAIN: test diff --git a/Gemfile b/Gemfile index f5a136fc..86a345c6 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,6 @@ gem "devise" gem 'devise-security' gem "devise-otp" gem "turnstile-captcha", require: "turnstile" -gem 'gibbon' # mailchimp connector gem 'addressable' # better URI checking # gem 'sinatra', '~> 2.0', '>= 2.0.8.1' diff --git a/README.md b/README.md index de8f2c1b..714a1b00 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ This app utilizes the following 3rd party services: * [CloudFlare](http://cloudflare.com) managed DNS + free SSL support (free for basic service) * [Mailgun](http://www.mailgun.com/rackspace) for Sending & Receiving Email (free for 50k emails per month) * [Amazon S3](http://aws.amazon.com) for Photo Uploads & Storage (free for 1 year) -* [MailChimp](http://mailchimp.com) for sending updates to all users (free for 2,000 subscribers) * [Google Analytics](http://google.com/analytics) for traffic stats (free for standard analytics) * [Turnstile](https://www.cloudflare.com/products/turnstile/) to prevent bot signups (free). * [Sentry](https://www.sentry.io/) to report errors (free) @@ -29,8 +28,6 @@ SECRET_KEY_BASE: 1234..1234 DEVISE_SECRET_KEY: 1234..1234 SMTP_DOMAIN: post.yourdomain.com MAILGUN_API_KEY=api-key -MAILCHIMP_API_KEY: f....3333-ek3 -MAILCHIMP_LIST_ID: 9982...112 TURNSTILE_SITE_KEY: 6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy TURNSTILE_SECRET_KEY: 6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx CLARIFAI_PERSONAL_ACCESS_TOKEN: asdl2k34jl2kn1l2hn234 @@ -46,9 +43,7 @@ STRIPE_SIGNING_SECRET: whsec_1234 ### Things you may want to rip out -If you want to bypass using Mailchimp to collect email addresses, simply don't put a value in for `MAILCHIMP_API_KEY`. I use Mailchimp to email out new features to the users at Dabble.me, so if you're the only one using your app it doesn't make sense to have Mailchimp. - -Same for Turnstile and Clarafai: simply don't add an environment variables for `TURNSTILE_SITE_KEY`, `CLARIFAI_V2_API_KEY`. +You can opt to not use Turnstile and Clarafai: simply don't add an environment variables for `TURNSTILE_SITE_KEY`, `CLARIFAI_V2_API_KEY`. ### Tests diff --git a/app/jobs/import_job.rb b/app/jobs/import_job.rb index bff232c2..5759d3d6 100644 --- a/app/jobs/import_job.rb +++ b/app/jobs/import_job.rb @@ -60,7 +60,7 @@ def perform(user_id,tmp_original_filename) messages << error end - ActionMailer::Base.mail(from: "Dabble Me Team ", + ActionMailer::Base.mail(from: "Paul from Dabble Me ", to: user.email, subject: "OhLife Image Import is complete", body: messages.join("\n\n")).deliver diff --git a/app/jobs/user_job.rb b/app/jobs/user_job.rb deleted file mode 100644 index e079a9e1..00000000 --- a/app/jobs/user_job.rb +++ /dev/null @@ -1,18 +0,0 @@ -class UserJob < ActiveJob::Base - queue_as :default - - def perform(email_for_lookup, user_id) - user = User.find(user_id) - email_for_lookup ||= user.email - if ENV['MAILCHIMP_API_KEY'].present? && Rails.env.production? - begin - gb = Gibbon::Request.new(api_key: ENV['MAILCHIMP_API_KEY']) - gb.timeout = 10 - gb.lists(ENV['MAILCHIMP_LIST_ID']).members(Digest::MD5.hexdigest(email_for_lookup)).upsert(body: {email_address: user.email, status: "subscribed", merge_fields: {USER_ID: user.id, FNAME: user.first_name, LNAME: user.last_name, GROUP: "Signed Up"}}) - rescue - # already subscribed or issues with Mailchimp's API - end - end - end - -end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index b55d97f0..e299fde0 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -4,7 +4,7 @@ class UserMailer < ActionMailer::Base helper EntriesHelper helper :application - default from: "Dabble Me Team " + default from: "Paul from Dabble Me " def welcome_email(user) @user = user diff --git a/app/models/user.rb b/app/models/user.rb index cd190553..0b09213e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -38,7 +38,6 @@ class User < ActiveRecord::Base before_save { send_timezone.gsub!("&", "&") } after_commit on: :update do restrict_free_frequency - subscribe_to_mailchimp end after_commit :send_welcome_email, on: :create @@ -252,11 +251,6 @@ def restrict_free_frequency end end - def subscribe_to_mailchimp - email_lookup = self.previous_changes["email"]&.last(2)&.first&.downcase - UserJob.perform_later(email_lookup, self.id) - end - def send_welcome_email UserMailer.welcome_email(self).deliver_later rescue StandardError => e diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 09dfcd53..731d0fe4 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -10,7 +10,7 @@ # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = "Dabble Me Team " + config.mailer_sender = "Paul from Dabble Me " # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer'