mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Directly upload device keys without eduserver
This commit is contained in:
parent
4cf0aa0a86
commit
203e5e3cb1
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/federationapi/queue"
|
"github.com/matrix-org/dendrite/federationapi/queue"
|
||||||
"github.com/matrix-org/dendrite/federationapi/storage"
|
"github.com/matrix-org/dendrite/federationapi/storage"
|
||||||
"github.com/matrix-org/dendrite/federationapi/types"
|
"github.com/matrix-org/dendrite/federationapi/types"
|
||||||
|
|
|
||||||
|
|
@ -382,20 +382,8 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case eduserverAPI.MSigningKeyUpdate:
|
case eduserverAPI.MSigningKeyUpdate:
|
||||||
var updatePayload eduserverAPI.CrossSigningKeyUpdate
|
if err := t.processSigningKeyUpdate(ctx, e); err != nil {
|
||||||
if err := json.Unmarshal(e.Content, &updatePayload); err != nil {
|
logrus.WithError(err).Errorf("Failed to process signing key update")
|
||||||
util.GetLogger(ctx).WithError(err).WithFields(logrus.Fields{
|
|
||||||
"user_id": updatePayload.UserID,
|
|
||||||
}).Debug("Failed to send signing key update to edu server")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
inputReq := &eduserverAPI.InputCrossSigningKeyUpdateRequest{
|
|
||||||
CrossSigningKeyUpdate: updatePayload,
|
|
||||||
}
|
|
||||||
inputRes := &eduserverAPI.InputCrossSigningKeyUpdateResponse{}
|
|
||||||
if err := t.eduAPI.InputCrossSigningKeyUpdate(ctx, inputReq, inputRes); err != nil {
|
|
||||||
util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal cross-signing update")
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
util.GetLogger(ctx).WithField("type", e.Type).Debug("Unhandled EDU")
|
util.GetLogger(ctx).WithField("type", e.Type).Debug("Unhandled EDU")
|
||||||
|
|
@ -403,6 +391,34 @@ func (t *txnReq) processEDUs(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *txnReq) processSigningKeyUpdate(ctx context.Context, e gomatrixserverlib.EDU) error {
|
||||||
|
var updatePayload eduserverAPI.CrossSigningKeyUpdate
|
||||||
|
if err := json.Unmarshal(e.Content, &updatePayload); err != nil {
|
||||||
|
util.GetLogger(ctx).WithError(err).WithFields(logrus.Fields{
|
||||||
|
"user_id": updatePayload.UserID,
|
||||||
|
}).Debug("Failed to unmarshal signing key update")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
keys := gomatrixserverlib.CrossSigningKeys{}
|
||||||
|
if updatePayload.MasterKey != nil {
|
||||||
|
keys.MasterKey = *updatePayload.MasterKey
|
||||||
|
}
|
||||||
|
if updatePayload.SelfSigningKey != nil {
|
||||||
|
keys.SelfSigningKey = *updatePayload.SelfSigningKey
|
||||||
|
}
|
||||||
|
uploadReq := &keyapi.PerformUploadDeviceKeysRequest{
|
||||||
|
CrossSigningKeys: keys,
|
||||||
|
UserID: updatePayload.UserID,
|
||||||
|
}
|
||||||
|
uploadRes := &keyapi.PerformUploadDeviceKeysResponse{}
|
||||||
|
t.keyAPI.PerformUploadDeviceKeys(ctx, uploadReq, uploadRes)
|
||||||
|
if uploadRes.Error != nil {
|
||||||
|
return uploadRes.Error
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// processReceiptEvent sends receipt events to the edu server
|
// processReceiptEvent sends receipt events to the edu server
|
||||||
func (t *txnReq) processReceiptEvent(ctx context.Context,
|
func (t *txnReq) processReceiptEvent(ctx context.Context,
|
||||||
userID, roomID, receiptType string,
|
userID, roomID, receiptType string,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue