Enqueue a letter every day to a designated receiver (LG-3939)#4558
Enqueue a letter every day to a designated receiver (LG-3939)#4558zachmargolis merged 5 commits intomasterfrom
Conversation
| timeout: 300, | ||
| callback: lambda { | ||
| callback: lambda do | ||
| UspsDailyTestSender.new.run |
There was a problem hiding this comment.
It seemed easier to add this step to the existing daily job, rather than worry about race conditions across multiple daily jobs? I did add the top-level rescue to minimize the chances that this job will break the actual upload run
| def profile | ||
| @profile ||= user.profiles.first || user.profiles.create | ||
| end | ||
|
|
||
| def user | ||
| email = designated_receiver_pii[:email] | ||
| @user ||= User.find_with_email(email) || User.create(email: email) | ||
| end |
There was a problem hiding this comment.
Our DB schema doesn't allow a nil profile_id so it seemed easier to make up a profile than to try to relax that requirement?
My assumption is that most of the time, the designated receiver will be a login.gov team member with a valid email/user/profile, so these lines to create DB objects are more of a safety. I don't expect us to create many empty profiles/users.
Open to changing this approach if anybody feels strongly, I didn't feel super great about it
There was a problem hiding this comment.
What are the implications if the designated receiver signs in with an empty profile? Or if they try to proof? It seems like there could be some weird behavior when we try to do things like decrypt nil PII.
Could we dodge the null constraint by setting profile id to -1 or something ugly like that?
There was a problem hiding this comment.
Updated to use profile_id = -1 in c69f1d3
| # @return [Hash] | ||
| def designated_receiver_pii | ||
| @designated_receiver_pii ||= JSON.parse( | ||
| AppConfig.env.gpo_designated_receiver_pii, |
There was a problem hiding this comment.
We need to make sure we go over this with privacy / security before we add PII to app config.
There was a problem hiding this comment.
Good point, thanks
There was a problem hiding this comment.
Got confirmation in Slack: https://gsa-tts.slack.com/archives/CA7NE63SB/p1609870443330800?thread_ts=1609866962.327800&cid=CA7NE63SB
This will create a letter every day to be sent out
I made some assumptions, will drop comments on the diff to highlight questions I have