mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 05:12:26 +03:00
Fix response to federation /invite to match the format expected by synapse (#221)
* Fix response to /invite to match the format expected by synapse * gb vendor update github.com/matrix-org/gomatrixserverlib * Use gomatrixserverlib.RespInvite * gb vendor update github.com/matrix-org/gomatrixserverlib
This commit is contained in:
parent
5740cb3e58
commit
6cb9d900b9
21 changed files with 148 additions and 64 deletions
|
@ -2,11 +2,12 @@ package gomatrixserverlib
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/matrix-org/gomatrix"
|
||||
"golang.org/x/crypto/ed25519"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
"golang.org/x/crypto/ed25519"
|
||||
)
|
||||
|
||||
// An FederationClient is a matrix federation client that adds
|
||||
|
@ -42,7 +43,7 @@ func (ac *FederationClient) doRequest(r FederationRequest, resBody interface{})
|
|||
|
||||
res, err := ac.client.Do(req)
|
||||
if res != nil {
|
||||
defer res.Body.Close()
|
||||
defer res.Body.Close() // nolint: errcheck
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -76,6 +77,10 @@ func (ac *FederationClient) doRequest(r FederationRequest, resBody interface{})
|
|||
return err
|
||||
}
|
||||
|
||||
if resBody == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return json.Unmarshal(contents, resBody)
|
||||
}
|
||||
|
||||
|
@ -124,6 +129,22 @@ func (ac *FederationClient) SendJoin(s ServerName, event Event) (res RespSendJoi
|
|||
return
|
||||
}
|
||||
|
||||
// ExchangeThirdPartyInvite sends the builder of a m.room.member event of
|
||||
// "invite" membership derived from a response from invites sent by an identity
|
||||
// server.
|
||||
// This is used to exchange a m.room.third_party_invite event for a m.room.member
|
||||
// one in a room the local server isn't a member of.
|
||||
func (ac *FederationClient) ExchangeThirdPartyInvite(s ServerName, builder EventBuilder) (err error) {
|
||||
path := "/_matrix/federation/v1/exchange_third_party_invite/" +
|
||||
url.PathEscape(builder.RoomID)
|
||||
req := NewFederationRequest("PUT", s, path)
|
||||
if err = req.SetContent(builder); err != nil {
|
||||
return
|
||||
}
|
||||
err = ac.doRequest(req, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// LookupState retrieves the room state for a room at an event from a
|
||||
// remote matrix server as full matrix events.
|
||||
func (ac *FederationClient) LookupState(s ServerName, roomID, eventID string) (res RespState, err error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue