mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-08 18:16:59 +00:00
Use gmsl relay_txn response type
This commit is contained in:
parent
f98003c030
commit
7b3334778f
@ -52,7 +52,7 @@ func (r *RelayInternalAPI) PerformRelayServerSync(
|
||||
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
r.processTransaction(&asyncResponse.Txn)
|
||||
r.processTransaction(&asyncResponse.Transaction)
|
||||
|
||||
prevEntry = gomatrixserverlib.RelayEntry{EntryID: asyncResponse.EntryID}
|
||||
for asyncResponse.EntriesQueued {
|
||||
@ -64,7 +64,7 @@ func (r *RelayInternalAPI) PerformRelayServerSync(
|
||||
logrus.Errorf("P2PGetTransactionFromRelay: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
r.processTransaction(&asyncResponse.Txn)
|
||||
r.processTransaction(&asyncResponse.Transaction)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -46,7 +46,7 @@ func (f *testFedClient) P2PGetTransactionFromRelay(
|
||||
}
|
||||
|
||||
res = gomatrixserverlib.RespGetRelayTransaction{
|
||||
Txn: gomatrixserverlib.Transaction{},
|
||||
Transaction: gomatrixserverlib.Transaction{},
|
||||
EntryID: 0,
|
||||
}
|
||||
if f.queueDepth > 0 {
|
||||
|
@ -25,12 +25,6 @@ import (
|
||||
"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}
|
||||
// This endpoint can be extracted into a separate relay server service.
|
||||
func GetTransactionFromRelay(
|
||||
@ -41,7 +35,7 @@ func GetTransactionFromRelay(
|
||||
) util.JSONResponse {
|
||||
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 {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
@ -65,7 +59,7 @@ func GetTransactionFromRelay(
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: RelayTransactionResponse{
|
||||
JSON: gomatrixserverlib.RespGetRelayTransaction{
|
||||
Transaction: response.Transaction,
|
||||
EntryID: response.EntryID,
|
||||
EntriesQueued: response.EntriesQueued,
|
||||
|
@ -64,7 +64,7 @@ func TestGetEmptyDatabaseReturnsNothing(t *testing.T) {
|
||||
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||
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, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
||||
|
||||
@ -130,7 +130,7 @@ func TestGetReturnsSavedTransaction(t *testing.T) {
|
||||
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||
assert.Equal(t, http.StatusOK, response.Code)
|
||||
|
||||
jsonResponse := response.JSON.(routing.RelayTransactionResponse)
|
||||
jsonResponse := response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||
assert.True(t, jsonResponse.EntriesQueued)
|
||||
assert.Equal(t, transaction, jsonResponse.Transaction)
|
||||
|
||||
@ -139,7 +139,7 @@ func TestGetReturnsSavedTransaction(t *testing.T) {
|
||||
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||
assert.Equal(t, http.StatusOK, response.Code)
|
||||
|
||||
jsonResponse = response.JSON.(routing.RelayTransactionResponse)
|
||||
jsonResponse = response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||
assert.False(t, jsonResponse.EntriesQueued)
|
||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
||||
|
||||
@ -193,7 +193,7 @@ func TestGetReturnsMultipleSavedTransactions(t *testing.T) {
|
||||
response := routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||
assert.Equal(t, http.StatusOK, response.Code)
|
||||
|
||||
jsonResponse := response.JSON.(routing.RelayTransactionResponse)
|
||||
jsonResponse := response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||
assert.True(t, jsonResponse.EntriesQueued)
|
||||
assert.Equal(t, transaction, jsonResponse.Transaction)
|
||||
|
||||
@ -201,7 +201,7 @@ func TestGetReturnsMultipleSavedTransactions(t *testing.T) {
|
||||
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||
assert.Equal(t, http.StatusOK, response.Code)
|
||||
|
||||
jsonResponse = response.JSON.(routing.RelayTransactionResponse)
|
||||
jsonResponse = response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||
assert.True(t, jsonResponse.EntriesQueued)
|
||||
assert.Equal(t, transaction2, jsonResponse.Transaction)
|
||||
|
||||
@ -210,7 +210,7 @@ func TestGetReturnsMultipleSavedTransactions(t *testing.T) {
|
||||
response = routing.GetTransactionFromRelay(httpReq, &request, relayAPI, *userID)
|
||||
assert.Equal(t, http.StatusOK, response.Code)
|
||||
|
||||
jsonResponse = response.JSON.(routing.RelayTransactionResponse)
|
||||
jsonResponse = response.JSON.(gomatrixserverlib.RespGetRelayTransaction)
|
||||
assert.False(t, jsonResponse.EntriesQueued)
|
||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Transaction)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user