Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Govuk Notify Mailer #240

Merged
merged 11 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PORT=3000
GOVUK_NOTIFY_API_KEY=
GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID=
GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID=
AZURE_CLIENT_ID=
AZURE_CLIENT_SECRET=
AZURE_TENANT_ID=
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
build-args: |
COMMIT_SHA=${{ env.IMAGE_TAG }}
GOVUK_NOTIFY_API_KEY=${{ secrets.GOVUK_NOTIFY_API_KEY }}
GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID=${{ secrets.GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID }}
GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID=${{ secrets.GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID }}

- name: Push ${{ env.DOCKER_IMAGE }} images for review
if: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
RAILS_ENV: test
DATABASE_URL: 'postgres://rails:password@localhost:5432/rails_test'
GOVUK_NOTIFY_API_KEY: ${{ secrets.GOVUK_NOTIFY_API_KEY }}
GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID: ${{ secrets.GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID }}
GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID: ${{ secrets.GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ COPY . .
RUN echo export PATH=/usr/local/bin:\$PATH > /root/.ashrc
ENV ENV="/root/.ashrc"

RUN bundle exec rake assets:precompile && \
rm -rf node_modules tmp

ARG COMMIT_SHA
ENV COMMIT_SHA=$COMMIT_SHA

ARG GOVUK_NOTIFY_API_KEY
ENV GOVUK_NOTIFY_API_KEY=$GOVUK_NOTIFY_API_KEY

ARG GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID
ENV GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID=$GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID
ARG GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID
ENV GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID=$GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID

RUN bundle exec rake assets:precompile && \
rm -rf node_modules tmp

CMD bundle exec rails db:migrate && \
bundle exec rails server -b 0.0.0.0
CMD ./bin/app-startup.sh
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ end
gem "sidekiq", "~> 7.1"

gem "sidekiq-cron", "~> 1.10"

gem "mail-notify", "~> 1.1"
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ GEM
net-imap
net-pop
net-smtp
mail-notify (1.1.0)
actionmailer (>= 5.2.4.6)
actionpack (>= 5.2.7.1)
actionview (>= 5.2.7.1)
activesupport (>= 5.2.4.6)
notifications-ruby-client (~> 5.1)
rack (>= 2.1.4.1)
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
Expand Down Expand Up @@ -463,6 +470,7 @@ DEPENDENCIES
invisible_captcha
jbuilder
launchy
mail-notify (~> 1.1)
notifications-ruby-client
okcomputer
omniauth-azure-activedirectory-v2
Expand Down
10 changes: 10 additions & 0 deletions app/mailers/govuk_notify_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class GovukNotifyMailer < Mail::Notify::Mailer
def application_submission
@urn = params[:urn]
view_mail(
Rails.configuration.x.govuk_notify.generic_email_template_id,
to: params[:email],
subject: t("mailer.application_submission.subject"),
)
end
end
122 changes: 0 additions & 122 deletions app/models/applicants/personal_detail.rb

This file was deleted.

21 changes: 0 additions & 21 deletions app/models/govuk_notify/client.rb

This file was deleted.

19 changes: 7 additions & 12 deletions app/services/submit_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,12 @@ def delete_form
end

def send_applicant_email
return if Rails.env.development?

# TODO: perform this in a job
template_id = ENV.fetch("GOVUK_NOTIFY_APPLICATION_SUBMITTED_TEMPLATE_ID")
email_address = application.applicant.email_address
application_id = application.urn

GovukNotify::Client.send_email(
template_id,
email_address,
application_id,
)
GovukNotifyMailer
.with(
email: application.applicant.email_address,
urn: application.urn,
)
.application_submission
.deliver_later
end
end
32 changes: 0 additions & 32 deletions app/views/applicants/application_routes/new.html.erb

This file was deleted.

19 changes: 0 additions & 19 deletions app/views/applicants/application_summary/new.html.erb

This file was deleted.

22 changes: 0 additions & 22 deletions app/views/applicants/contract_details/new.html.erb

This file was deleted.

20 changes: 0 additions & 20 deletions app/views/applicants/contract_start_dates/new.html.erb

This file was deleted.

28 changes: 0 additions & 28 deletions app/views/applicants/employment_details/new.html.erb

This file was deleted.

Loading