mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-10 16:33:11 -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 {
|
||||
if httpReq.Method == "GET" {
|
||||
limit, err := strconv.Atoi(httpReq.FormValue("limit"))
|
||||
|
|
|
|||
|
|
@ -113,13 +113,12 @@ func (r *RoomserverPublicRoomAPI) GetPublicRooms(
|
|||
var offset int64
|
||||
|
||||
limit = req.Limit
|
||||
ofst, err := strconv.Atoi(req.Since)
|
||||
// Atoi returns 0 and an error when trying to parse an empty string
|
||||
offset, err := strconv.ParseInt(req.Since, 10, 64)
|
||||
// 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
|
||||
if err != nil && len(req.Since) > 0 {
|
||||
return err
|
||||
}
|
||||
offset = int64(ofst)
|
||||
|
||||
roomIDs, err := r.DB.GetPublicRoomIDs()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue