mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-03 06:32:47 +00:00
Federation fixes for virtual hosting
This commit is contained in:
parent
f4ee397734
commit
6650712a1c
73 changed files with 736 additions and 420 deletions
|
@ -90,7 +90,17 @@ func CreateInvitesFrom3PIDInvites(
|
|||
}
|
||||
|
||||
// Send all the events
|
||||
if err := api.SendEvents(req.Context(), rsAPI, api.KindNew, evs, "TODO", cfg.Matrix.ServerName, nil, false); err != nil {
|
||||
if err := api.SendEvents(
|
||||
req.Context(),
|
||||
rsAPI,
|
||||
api.KindNew,
|
||||
evs,
|
||||
cfg.Matrix.ServerName, // TODO: which virtual host?
|
||||
"TODO",
|
||||
cfg.Matrix.ServerName,
|
||||
nil,
|
||||
false,
|
||||
); err != nil {
|
||||
util.GetLogger(req.Context()).WithError(err).Error("SendEvents failed")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
@ -126,6 +136,14 @@ func ExchangeThirdPartyInvite(
|
|||
}
|
||||
}
|
||||
|
||||
_, senderDomain, err := cfg.Matrix.SplitLocalID('@', builder.Sender)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
JSON: jsonerror.BadJSON("Invalid sender ID: " + err.Error()),
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the state key is correct.
|
||||
_, targetDomain, err := gomatrixserverlib.SplitID('@', *builder.StateKey)
|
||||
if err != nil {
|
||||
|
@ -171,7 +189,7 @@ func ExchangeThirdPartyInvite(
|
|||
util.GetLogger(httpReq.Context()).WithError(err).Error("failed to make invite v2 request")
|
||||
return jsonerror.InternalServerError()
|
||||
}
|
||||
signedEvent, err := federation.SendInviteV2(httpReq.Context(), request.Origin(), inviteReq)
|
||||
signedEvent, err := federation.SendInviteV2(httpReq.Context(), senderDomain, request.Origin(), inviteReq)
|
||||
if err != nil {
|
||||
util.GetLogger(httpReq.Context()).WithError(err).Error("federation.SendInvite failed")
|
||||
return jsonerror.InternalServerError()
|
||||
|
@ -189,6 +207,7 @@ func ExchangeThirdPartyInvite(
|
|||
[]*gomatrixserverlib.HeaderedEvent{
|
||||
inviteEvent.Headered(verRes.RoomVersion),
|
||||
},
|
||||
request.Destination(),
|
||||
request.Origin(),
|
||||
cfg.Matrix.ServerName,
|
||||
nil,
|
||||
|
@ -341,7 +360,7 @@ func buildMembershipEvent(
|
|||
// them responded with an error.
|
||||
func sendToRemoteServer(
|
||||
ctx context.Context, inv invite,
|
||||
federation federationAPI.FederationClient, _ *config.FederationAPI,
|
||||
federation federationAPI.FederationClient, cfg *config.FederationAPI,
|
||||
builder gomatrixserverlib.EventBuilder,
|
||||
) (err error) {
|
||||
remoteServers := make([]gomatrixserverlib.ServerName, 2)
|
||||
|
@ -357,7 +376,7 @@ func sendToRemoteServer(
|
|||
}
|
||||
|
||||
for _, server := range remoteServers {
|
||||
err = federation.ExchangeThirdPartyInvite(ctx, server, builder)
|
||||
err = federation.ExchangeThirdPartyInvite(ctx, cfg.Matrix.ServerName, server, builder)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue