( ctx context.Context, res *api.QueryKeysResponse, domainToDeviceKeys map[string]map[string][]string, )
| 375 | } |
| 376 | |
| 377 | func (a *KeyInternalAPI) remoteKeysFromDatabase( |
| 378 | ctx context.Context, res *api.QueryKeysResponse, domainToDeviceKeys map[string]map[string][]string, |
| 379 | ) map[string]map[string][]string { |
| 380 | fetchRemote := make(map[string]map[string][]string) |
| 381 | for domain, userToDeviceMap := range domainToDeviceKeys { |
| 382 | for userID, deviceIDs := range userToDeviceMap { |
| 383 | // we can't safely return keys from the db when all devices are requested as we don't |
| 384 | // know if one has just been added. |
| 385 | if len(deviceIDs) > 0 { |
| 386 | err := a.populateResponseWithDeviceKeysFromDatabase(ctx, res, userID, deviceIDs) |
| 387 | if err == nil { |
| 388 | continue |
| 389 | } |
| 390 | util.GetLogger(ctx).WithError(err).Error("populateResponseWithDeviceKeysFromDatabase") |
| 391 | } |
| 392 | // fetch device lists from remote |
| 393 | if _, ok := fetchRemote[domain]; !ok { |
| 394 | fetchRemote[domain] = make(map[string][]string) |
| 395 | } |
| 396 | fetchRemote[domain][userID] = append(fetchRemote[domain][userID], deviceIDs...) |
| 397 | |
| 398 | } |
| 399 | } |
| 400 | return fetchRemote |
| 401 | } |
| 402 | |
| 403 | func (a *KeyInternalAPI) queryRemoteKeys( |
| 404 | ctx context.Context, timeout time.Duration, res *api.QueryKeysResponse, |
no test coverage detected