aboutsummaryrefslogtreecommitdiff
path: root/federationsender/inthttp/client.go
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-12-04 14:11:01 +0000
committerGitHub <noreply@github.com>2020-12-04 14:11:01 +0000
commitb507312d4cf9d35b5d4eaaa01a7f74d095b825f8 (patch)
tree2812bd7453da07a3c2850fb0b27a740c950af212 /federationsender/inthttp/client.go
parentc052edafdd765d821f9732add4f5d33962ba5ba4 (diff)
MSC2836 threading: part 2 (#1596)
* Update GMSL * Add MSC2836EventRelationships to fedsender * Call MSC2836EventRelationships in reqCtx * auth remote servers * Extract room ID and servers from previous events; refactor a bit * initial cut of federated threading * Use the right client/fed struct in the response * Add QueryAuthChain for use with MSC2836 * Add auth chain to federated response * Fix pointers * under CI: more logging and enable mscs, nil fix * Handle direction: up * Actually send message events to the roomserver.. * Add children and children_hash to unsigned, with tests * Add logic for exploring threads and tracking children; missing storage functions * Implement storage functions for children * Add fetchUnknownEvent * Do federated hits for include_children if we have unexplored children * Use /ev_rel rather than /event as the former includes child metadata * Remove cross-room threading impl * Enable MSC2836 in the p2p demo * Namespace mscs db * Enable msc2836 for ygg Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'federationsender/inthttp/client.go')
-rw-r--r--federationsender/inthttp/client.go51
1 files changed, 42 insertions, 9 deletions
diff --git a/federationsender/inthttp/client.go b/federationsender/inthttp/client.go
index e0783ee1..fe98ff33 100644
--- a/federationsender/inthttp/client.go
+++ b/federationsender/inthttp/client.go
@@ -23,15 +23,16 @@ const (
FederationSenderPerformServersAlivePath = "/federationsender/performServersAlive"
FederationSenderPerformBroadcastEDUPath = "/federationsender/performBroadcastEDU"
- FederationSenderGetUserDevicesPath = "/federationsender/client/getUserDevices"
- FederationSenderClaimKeysPath = "/federationsender/client/claimKeys"
- FederationSenderQueryKeysPath = "/federationsender/client/queryKeys"
- FederationSenderBackfillPath = "/federationsender/client/backfill"
- FederationSenderLookupStatePath = "/federationsender/client/lookupState"
- FederationSenderLookupStateIDsPath = "/federationsender/client/lookupStateIDs"
- FederationSenderGetEventPath = "/federationsender/client/getEvent"
- FederationSenderGetServerKeysPath = "/federationsender/client/getServerKeys"
- FederationSenderLookupServerKeysPath = "/federationsender/client/lookupServerKeys"
+ FederationSenderGetUserDevicesPath = "/federationsender/client/getUserDevices"
+ FederationSenderClaimKeysPath = "/federationsender/client/claimKeys"
+ FederationSenderQueryKeysPath = "/federationsender/client/queryKeys"
+ FederationSenderBackfillPath = "/federationsender/client/backfill"
+ FederationSenderLookupStatePath = "/federationsender/client/lookupState"
+ FederationSenderLookupStateIDsPath = "/federationsender/client/lookupStateIDs"
+ FederationSenderGetEventPath = "/federationsender/client/getEvent"
+ FederationSenderGetServerKeysPath = "/federationsender/client/getServerKeys"
+ FederationSenderLookupServerKeysPath = "/federationsender/client/lookupServerKeys"
+ FederationSenderEventRelationshipsPath = "/federationsender/client/msc2836eventRelationships"
)
// NewFederationSenderClient creates a FederationSenderInternalAPI implemented by talking to a HTTP POST API.
@@ -416,3 +417,35 @@ func (h *httpFederationSenderInternalAPI) LookupServerKeys(
}
return response.ServerKeys, nil
}
+
+type eventRelationships struct {
+ S gomatrixserverlib.ServerName
+ Req gomatrixserverlib.MSC2836EventRelationshipsRequest
+ RoomVer gomatrixserverlib.RoomVersion
+ Res gomatrixserverlib.MSC2836EventRelationshipsResponse
+ Err *api.FederationClientError
+}
+
+func (h *httpFederationSenderInternalAPI) MSC2836EventRelationships(
+ ctx context.Context, s gomatrixserverlib.ServerName, r gomatrixserverlib.MSC2836EventRelationshipsRequest,
+ roomVersion gomatrixserverlib.RoomVersion,
+) (res gomatrixserverlib.MSC2836EventRelationshipsResponse, err error) {
+ span, ctx := opentracing.StartSpanFromContext(ctx, "MSC2836EventRelationships")
+ defer span.Finish()
+
+ request := eventRelationships{
+ S: s,
+ Req: r,
+ RoomVer: roomVersion,
+ }
+ var response eventRelationships
+ apiURL := h.federationSenderURL + FederationSenderEventRelationshipsPath
+ err = httputil.PostJSON(ctx, span, h.httpClient, apiURL, &request, &response)
+ if err != nil {
+ return res, err
+ }
+ if response.Err != nil {
+ return res, response.Err
+ }
+ return response.Res, nil
+}