MCPcopy Create free account
hub / github.com/daodst/chat / parseRoomEventFilter

Function parseRoomEventFilter

syncapi/routing/context.go:216–240  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

214}
215
216func parseRoomEventFilter(req *http.Request) (*gomatrixserverlib.RoomEventFilter, error) {
217 // Default room filter
218 filter := &gomatrixserverlib.RoomEventFilter{Limit: 10}
219
220 l := req.URL.Query().Get("limit")
221 f := req.URL.Query().Get("filter")
222 if l != "" {
223 limit, err := strconv.Atoi(l)
224 if err != nil {
225 return nil, err
226 }
227 // NOTSPEC: feels like a good idea to have an upper bound limit
228 if limit > 100 {
229 limit = 100
230 }
231 filter.Limit = limit
232 }
233 if f != "" {
234 if err := json.Unmarshal([]byte(f), &filter); err != nil {
235 return nil, err
236 }
237 }
238
239 return filter, nil
240}

Callers 3

Test_parseContextParamsFunction · 0.85
ContextFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by 1

Test_parseContextParamsFunction · 0.68