Let's try this again

This commit is contained in:
Neil Alexander 2021-07-30 10:28:33 +01:00
parent 1fed507679
commit 67421a9d65
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -233,7 +233,6 @@ func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReques
// make a map from domain to device keys // make a map from domain to device keys
domainToDeviceKeys := make(map[string]map[string][]string) domainToDeviceKeys := make(map[string]map[string][]string)
domainToCrossSigningKeys := make(map[string]struct{})
for userID, deviceIDs := range req.UserToDevices { for userID, deviceIDs := range req.UserToDevices {
_, serverName, err := gomatrixserverlib.SplitID('@', userID) _, serverName, err := gomatrixserverlib.SplitID('@', userID)
if err != nil { if err != nil {
@ -285,20 +284,25 @@ func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReques
domainToDeviceKeys[domain][userID] = append(domainToDeviceKeys[domain][userID], deviceIDs...) domainToDeviceKeys[domain][userID] = append(domainToDeviceKeys[domain][userID], deviceIDs...)
} }
// work out if our cross-signing request for this user was // work out if our cross-signing request for this user was
// satisfied // satisfied, if not add them to the list of things to fetch
if _, ok := domainToCrossSigningKeys[userID]; !ok { if _, ok := domainToDeviceKeys[domain]; !ok {
if _, ok := res.MasterKeys[userID]; !ok { domainToDeviceKeys[domain] = make(map[string][]string)
domainToCrossSigningKeys[userID] = struct{}{} }
if _, ok := res.MasterKeys[userID]; !ok {
if _, ok := domainToDeviceKeys[domain][userID]; !ok {
domainToDeviceKeys[domain][userID] = []string{}
} }
if _, ok := res.SelfSigningKeys[userID]; !ok { }
domainToCrossSigningKeys[userID] = struct{}{} if _, ok := res.SelfSigningKeys[userID]; !ok {
if _, ok := domainToDeviceKeys[domain][userID]; !ok {
domainToDeviceKeys[domain][userID] = []string{}
} }
} }
} }
// attempt to satisfy key queries from the local database first as we should get device updates pushed to us // attempt to satisfy key queries from the local database first as we should get device updates pushed to us
domainToDeviceKeys = a.remoteKeysFromDatabase(ctx, res, domainToDeviceKeys) domainToDeviceKeys = a.remoteKeysFromDatabase(ctx, res, domainToDeviceKeys)
if len(domainToDeviceKeys) == 0 && len(domainToCrossSigningKeys) == 0 { if len(domainToDeviceKeys) == 0 {
return // nothing to query return // nothing to query
} }