Skip to content

Commit 5e96a9c

Browse files
feat(messages): Transitions from SparkPost to SendGrid (#285)
* feat(messages): Transitions from SparkPost to SendGrid * Fixes Hound issues (v1) * fix: Hound whitespace issue * refactor: Removes stubbed-out code for HM2.1 * Update README.md * Update README.md Co-authored-by: Peter Kos <[email protected]>
1 parent abcf634 commit 5e96a9c

22 files changed

+9198
-94
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ AWS_ACCESS_KEY_ID="abc"
55
AWS_SECRET_ACCESS_KEY="123"
66
AWS_REGION="us-east-1"
77
AWS_ENDPOINT=""
8-
SPARKPOST_API_KEY="foo"
8+
SENDGRID_API_KEY="foo"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
/public/assets
2424
.byebug_history
2525

26+
/coverage
27+
2628
# Ignore master key for decrypting credentials and more.
2729
/config/master.key
2830

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ gem 'sidekiq-cron', '~> 1.1'
8282
gem 'rails-settings-cached', '~> 0.7.2'
8383
gem 'blazer'
8484
gem 'simple_spark'
85-
gem 'sparkpost_rails'
85+
gem 'sendgrid-actionmailer'
8686
gem 'httparty'
8787
gem 'rollbar', '~> 2.8'
8888
gem 'rubyzip', '>= 1.3.0'

Gemfile.lock

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ GEM
333333
rollbar (2.26.0)
334334
ruby-progressbar (1.10.1)
335335
ruby_dep (1.5.0)
336+
ruby_http_client (3.5.0)
336337
ruby_parser (3.14.2)
337338
sexp_processor (~> 4.9)
338339
rubyzip (2.3.0)
@@ -353,6 +354,11 @@ GEM
353354
selenium-webdriver (3.142.7)
354355
childprocess (>= 0.5, < 4.0)
355356
rubyzip (>= 1.2.2)
357+
sendgrid-actionmailer (3.0.2)
358+
mail (~> 2.7)
359+
sendgrid-ruby (~> 6.0)
360+
sendgrid-ruby (6.3.2)
361+
ruby_http_client (~> 3.4)
356362
sexp_processor (4.15.0)
357363
shellany (0.0.1)
358364
shoulda (3.5.0)
@@ -379,8 +385,6 @@ GEM
379385
docile (~> 1.1)
380386
simplecov-html (~> 0.11)
381387
simplecov-html (0.12.2)
382-
sparkpost_rails (1.5.2)
383-
rails (>= 4.0, < 6.1)
384388
spring (2.1.0)
385389
spring-watcher-listen (2.0.1)
386390
listen (>= 2.7, < 4.0)
@@ -481,14 +485,14 @@ DEPENDENCIES
481485
sass-rails (~> 6.0)
482486
selectize-rails
483487
selenium-webdriver
488+
sendgrid-actionmailer
484489
shoulda (~> 3.5)
485490
shoulda-matchers (~> 2.0)
486491
sidekiq (< 7)
487492
sidekiq-cron (~> 1.1)
488493
simple_form
489494
simple_spark
490495
simplecov
491-
sparkpost_rails
492496
spring
493497
spring-watcher-listen (~> 2.0.0)
494498
sprockets

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ HackathonManager makes use of a few different third-party services & Ruby gems:
3131

3232
- [Devise](https://github.com/plataformatec/devise) + [MyMLH](https://my.mlh.io/) (authentication & attendee identity)
3333
- [Sidekiq](https://github.com/mperham/sidekiq) (background jobs)
34-
- [SparkPost](https://www.sparkpost.com/) (email)
35-
- [Amazon S3](https://aws.amazon.com/s3/) (resume storage)
36-
- [Chartkick](http://chartkick.com/) (management UI charts)
34+
- [SendGrid](https://sendgrid.com) (email)
35+
- [Amazon S3](https://aws.amazon.com/s3) (resume storage)
36+
- [Chartkick](http://chartkick.com) (management UI charts)
3737
- [Blazer](https://github.com/ankane/blazer) (custom SQL queries, analytics, and charts)
3838
- [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) (authentication via OAuth for API usage)
3939

app.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,8 @@
5858
"description": "Rollbar access token for code exception reporting",
5959
"required": false
6060
},
61-
"SPARKPOST_API_KEY": {
62-
"description": "SparkPost API key for sending email",
63-
"required": false
64-
},
65-
"SPARKPOST_CAMPAIGN_ID": {
66-
"description": "SparkPost campaign ID for sending email (e.g. the name of your hackathon)",
61+
"SENDGRID_API_KEY": {
62+
"description": "SendGrid API key for sending email",
6763
"required": false
6864
},
6965
"HM_DOMAIN_NAME": {

app/controllers/manage/questionnaires_controller.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Manage::QuestionnairesController < Manage::ApplicationController
22
include QuestionnairesControllable
33

4-
before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :convert_to_admin, :update_acc_status, :message_events]
4+
before_action :set_questionnaire, only: [:show, :edit, :update, :destroy, :check_in, :convert_to_admin, :update_acc_status]
55

66
respond_to :html, :json
77

@@ -146,10 +146,6 @@ def bulk_apply
146146
head :ok
147147
end
148148

149-
def message_events
150-
render json: @questionnaire.message_events
151-
end
152-
153149
private
154150

155151
def questionnaire_params

app/mailers/user_mailer.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,4 @@ def incomplete_reminder_email(user_id)
2020

2121
Message.queue_for_trigger("user.24hr_incomplete_application", @user.id)
2222
end
23-
24-
rescue_from SparkPostRails::DeliveryException do |e|
25-
error_codes_to_not_retry = [
26-
"1902", # Generation rejection, specific to the Sparkpost API
27-
]
28-
raise e unless e.blank? || error_codes_to_not_retry.include?(e.service_code)
29-
end
3023
end

app/models/questionnaire.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,6 @@ def did_rsvp?
191191
['rsvp_confirmed', 'rsvp_denied'].include? acc_status
192192
end
193193

194-
def message_events
195-
return [] unless ENV["SPARKPOST_API_KEY"].presence
196-
197-
simple_spark = SimpleSpark::Client.new
198-
simple_spark.message_events.search(recipients: email)
199-
end
200-
201194
def verbal_status
202195
if acc_status == "rsvp_denied"
203196
"Not Attending"

app/views/manage/configs/index.html.haml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,20 @@
7474
%b Email Provider
7575
- if Rails.application.config.action_mailer.delivery_method == :smtp
7676
%p
77-
%span.badge.badge-secondary SparkPost
77+
%span.badge.badge-secondary SendGrid
7878
%span.badge.badge-success SMTP
7979
%br
8080
%small
81-
%i To switch to SparkPost, unset the <code>SMTP_ADDRESS</code> environment variable
81+
%i To switch to SendGrid, unset the <code>SMTP_ADDRESS</code> environment variable
8282
= render 'config_row', name: 'SMTP Address', key: 'SMTP_ADDRESS'
8383
= render 'config_row', name: 'SMTP Port', key: 'SMTP_PORT', default: 587
8484
= render 'config_row', name: 'SMTP Username', key: 'SMTP_USER_NAME', secret: true
8585
= render 'config_row', name: 'SMTP Password', key: 'SMTP_PASSWORD', secret: true
8686
- else
8787
%p
88-
%span.badge.badge-success SparkPost
88+
%span.badge.badge-success SendGrid
8989
%span.badge.badge-secondary SMTP
9090
%br
9191
%small
9292
%i To switch to SMTP, set the <code>SMTP_ADDRESS</code> environment variable
93-
= render 'config_row', name: 'SparkPost Campaign ID', key: 'SPARKPOST_CAMPAIGN_ID'
94-
= render 'config_row', name: 'SparkPost API Key', key: 'SPARKPOST_API_KEY', secret: true
93+
= render 'config_row', name: 'SendGrid API Key', key: 'SENDGRID_API_KEY', secret: true

0 commit comments

Comments
 (0)