mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Merge branch 'main' into roomserver-pub-pkey-migration
This commit is contained in:
commit
b8ed5d42f2
2
go.mod
2
go.mod
|
|
@ -22,7 +22,7 @@ require (
|
||||||
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
||||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230119205614-cb888d80b00f
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230131183213-122f1e0e3fa1
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230111184901-61850f0e63cb
|
github.com/matrix-org/pinecone v0.11.1-0.20230111184901-61850f0e63cb
|
||||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
||||||
github.com/mattn/go-sqlite3 v1.14.15
|
github.com/mattn/go-sqlite3 v1.14.15
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -327,8 +327,8 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91 h1:s7fexw
|
||||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
|
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U=
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230119205614-cb888d80b00f h1:niRWEVkeeekpjxwnMhKn8PD0PUloDsNXP8W+Ez/co/M=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230131183213-122f1e0e3fa1 h1:JSw0nmjMrgBmoM2aQsa78LTpI5BnuD9+vOiEQ4Qo0qw=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230119205614-cb888d80b00f/go.mod h1:Mtifyr8q8htcBeugvlDnkBcNUy5LO8OzUoplAf1+mb4=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230131183213-122f1e0e3fa1/go.mod h1:Mtifyr8q8htcBeugvlDnkBcNUy5LO8OzUoplAf1+mb4=
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230111184901-61850f0e63cb h1:2L+ltfNKab56FoBBqAvbBLjoAbxwwoZie+B8d+Mp3JI=
|
github.com/matrix-org/pinecone v0.11.1-0.20230111184901-61850f0e63cb h1:2L+ltfNKab56FoBBqAvbBLjoAbxwwoZie+B8d+Mp3JI=
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230111184901-61850f0e63cb/go.mod h1:F3GHppRuHCTDeoOmmgjZMeJdbql91+RSGGsATWfC7oc=
|
github.com/matrix-org/pinecone v0.11.1-0.20230111184901-61850f0e63cb/go.mod h1:F3GHppRuHCTDeoOmmgjZMeJdbql91+RSGGsATWfC7oc=
|
||||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ func (r *RelayInternalAPI) PerformRelayServerSync(
|
||||||
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.processTransaction(&asyncResponse.Txn)
|
r.processTransaction(&asyncResponse.Transaction)
|
||||||
|
|
||||||
prevEntry = gomatrixserverlib.RelayEntry{EntryID: asyncResponse.EntryID}
|
prevEntry = gomatrixserverlib.RelayEntry{EntryID: asyncResponse.EntryID}
|
||||||
for asyncResponse.EntriesQueued {
|
for asyncResponse.EntriesQueued {
|
||||||
|
|
@ -64,7 +64,7 @@ func (r *RelayInternalAPI) PerformRelayServerSync(
|
||||||
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.processTransaction(&asyncResponse.Txn)
|
r.processTransaction(&asyncResponse.Transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ func (f *testFedClient) P2PGetTransactionFromRelay(
|
||||||
}
|
}
|
||||||
|
|
||||||
res = gomatrixserverlib.RespGetRelayTransaction{
|
res = gomatrixserverlib.RespGetRelayTransaction{
|
||||||
Txn: gomatrixserverlib.Transaction{},
|
Transaction: gomatrixserverlib.Transaction{},
|
||||||
EntryID: 0,
|
EntryID: 0,
|
||||||
}
|
}
|
||||||
if f.queueDepth > 0 {
|
if f.queueDepth > 0 {
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RelayTransactionResponse struct {
|
|
||||||
Transaction gomatrixserverlib.Transaction `json:"transaction"`
|
|
||||||
EntryID int64 `json:"entry_id,omitempty"`
|
|
||||||
EntriesQueued bool `json:"entries_queued"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTransactionFromRelay implements GET /_matrix/federation/v1/relay_txn/{userID}
|
// GetTransactionFromRelay implements GET /_matrix/federation/v1/relay_txn/{userID}
|
||||||
// This endpoint can be extracted into a separate relay server service.
|
// This endpoint can be extracted into a separate relay server service.
|
||||||
func GetTransactionFromRelay(
|
func GetTransactionFromRelay(
|
||||||
|
|
@ -41,7 +35,7 @@ func GetTransactionFromRelay(
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
logrus.Infof("Processing relay_txn for %s", userID.Raw())
|
logrus.Infof("Processing relay_txn for %s", userID.Raw())
|
||||||
|
|
||||||
previousEntry := gomatrixserverlib.RelayEntry{}
|
var previousEntry gomatrixserverlib.RelayEntry
|
||||||
if err := json.Unmarshal(fedReq.Content(), &previousEntry); err != nil {
|
if err := json.Unmarshal(fedReq.Content(), &previousEntry); err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
|
|
@ -65,7 +59,7 @@ func GetTransactionFromRelay(
|
||||||
|
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
JSON: RelayTransactionResponse{
|
JSON: gomatrixserverlib.RespGetRelayTransaction{
|
||||||
Transaction: response.Transaction,
|
Transaction: response.Transaction,
|
||||||
EntryID: response.EntryID,
|
EntryID: response.EntryID,
|
||||||
EntriesQueued: response.EntriesQueued,
|
EntriesQueued: response.EntriesQueued,
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ func TestGetEmptyDatabaseReturnsNothing(t *testing.T) {
|
||||||
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
jsonResponse := response.JSON.(routing.RelayTransactionResponse)
|
jsonResponse := response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||||
assert.Equal(t, false, jsonResponse.EntriesQueued)
|
assert.Equal(t, false, jsonResponse.EntriesQueued)
|
||||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@ func TestGetReturnsSavedTransaction(t *testing.T) {
|
||||||
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
jsonResponse := response.JSON.(routing.RelayTransactionResponse)
|
jsonResponse := response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||||
assert.True(t, jsonResponse.EntriesQueued)
|
assert.True(t, jsonResponse.EntriesQueued)
|
||||||
assert.Equal(t, transaction, jsonResponse.Transaction)
|
assert.Equal(t, transaction, jsonResponse.Transaction)
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ func TestGetReturnsSavedTransaction(t *testing.T) {
|
||||||
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
jsonResponse = response.JSON.(routing.RelayTransactionResponse)
|
jsonResponse = response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||||
assert.False(t, jsonResponse.EntriesQueued)
|
assert.False(t, jsonResponse.EntriesQueued)
|
||||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
||||||
|
|
||||||
|
|
@ -193,7 +193,7 @@ func TestGetReturnsMultipleSavedTransactions(t *testing.T) {
|
||||||
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
jsonResponse := response.JSON.(routing.RelayTransactionResponse)
|
jsonResponse := response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||||
assert.True(t, jsonResponse.EntriesQueued)
|
assert.True(t, jsonResponse.EntriesQueued)
|
||||||
assert.Equal(t, transaction, jsonResponse.Transaction)
|
assert.Equal(t, transaction, jsonResponse.Transaction)
|
||||||
|
|
||||||
|
|
@ -201,7 +201,7 @@ func TestGetReturnsMultipleSavedTransactions(t *testing.T) {
|
||||||
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
jsonResponse = response.JSON.(routing.RelayTransactionResponse)
|
jsonResponse = response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||||
assert.True(t, jsonResponse.EntriesQueued)
|
assert.True(t, jsonResponse.EntriesQueued)
|
||||||
assert.Equal(t, transaction2, jsonResponse.Transaction)
|
assert.Equal(t, transaction2, jsonResponse.Transaction)
|
||||||
|
|
||||||
|
|
@ -210,7 +210,7 @@ func TestGetReturnsMultipleSavedTransactions(t *testing.T) {
|
||||||
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
jsonResponse = response.JSON.(routing.RelayTransactionResponse)
|
jsonResponse = response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||||
assert.False(t, jsonResponse.EntriesQueued)
|
assert.False(t, jsonResponse.EntriesQueued)
|
||||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,7 @@ func SendTransactionToRelay(
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
logrus.Infof("Processing send_relay for %s", userID.Raw())
|
logrus.Infof("Processing send_relay for %s", userID.Raw())
|
||||||
|
|
||||||
var txnEvents struct {
|
var txnEvents gomatrixserverlib.RelayEvents
|
||||||
PDUs []json.RawMessage `json:"pdus"`
|
|
||||||
EDUs []gomatrixserverlib.EDU `json:"edus"`
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := json.Unmarshal(fedReq.Content(), &txnEvents); err != nil {
|
if err := json.Unmarshal(fedReq.Content(), &txnEvents); err != nil {
|
||||||
logrus.Info("The request body could not be decoded into valid JSON." + err.Error())
|
logrus.Info("The request body could not be decoded into valid JSON." + err.Error())
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue