mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-12 01:13:10 -06:00
Doc + use ParseInt instead of Atoi in roomserver
This commit is contained in:
parent
f4a53ee54b
commit
a99f7de70f
|
|
@ -89,6 +89,8 @@ func GetPublicRooms(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fillPublicRoomsReq fills the Limit, Since and Filter attributes of a request to the roomserver's
|
||||||
|
// GetPublicRooms API by parsing the incoming HTTP request
|
||||||
func fillPublicRoomsReq(httpReq *http.Request, queryReq *api.GetPublicRoomsRequest) *util.JSONResponse {
|
func fillPublicRoomsReq(httpReq *http.Request, queryReq *api.GetPublicRoomsRequest) *util.JSONResponse {
|
||||||
if httpReq.Method == "GET" {
|
if httpReq.Method == "GET" {
|
||||||
limit, err := strconv.Atoi(httpReq.FormValue("limit"))
|
limit, err := strconv.Atoi(httpReq.FormValue("limit"))
|
||||||
|
|
|
||||||
|
|
@ -113,13 +113,12 @@ func (r *RoomserverPublicRoomAPI) GetPublicRooms(
|
||||||
var offset int64
|
var offset int64
|
||||||
|
|
||||||
limit = req.Limit
|
limit = req.Limit
|
||||||
ofst, err := strconv.Atoi(req.Since)
|
offset, err := strconv.ParseInt(req.Since, 10, 64)
|
||||||
// Atoi returns 0 and an error when trying to parse an empty string
|
// ParseInt returns 0 and an error when trying to parse an empty string
|
||||||
// In that case, we want to assign 0 so we ignore the error
|
// In that case, we want to assign 0 so we ignore the error
|
||||||
if err != nil && len(req.Since) > 0 {
|
if err != nil && len(req.Since) > 0 {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
offset = int64(ofst)
|
|
||||||
|
|
||||||
roomIDs, err := r.DB.GetPublicRoomIDs()
|
roomIDs, err := r.DB.GetPublicRoomIDs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue