mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
refactor: update GMSL (#3058)
Sister PR to https://github.com/matrix-org/gomatrixserverlib/pull/364 Read this commit by commit to avoid going insane.
This commit is contained in:
parent
9fa39263c0
commit
72285b2659
306 changed files with 2117 additions and 1934 deletions
|
@ -26,6 +26,8 @@ import (
|
|||
relayInternal "github.com/matrix-org/dendrite/relayapi/internal"
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"github.com/matrix-org/gomatrixserverlib/fclient"
|
||||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
"github.com/matrix-org/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -44,7 +46,7 @@ func Setup(
|
|||
|
||||
v1fedmux.Handle("/send_relay/{txnID}/{userID}", MakeRelayAPI(
|
||||
"send_relay_transaction", "", cfg.Matrix.IsLocalServerName, keys,
|
||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest, vars map[string]string) util.JSONResponse {
|
||||
func(httpReq *http.Request, request *fclient.FederationRequest, vars map[string]string) util.JSONResponse {
|
||||
logrus.Infof("Handling send_relay from: %s", request.Origin())
|
||||
if !relayAPI.RelayingEnabled() {
|
||||
logrus.Warnf("Dropping send_relay from: %s", request.Origin())
|
||||
|
@ -53,7 +55,7 @@ func Setup(
|
|||
}
|
||||
}
|
||||
|
||||
userID, err := gomatrixserverlib.NewUserID(vars["userID"], false)
|
||||
userID, err := spec.NewUserID(vars["userID"], false)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
@ -69,7 +71,7 @@ func Setup(
|
|||
|
||||
v1fedmux.Handle("/relay_txn/{userID}", MakeRelayAPI(
|
||||
"get_relay_transaction", "", cfg.Matrix.IsLocalServerName, keys,
|
||||
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest, vars map[string]string) util.JSONResponse {
|
||||
func(httpReq *http.Request, request *fclient.FederationRequest, vars map[string]string) util.JSONResponse {
|
||||
logrus.Infof("Handling relay_txn from: %s", request.Origin())
|
||||
if !relayAPI.RelayingEnabled() {
|
||||
logrus.Warnf("Dropping relay_txn from: %s", request.Origin())
|
||||
|
@ -78,7 +80,7 @@ func Setup(
|
|||
}
|
||||
}
|
||||
|
||||
userID, err := gomatrixserverlib.NewUserID(vars["userID"], false)
|
||||
userID, err := spec.NewUserID(vars["userID"], false)
|
||||
if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusBadRequest,
|
||||
|
@ -92,13 +94,13 @@ func Setup(
|
|||
|
||||
// MakeRelayAPI makes an http.Handler that checks matrix relay authentication.
|
||||
func MakeRelayAPI(
|
||||
metricsName string, serverName gomatrixserverlib.ServerName,
|
||||
isLocalServerName func(gomatrixserverlib.ServerName) bool,
|
||||
metricsName string, serverName spec.ServerName,
|
||||
isLocalServerName func(spec.ServerName) bool,
|
||||
keyRing gomatrixserverlib.JSONVerifier,
|
||||
f func(*http.Request, *gomatrixserverlib.FederationRequest, map[string]string) util.JSONResponse,
|
||||
f func(*http.Request, *fclient.FederationRequest, map[string]string) util.JSONResponse,
|
||||
) http.Handler {
|
||||
h := func(req *http.Request) util.JSONResponse {
|
||||
fedReq, errResp := gomatrixserverlib.VerifyHTTPRequest(
|
||||
fedReq, errResp := fclient.VerifyHTTPRequest(
|
||||
req, time.Now(), serverName, isLocalServerName, keyRing,
|
||||
)
|
||||
if fedReq == nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue