mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-20 12:33:09 -06:00
Fix relay linter errors
This commit is contained in:
parent
0875ba2073
commit
fc365a3e06
|
|
@ -79,5 +79,5 @@ type QueryAsyncTransactionsRequest struct {
|
||||||
type QueryAsyncTransactionsResponse struct {
|
type QueryAsyncTransactionsResponse struct {
|
||||||
Txn gomatrixserverlib.Transaction `json:"transaction"`
|
Txn gomatrixserverlib.Transaction `json:"transaction"`
|
||||||
EntryID int64 `json:"entry_id"`
|
EntryID int64 `json:"entry_id"`
|
||||||
EntriesQueued bool `json:entries_queued`
|
EntriesQueued bool `json:"entries_queued"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,10 @@ import (
|
||||||
func createAsyncQuery(
|
func createAsyncQuery(
|
||||||
userID gomatrixserverlib.UserID,
|
userID gomatrixserverlib.UserID,
|
||||||
prevEntry gomatrixserverlib.RelayEntry,
|
prevEntry gomatrixserverlib.RelayEntry,
|
||||||
relayServer gomatrixserverlib.ServerName,
|
|
||||||
) gomatrixserverlib.FederationRequest {
|
) gomatrixserverlib.FederationRequest {
|
||||||
var federationPathPrefixV1 = "/_matrix/federation/v1"
|
var federationPathPrefixV1 = "/_matrix/federation/v1"
|
||||||
path := federationPathPrefixV1 + "/async_events/" + userID.Raw()
|
path := federationPathPrefixV1 + "/async_events/" + userID.Raw()
|
||||||
request := gomatrixserverlib.NewFederationRequest("GET", userID.Domain(), relayServer, path)
|
request := gomatrixserverlib.NewFederationRequest("GET", userID.Domain(), "relay", path)
|
||||||
request.SetContent(prevEntry)
|
request.SetContent(prevEntry)
|
||||||
|
|
||||||
return request
|
return request
|
||||||
|
|
@ -47,7 +46,7 @@ func TestGetAsyncEmptyDatabaseReturnsNothing(t *testing.T) {
|
||||||
&db, nil, nil, nil, nil, false, "",
|
&db, nil, nil, nil, nil, false, "",
|
||||||
)
|
)
|
||||||
|
|
||||||
request := createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: -1}, "relay")
|
request := createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: -1})
|
||||||
response := routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
response := routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
|
|
@ -56,6 +55,7 @@ func TestGetAsyncEmptyDatabaseReturnsNothing(t *testing.T) {
|
||||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Txn)
|
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Txn)
|
||||||
|
|
||||||
count, err := db.GetAsyncTransactionCount(context.Background(), *userID)
|
count, err := db.GetAsyncTransactionCount(context.Background(), *userID)
|
||||||
|
assert.Nil(t, err)
|
||||||
assert.Zero(t, count)
|
assert.Zero(t, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ func TestGetAsyncReturnsSavedTransaction(t *testing.T) {
|
||||||
&db, nil, nil, nil, nil, false, "",
|
&db, nil, nil, nil, nil, false, "",
|
||||||
)
|
)
|
||||||
|
|
||||||
request := createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: -1}, "relay")
|
request := createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: -1})
|
||||||
response := routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
response := routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ func TestGetAsyncReturnsSavedTransaction(t *testing.T) {
|
||||||
assert.Equal(t, transaction, jsonResponse.Txn)
|
assert.Equal(t, transaction, jsonResponse.Txn)
|
||||||
|
|
||||||
// And once more to clear the queue
|
// And once more to clear the queue
|
||||||
request = createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: jsonResponse.EntryID}, "relay")
|
request = createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: jsonResponse.EntryID})
|
||||||
response = routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
response = routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
|
|
@ -105,6 +105,7 @@ func TestGetAsyncReturnsSavedTransaction(t *testing.T) {
|
||||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Txn)
|
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Txn)
|
||||||
|
|
||||||
count, err := db.GetAsyncTransactionCount(context.Background(), *userID)
|
count, err := db.GetAsyncTransactionCount(context.Background(), *userID)
|
||||||
|
assert.Nil(t, err)
|
||||||
assert.Zero(t, count)
|
assert.Zero(t, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +150,7 @@ func TestGetAsyncReturnsMultipleSavedTransactions(t *testing.T) {
|
||||||
&db, nil, nil, nil, nil, false, "",
|
&db, nil, nil, nil, nil, false, "",
|
||||||
)
|
)
|
||||||
|
|
||||||
request := createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: -1}, "relay")
|
request := createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: -1})
|
||||||
response := routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
response := routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
|
|
@ -157,7 +158,7 @@ func TestGetAsyncReturnsMultipleSavedTransactions(t *testing.T) {
|
||||||
assert.True(t, jsonResponse.EntriesQueued)
|
assert.True(t, jsonResponse.EntriesQueued)
|
||||||
assert.Equal(t, transaction, jsonResponse.Txn)
|
assert.Equal(t, transaction, jsonResponse.Txn)
|
||||||
|
|
||||||
request = createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: jsonResponse.EntryID}, "relay")
|
request = createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: jsonResponse.EntryID})
|
||||||
response = routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
response = routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
|
|
@ -166,7 +167,7 @@ func TestGetAsyncReturnsMultipleSavedTransactions(t *testing.T) {
|
||||||
assert.Equal(t, transaction2, jsonResponse.Txn)
|
assert.Equal(t, transaction2, jsonResponse.Txn)
|
||||||
|
|
||||||
// And once more to clear the queue
|
// And once more to clear the queue
|
||||||
request = createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: jsonResponse.EntryID}, "relay")
|
request = createAsyncQuery(*userID, gomatrixserverlib.RelayEntry{EntryID: jsonResponse.EntryID})
|
||||||
response = routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
response = routing.GetAsyncEvents(httpReq, &request, &relayAPI, *userID)
|
||||||
assert.Equal(t, http.StatusOK, response.Code)
|
assert.Equal(t, http.StatusOK, response.Code)
|
||||||
|
|
||||||
|
|
@ -175,5 +176,6 @@ func TestGetAsyncReturnsMultipleSavedTransactions(t *testing.T) {
|
||||||
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Txn)
|
assert.Equal(t, gomatrixserverlib.Transaction{}, jsonResponse.Txn)
|
||||||
|
|
||||||
count, err := db.GetAsyncTransactionCount(context.Background(), *userID)
|
count, err := db.GetAsyncTransactionCount(context.Background(), *userID)
|
||||||
|
assert.Nil(t, err)
|
||||||
assert.Zero(t, count)
|
assert.Zero(t, count)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,8 @@ func (d *Database) CleanAsyncTransactions(
|
||||||
}
|
}
|
||||||
|
|
||||||
err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
err = d.Writer.Do(d.DB, nil, func(txn *sql.Tx) error {
|
||||||
err := d.RelayQueueJSON.DeleteQueueJSON(ctx, txn, nids)
|
dbErr := d.RelayQueueJSON.DeleteQueueJSON(ctx, txn, nids)
|
||||||
return err
|
return dbErr
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("d.deleteQueueJSON: %w", err)
|
return fmt.Errorf("d.deleteQueueJSON: %w", err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue