Fix GetUserFollowers returning wrong user's followers

This commit is contained in:
Marco Realacci 2023-01-15 15:22:40 +01:00
parent 7812304be8
commit c0ba5011b5

View file

@ -125,7 +125,7 @@ func (db *appdbimpl) GetUserFollowers(uid string, requesting_uid string, start_i
AND "followed" = ?
LIMIT ?
OFFSET ?`, uid, requesting_uid, limit, start_index)
OFFSET ?`, requesting_uid, uid, limit, start_index)
followers, err := db.uidNameQuery(rows, err)
@ -137,7 +137,7 @@ func (db *appdbimpl) GetUserFollowers(uid string, requesting_uid string, start_i
}
// Get user following
func (db *appdbimpl) GetUserFollowing(uid string, requesting_uid string, start_index int, offset int) (QueryResult, *[]structures.UIDName, error) {
func (db *appdbimpl) GetUserFollowing(uid string, requesting_uid string, start_index int, limit int) (QueryResult, *[]structures.UIDName, error) {
// user may exist but have no followers
exists, err := db.UserExistsNotBanned(uid, requesting_uid)
@ -150,7 +150,7 @@ func (db *appdbimpl) GetUserFollowing(uid string, requesting_uid string, start_i
return ERR_NOT_FOUND, nil, nil
}
rows, err := db.c.Query(`SELECT "followed", "user"."name" FROM "follows", "users"
rows, err := db.c.Query(`SELECT "followed", "users"."name" FROM "follows", "users"
WHERE "follows"."followed" = "users"."uid"
AND "follows"."followed" NOT IN (
@ -161,7 +161,7 @@ func (db *appdbimpl) GetUserFollowing(uid string, requesting_uid string, start_i
AND "follower" = ?
LIMIT ?
OFFSET ?`, uid, requesting_uid, offset, start_index)
OFFSET ?`, requesting_uid, uid, limit, start_index)
following, err := db.uidNameQuery(rows, err)