Skip to content

Commit

Permalink
correctly update pds id in database (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvolp12 authored Nov 6, 2023
2 parents 7be9693 + ed92df1 commit 3f7c1d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bgs/bgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,10 +1109,14 @@ func (s *BGS) createExternalUser(ctx context.Context, did string) (*models.Actor
log.Debugw("lost the race to create a new user", "did", did, "handle", handle, "existing_hand", exu.Handle)
if exu.PDS != peering.ID {
// User is now on a different PDS, update
if err := s.db.Model(User{}).Where("id = ?", exu.ID).Update("pds", peering.ID).Error; err != nil {
if err := s.db.Model(User{}).Where("id = ?", exu.Uid).Update("pds", peering.ID).Error; err != nil {
return nil, fmt.Errorf("failed to update users pds: %w", err)
}

if err := s.db.Model(models.ActorInfo{}).Where("uid = ?", exu.Uid).Update("pds", peering.ID).Error; err != nil {
return nil, fmt.Errorf("failed to update users pds on actorInfo: %w", err)
}

exu.PDS = peering.ID
}

Expand Down

0 comments on commit 3f7c1d3

Please sign in to comment.