Require user ID to be set

This commit is contained in:
Neil Alexander 2021-03-02 10:53:48 +00:00
parent 22513afe88
commit 4926c551de
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -513,7 +513,12 @@ func (a *KeyInternalAPI) uploadLocalDeviceKeys(ctx context.Context, req *api.Per
}
func (a *KeyInternalAPI) uploadOneTimeKeys(ctx context.Context, req *api.PerformUploadKeysRequest, res *api.PerformUploadKeysResponse) {
if req.UserID != "" && req.DeviceID != "" && len(req.OneTimeKeys) == 0 {
if req.UserID == "" {
res.Error = &api.KeyError{
Err: "user ID missing",
}
}
if req.DeviceID != "" && len(req.OneTimeKeys) == 0 {
counts, err := a.DB.OneTimeKeysCount(ctx, req.UserID, req.DeviceID)
if err != nil {
res.Error = &api.KeyError{