mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Add start_index & limit to GetFollowersFollowing
This commit is contained in:
parent
c134becb61
commit
77e9f405c6
3 changed files with 21 additions and 9 deletions
|
@ -25,13 +25,21 @@ func (rt *_router) GetFollowersFollowing(w http.ResponseWriter, r *http.Request,
|
|||
var err error
|
||||
var status database.QueryResult
|
||||
|
||||
// Get limits, or use default values
|
||||
start_index, limit, err := helpers.GetLimits(r.URL.Query())
|
||||
|
||||
if err != nil {
|
||||
helpers.SendBadRequest(w, "Invalid start_index or limit", rt.baseLogger)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if client is asking for followers or following
|
||||
if strings.HasSuffix(r.URL.Path, "/followers") {
|
||||
// Get the followers from the database
|
||||
status, users, err = rt.db.GetUserFollowers(uid, ctx.Auth.GetUserID())
|
||||
status, users, err = rt.db.GetUserFollowers(uid, ctx.Auth.GetUserID(), start_index, limit)
|
||||
} else {
|
||||
// Get the following users from the database
|
||||
status, users, err = rt.db.GetUserFollowing(uid, ctx.Auth.GetUserID())
|
||||
status, users, err = rt.db.GetUserFollowing(uid, ctx.Auth.GetUserID(), start_index, limit)
|
||||
}
|
||||
|
||||
// Send a 500 response if there was an error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue