Perform server key API operations using new context

This commit is contained in:
Neil Alexander 2020-06-04 14:35:51 +01:00
parent 1ff04e2461
commit 02172223f5
2 changed files with 8 additions and 4 deletions

View file

@ -70,9 +70,10 @@ func (s *httpServerKeyInternalAPI) FetcherName() string {
}
func (s *httpServerKeyInternalAPI) StoreKeys(
ctx context.Context,
_ context.Context,
results map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult,
) error {
ctx := context.Background()
request := InputPublicKeysRequest{
Keys: make(map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult),
}
@ -85,9 +86,10 @@ func (s *httpServerKeyInternalAPI) StoreKeys(
}
func (s *httpServerKeyInternalAPI) FetchKeys(
ctx context.Context,
_ context.Context,
requests map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp,
) (map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult, error) {
ctx := context.Background()
result := make(map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult)
request := QueryPublicKeysRequest{
Requests: make(map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp),

View file

@ -25,17 +25,19 @@ func (s *ServerKeyAPI) KeyRing() *gomatrixserverlib.KeyRing {
}
func (s *ServerKeyAPI) StoreKeys(
ctx context.Context,
_ context.Context,
results map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult,
) error {
ctx := context.Background()
// Store any keys that we were given in our database.
return s.OurKeyRing.KeyDatabase.StoreKeys(ctx, results)
}
func (s *ServerKeyAPI) FetchKeys(
ctx context.Context,
_ context.Context,
requests map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp,
) (map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult, error) {
ctx := context.Background()
results := map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult{}
// First consult our local database and see if we have the requested
// keys. These might come from a cache, depending on the database