diff --git a/vendor/manifest b/vendor/manifest index a15048537..aa13b1c5d 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -148,7 +148,7 @@ { "importpath": "github.com/matrix-org/gomatrixserverlib", "repository": "https://github.com/matrix-org/gomatrixserverlib", - "revision": "677bbe93ffc9ad9ba5de615cd81185d0493f5d25", + "revision": "1c2cbc0872f0b2f19929dd70d22f77486078641e", "branch": "master" }, { diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/federationclient.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/federationclient.go index bcc68b2e1..09398903e 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/federationclient.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/federationclient.go @@ -3,6 +3,7 @@ package gomatrixserverlib import ( "context" "net/url" + "strconv" "golang.org/x/crypto/ed25519" ) @@ -170,3 +171,33 @@ func (ac *FederationClient) LookupRoomAlias( err = ac.doRequest(ctx, req, &res) return } + +// Backfill asks a homeserver for events early enough for them to not be in the +// local database. +// See https://matrix.org/docs/spec/server_server/unstable.html#get-matrix-federation-v1-backfill-roomid +func (ac *FederationClient) Backfill( + ctx context.Context, s ServerName, roomID string, limit int, eventIDs []string, +) (res Transaction, err error) { + // Encode the room ID so it won't interfer with the path. + roomID = url.PathEscape(roomID) + + // Parse the limit into a string so that we can include it in the URL's query. + limitStr := strconv.Itoa(limit) + + // Define the URL's query. + query := url.Values{} + query["v"] = eventIDs + query.Set("limit", limitStr) + + // Use the url.URL structure to easily generate the request's URI (path?query). + u := url.URL{ + Path: "/_matrix/federation/v1/backfill/" + roomID + "/", + RawQuery: query.Encode(), + } + path := u.RequestURI() + + // Send the request. + req := NewFederationRequest("GET", s, path) + err = ac.doRequest(ctx, req, &res) + return +}