Fix profile view follow & ban status, Add ban status in GET profile API call

This commit is contained in:
Marco Realacci 2022-12-12 12:37:30 +01:00
parent 00e6b3de7b
commit 4c4481393d
8 changed files with 39 additions and 16 deletions

View file

@ -54,12 +54,21 @@ func (db *appdbimpl) GetUserProfile(uid string, requesting_uid string) (QueryRes
return ERR_INTERNAL, nil, err
}
// Get ban status
var ban_status bool
err = db.c.QueryRow(`SELECT EXISTS (SELECT * FROM "bans" WHERE "user" = ? AND "ban" = ?)`, requesting_uid, uid).Scan(&ban_status)
if err != nil {
return ERR_INTERNAL, nil, err
}
return SUCCESS, &structures.UserProfile{
UID: uid,
Name: name,
Following: following,
Followers: followers,
Followed: follow_status,
Banned: ban_status,
Photos: photos,
}, nil
}

View file

@ -290,15 +290,15 @@ func (db *appdbimpl) SearchByName(name string, requesting_uid string, start_inde
(
SELECT EXISTS(
SELECT * FROM "follows" AS "f"
WHERE "f"."follower" = "users"."uid"
AND "f"."followed" = ?
WHERE "f"."follower" = ?
AND "f"."followed" = "users"."uid"
)
),
(
SELECT EXISTS(
SELECT * FROM "bans" AS "b"
WHERE "b"."user" = "users"."uid"
AND "b"."ban" = ?
WHERE "b"."user" = ?
AND "b"."ban" = "users"."uid"
)
)