Skip to content

Commit

Permalink
Attempt to fix production bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lil5 committed Mar 15, 2024
1 parent cf1355c commit 9a465e6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions server/internal/controllers/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,10 @@ func omitUserData(db *gorm.DB, chain *models.Chain, users []models.User, authUse

checkNode := func(currentNode *noderoute.NodeWithInformation[userData], routePrivacy int) int {
d := currentNode.Data
_, err := lo.Nth(users, d.userIndex)
if err != nil {
return 0
}
user := &users[d.userIndex]
hasBulkyItem := d.hasBulkyItem
isChainAdmin := d.isChainAdmin
Expand Down
6 changes: 3 additions & 3 deletions server/internal/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ SELECT
users.i18n AS i18n,
chains.name AS chain_name
FROM user_chains AS uc
LEFT JOIN users ON uc.user_id = users.id
LEFT JOIN chains ON uc.chain_id = chains.id
JOIN users ON uc.user_id = users.id
JOIN chains ON uc.chain_id = chains.id
WHERE uc.chain_id IN ?
AND uc.is_chain_admin = TRUE
AND users.is_email_verified = TRUE
Expand All @@ -233,7 +233,7 @@ func UserGetAllUsersByChain(db *gorm.DB, chainID uint) ([]User, error) {
err := db.Raw(`
SELECT users.*
FROM users
LEFT JOIN user_chains ON user_chains.user_id = users.id
JOIN user_chains ON user_chains.user_id = users.id
WHERE user_chains.chain_id = ? AND users.is_email_verified = TRUE
`, chainID).Scan(&results).Error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func TestUserGetAllOfChainRoutePrivacyMutiple0(t *testing.T) {
return actualUser.UID == expectedUser.UID
})
if !ok {
assert.Truef(t, ok, "expected user %s not in %s", strings.Join(actualUserUIDs, ", "))
assert.Failf(t, "expected user %s not in %s", strings.Join(actualUserUIDs, ", "))
}
}
}
1 change: 0 additions & 1 deletion server/pkg/noderoute/noderoute.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ LOOP_NEW_KEYS:
}
}
nk.Keys = append(nk.Keys, newKey)

}
}

Expand Down
6 changes: 6 additions & 0 deletions server/pkg/noderoute/noderoute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@ func TestIndexCircular(t *testing.T) {

v = get(arr, -1)
assert.Equal(t, "c", v)

v = get(arr, 1)
assert.Equal(t, "b", v)

v = get(arr, 0)
assert.Equal(t, "a", v)
}

0 comments on commit 9a465e6

Please sign in to comment.