mirror of
https://github.com/matrix-org/dendrite
synced 2025-01-07 10:48:42 +00:00
Add MasterKey & SelfSigningKey to update
Avoid panic if signatures are not present
This commit is contained in:
parent
f13ac2a935
commit
2c81b34884
2 changed files with 48 additions and 42 deletions
|
@ -308,8 +308,12 @@ func (a *KeyInternalAPI) PerformUploadDeviceSignatures(ctx context.Context, req
|
||||||
|
|
||||||
// Finally, generate a notification that we updated the signatures.
|
// Finally, generate a notification that we updated the signatures.
|
||||||
for userID := range req.Signatures {
|
for userID := range req.Signatures {
|
||||||
|
masterKey := queryRes.MasterKeys[userID]
|
||||||
|
selfSigningKey := queryRes.SelfSigningKeys[userID]
|
||||||
update := eduserverAPI.CrossSigningKeyUpdate{
|
update := eduserverAPI.CrossSigningKeyUpdate{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
|
MasterKey: &masterKey,
|
||||||
|
SelfSigningKey: &selfSigningKey,
|
||||||
}
|
}
|
||||||
if err := a.Producer.ProduceSigningKeyUpdate(update); err != nil {
|
if err := a.Producer.ProduceSigningKeyUpdate(update); err != nil {
|
||||||
res.Error = &api.KeyError{
|
res.Error = &api.KeyError{
|
||||||
|
|
|
@ -243,7 +243,6 @@ func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReques
|
||||||
}
|
}
|
||||||
domain := string(serverName)
|
domain := string(serverName)
|
||||||
// query local devices
|
// query local devices
|
||||||
if serverName == a.ThisServer {
|
|
||||||
deviceKeys, err := a.DB.DeviceKeysForUser(ctx, userID, deviceIDs)
|
deviceKeys, err := a.DB.DeviceKeysForUser(ctx, userID, deviceIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Error = &api.KeyError{
|
res.Error = &api.KeyError{
|
||||||
|
@ -282,10 +281,7 @@ func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReques
|
||||||
}{displayName})
|
}{displayName})
|
||||||
res.DeviceKeys[userID][dk.DeviceID] = dk.KeyJSON
|
res.DeviceKeys[userID][dk.DeviceID] = dk.KeyJSON
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
domainToDeviceKeys[domain] = make(map[string][]string)
|
|
||||||
domainToDeviceKeys[domain][userID] = append(domainToDeviceKeys[domain][userID], deviceIDs...)
|
|
||||||
}
|
|
||||||
// work out if our cross-signing request for this user was
|
// work out if our cross-signing request for this user was
|
||||||
// satisfied, if not add them to the list of things to fetch
|
// satisfied, if not add them to the list of things to fetch
|
||||||
if _, ok := res.MasterKeys[userID]; !ok {
|
if _, ok := res.MasterKeys[userID]; !ok {
|
||||||
|
@ -326,8 +322,14 @@ func (a *KeyInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReques
|
||||||
if err = json.Unmarshal(key, &deviceKey); err != nil {
|
if err = json.Unmarshal(key, &deviceKey); err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if deviceKey.Signatures == nil {
|
||||||
|
deviceKey.Signatures = map[string]map[gomatrixserverlib.KeyID]gomatrixserverlib.Base64Bytes{}
|
||||||
|
}
|
||||||
for sourceUserID, forSourceUser := range sigMap {
|
for sourceUserID, forSourceUser := range sigMap {
|
||||||
for sourceKeyID, sourceSig := range forSourceUser {
|
for sourceKeyID, sourceSig := range forSourceUser {
|
||||||
|
if _, ok := deviceKey.Signatures[sourceUserID]; !ok {
|
||||||
|
deviceKey.Signatures[sourceUserID] = map[gomatrixserverlib.KeyID]gomatrixserverlib.Base64Bytes{}
|
||||||
|
}
|
||||||
deviceKey.Signatures[sourceUserID][sourceKeyID] = sourceSig
|
deviceKey.Signatures[sourceUserID][sourceKeyID] = sourceSig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue