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

Send letters to contacts with no email address #884

Merged
merged 10 commits into from
Aug 3, 2022

Conversation

Beckyrose200
Copy link
Contributor

https://eaflood.atlassian.net/browse/RUBY-1997

Here we have the changes to allow letters to be sent to registrations without an email address.
In WEX there are two emails address captured, applicant_email and contact_email.
These changes mean letters are sent to any emails that are nil value instead of the NCCC email address.

@Beckyrose200 Beckyrose200 added the enhancement New feature or request label Jul 18, 2022
@Beckyrose200 Beckyrose200 marked this pull request as ready for review July 18, 2022 15:42
db/schema.rb Outdated Show resolved Hide resolved
end

def find_email_variations(email_type)
WasteExemptionsEngine::Registration.where("#{email_type} ~* ? or #{email_type} ~* ? or #{email_type} ~* ?", WASTE_EXEMPTIONS_EMAIL_VARIATIONS, EXEMPTION_EMAIL_VARIATIONS, NCCC_EMAIL_VARIATIONS)

Check notice

Code scanning / Brakeman

Possible SQL injection.

Possible SQL injection.
# rubocop:disable Layout/LineLength
class RemoveNcccEmailService < ::WasteExemptionsEngine::BaseService

# https://rubular.com/r/LPHA79nxD5k2ff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really handy. (Make sure it is cleared on rubular.com once this is merged!)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... in which case the comment should be deleted ....

app/services/remove_nccc_email_service.rb Show resolved Hide resolved
@@ -18,7 +16,7 @@ class Registration < ::WasteExemptionsEngine::ApplicationRecord

scope :renewals, -> { where.not(referring_registration_id: nil) }

scope :contact_email_is_not_nccc, -> { where.not(contact_email: NCCC_EMAIL) }
scope :contact_email_is_not_blank, -> { where.not(contact_email: nil) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"blank" and "nil" are not the same - maybe rename this to contact_email_present and also check for empty string values?

@@ -24,7 +24,7 @@ def ad_expiring_registrations
@_ad_expiring_registrations ||= lambda do
WasteExemptionsEngine::Registration
.order(:reference)
.where(contact_email: WasteExemptionsEngine.configuration.assisted_digital_email)
.where(contact_email: nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to also check for empty strings

@Beckyrose200 Beckyrose200 merged commit 03ade91 into main Aug 3, 2022
@Beckyrose200 Beckyrose200 deleted the feature/letters_to_no_email branch August 3, 2022 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants