MCPcopy Create free account
hub / github.com/daodst/chat / remoteKeysFromDatabase

Method remoteKeysFromDatabase

keyserver/internal/internal.go:377–401  ·  view source on GitHub ↗
(
	ctx context.Context, res *api.QueryKeysResponse, domainToDeviceKeys map[string]map[string][]string,
)

Source from the content-addressed store, hash-verified

375}
376
377func (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
403func (a *KeyInternalAPI) queryRemoteKeys(
404 ctx context.Context, timeout time.Duration, res *api.QueryKeysResponse,

Callers 1

QueryKeysMethod · 0.95

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected