Merge branch 'main' into s7evink/retiredinvites

This commit is contained in:
Till 2022-10-20 19:41:36 +02:00 committed by GitHub
commit 0146e9a49d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -1004,9 +1004,12 @@ func TestQueueInteractsWithRealDatabasePDUAndEDU(t *testing.T) {
err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination}) err := queues.SendEvent(ev, "localhost", []gomatrixserverlib.ServerName{destination})
assert.NoError(t, err) assert.NoError(t, err)
// NOTE : The server can be blacklisted before this, so manually inject the event
// into the database.
edu := mustCreateEDU(t) edu := mustCreateEDU(t)
errEDU := queues.SendEDU(edu, "localhost", []gomatrixserverlib.ServerName{destination}) ephemeralJSON, _ := json.Marshal(edu)
assert.NoError(t, errEDU) nid, _ := db.StoreJSON(pc.Context(), string(ephemeralJSON))
db.AssociateEDUWithDestination(pc.Context(), destination, nid, edu.Type, nil)
checkBlacklisted := func(log poll.LogT) poll.Result { checkBlacklisted := func(log poll.LogT) poll.Result {
if fc.txCount.Load() == failuresUntilBlacklist { if fc.txCount.Load() == failuresUntilBlacklist {

View file

@ -472,7 +472,9 @@ func (a *KeyInternalAPI) queryRemoteKeys(
close(resultCh) close(resultCh)
}() }()
for result := range resultCh { processResult := func(result *gomatrixserverlib.RespQueryKeys) {
respMu.Lock()
defer respMu.Unlock()
for userID, nest := range result.DeviceKeys { for userID, nest := range result.DeviceKeys {
res.DeviceKeys[userID] = make(map[string]json.RawMessage) res.DeviceKeys[userID] = make(map[string]json.RawMessage)
for deviceID, deviceKey := range nest { for deviceID, deviceKey := range nest {
@ -495,6 +497,10 @@ func (a *KeyInternalAPI) queryRemoteKeys(
// TODO: do we want to persist these somewhere now // TODO: do we want to persist these somewhere now
// that we have fetched them? // that we have fetched them?
} }
for result := range resultCh {
processResult(result)
}
} }
func (a *KeyInternalAPI) queryRemoteKeysOnServer( func (a *KeyInternalAPI) queryRemoteKeysOnServer(