This repository was archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
This repository was archived by the owner on Dec 7, 2023. It is now read-only.
Registered user name does not get updated if Sparkpost fails #547
Copy link
Copy link
Open
Labels
Description
We hit Sparkpost monthly rate-limit, and that caused the entire registration endpoint to create partially handled responses un-atomically.
We need to wrap this (and a bunch of other endpoints in general) in transactions and move the nameless updating prior to attempting to send the confirmation email.
api/services/registration/controller/controller.go
Lines 170 to 195 in 1213151
| mail_template := "registration_confirmation" | |
| err = service.SendUserMail(id, mail_template) | |
| if err != nil { | |
| errors.WriteError(w, r, errors.InternalError(err.Error(), "Could not send registration confirmation email.")) | |
| return | |
| } | |
| // Update user's name (if needed) using registration info | |
| is_user_nameless := user_info.FirstName == "" || user_info.LastName == "" | |
| if is_user_nameless { | |
| first_name, first_ok := user_registration.Data["firstName"].(string) | |
| last_name, last_ok := user_registration.Data["lastName"].(string) | |
| if first_ok && last_ok { | |
| user_info.FirstName = first_name | |
| user_info.LastName = last_name | |
| err = service.SetUserInfo(user_info) | |
| if err != nil { | |
| errors.WriteError(w, r, errors.InternalError(err.Error(), "Could not set user's name.")) | |
| return | |
| } | |
| } | |
| } |