diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2022-09-30 10:32:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-30 09:32:31 +0100 |
commit | 9005e5b4a87c0bdd4f19b1dbf46f3093ac07e727 (patch) | |
tree | 9c0d1d4b22b2bed21ca6f839c688512c55cad7b4 /keyserver | |
parent | e45ba35e979f2f8af1e75f5f16158973b790436b (diff) |
Add `/_dendrite/admin/refreshDevices/{userID}` (#2746)
Allows to immediately query `/devices/{userID}` over federation to
(hopefully) resolve E2EE issues.
Diffstat (limited to 'keyserver')
-rw-r--r-- | keyserver/api/api.go | 1 | ||||
-rw-r--r-- | keyserver/internal/internal.go | 13 |
2 files changed, 11 insertions, 3 deletions
diff --git a/keyserver/api/api.go b/keyserver/api/api.go index c9ec59a7..14fced3e 100644 --- a/keyserver/api/api.go +++ b/keyserver/api/api.go @@ -45,6 +45,7 @@ type ClientKeyAPI interface { PerformUploadDeviceSignatures(ctx context.Context, req *PerformUploadDeviceSignaturesRequest, res *PerformUploadDeviceSignaturesResponse) error // PerformClaimKeys claims one-time keys for use in pre-key messages PerformClaimKeys(ctx context.Context, req *PerformClaimKeysRequest, res *PerformClaimKeysResponse) error + PerformMarkAsStaleIfNeeded(ctx context.Context, req *PerformMarkAsStaleRequest, res *struct{}) error } // API functions required by the userapi diff --git a/keyserver/internal/internal.go b/keyserver/internal/internal.go index a8d1128c..6309066d 100644 --- a/keyserver/internal/internal.go +++ b/keyserver/internal/internal.go @@ -228,14 +228,21 @@ func (a *KeyInternalAPI) QueryDeviceMessages(ctx context.Context, req *api.Query // PerformMarkAsStaleIfNeeded marks the users device list as stale, if the given deviceID is not present // in our database. func (a *KeyInternalAPI) PerformMarkAsStaleIfNeeded(ctx context.Context, req *api.PerformMarkAsStaleRequest, res *struct{}) error { - knownDevices, err := a.DB.DeviceKeysForUser(ctx, req.UserID, []string{req.DeviceID}, true) + knownDevices, err := a.DB.DeviceKeysForUser(ctx, req.UserID, []string{}, true) if err != nil { return err } if len(knownDevices) == 0 { - return a.Updater.ManualUpdate(ctx, req.Domain, req.UserID) + return fmt.Errorf("unknown user %s", req.UserID) } - return nil + + for i := range knownDevices { + if knownDevices[i].DeviceID == req.DeviceID { + return nil // we already know about this device + } + } + + return a.Updater.ManualUpdate(ctx, req.Domain, req.UserID) } // nolint:gocyclo |