aboutsummaryrefslogtreecommitdiff
path: root/syncapi/routing/routing.go
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-26 15:34:41 +0100
committerGitHub <noreply@github.com>2020-06-26 15:34:41 +0100
commit1ad7219e4b6c71f64e4d44db17a6a8d729e6198a (patch)
treec13db3fd184c0c9bd7d879793be7e5aba2066121 /syncapi/routing/routing.go
parent164057a3be1e666d6fb68398d616da9a8a665a18 (diff)
Implement /sync `limited` and read timeline limit from stored filters (#1168)
* Move filter table to syncapi where it is used * Implement /sync `limited` and read timeline limit from stored filters We now fully handle `room.timeline.limit` filters (in-line + stored) and return the right value for `limited` syncs. * Update whitelist * Default to the default timeline limit if it's unset, also strip the extra event correctly * Update whitelist
Diffstat (limited to 'syncapi/routing/routing.go')
-rw-r--r--syncapi/routing/routing.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/syncapi/routing/routing.go b/syncapi/routing/routing.go
index 5744de05..a98955c5 100644
--- a/syncapi/routing/routing.go
+++ b/syncapi/routing/routing.go
@@ -55,4 +55,24 @@ func Setup(
}
return OnIncomingMessagesRequest(req, syncDB, vars["roomID"], federation, rsAPI, cfg)
})).Methods(http.MethodGet, http.MethodOptions)
+
+ r0mux.Handle("/user/{userId}/filter",
+ httputil.MakeAuthAPI("put_filter", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
+ vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
+ if err != nil {
+ return util.ErrorResponse(err)
+ }
+ return PutFilter(req, device, syncDB, vars["userId"])
+ }),
+ ).Methods(http.MethodPost, http.MethodOptions)
+
+ r0mux.Handle("/user/{userId}/filter/{filterId}",
+ httputil.MakeAuthAPI("get_filter", userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
+ vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
+ if err != nil {
+ return util.ErrorResponse(err)
+ }
+ return GetFilter(req, device, syncDB, vars["userId"], vars["filterId"])
+ }),
+ ).Methods(http.MethodGet, http.MethodOptions)
}