Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Registered user name does not get updated if Sparkpost fails #547

Open
Nydauron opened this issue Feb 16, 2023 · 0 comments
Open

Registered user name does not get updated if Sparkpost fails #547

Nydauron opened this issue Feb 16, 2023 · 0 comments

Comments

@Nydauron
Copy link
Contributor

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.

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
}
}
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant