Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.
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

Description

@Nydauron

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions