Skip to content

Commit

Permalink
Fix recently viewed docs disappearing bug (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfreda authored Aug 23, 2023
1 parent 4ba84ab commit 5b45c5e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions internal/api/me_subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,28 @@ func MeSubscriptionsHandler(
return
}

// Find or create user.
u := models.User{
EmailAddress: userEmail,
}
if err := u.FirstOrCreate(db); err != nil {
errResp(
http.StatusInternalServerError,
"Error authorizing the request",
"error finding or creating user",
err,
)
return
}

// Build user product subscriptions.
var subs []models.Product
for _, p := range req.Subscriptions {
subs = append(subs, models.Product{Name: p})
}
u.ProductSubscriptions = subs

// Upsert user.
u := models.User{
EmailAddress: userEmail,
ProductSubscriptions: subs,
}
if err := u.Upsert(db); err != nil {
errResp(
http.StatusInternalServerError,
Expand Down

0 comments on commit 5b45c5e

Please sign in to comment.