mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 13:52:46 +00:00
Add EDU server wiring
This commit is contained in:
parent
dcadec88d9
commit
8683f7553f
9 changed files with 105 additions and 0 deletions
|
@ -39,6 +39,8 @@ type EDUServerInputAPI struct {
|
|||
OutputSendToDeviceEventTopic string
|
||||
// The kafka topic to output new receipt events to
|
||||
OutputReceiptEventTopic string
|
||||
// The kafka topic to output new signing key updates to
|
||||
OutputSigningKeyUpdateTopic string
|
||||
// kafka producer
|
||||
Producer sarama.SyncProducer
|
||||
// Internal user query API
|
||||
|
@ -203,3 +205,28 @@ func (t *EDUServerInputAPI) InputReceiptEvent(
|
|||
_, _, err = t.Producer.SendMessage(m)
|
||||
return err
|
||||
}
|
||||
|
||||
// InputSigningKeyUpdate implements api.EDUServerInputAPI
|
||||
func (t *EDUServerInputAPI) InputSigningKeyUpdate(
|
||||
ctx context.Context,
|
||||
request *api.InputSigningKeyUpdateRequest,
|
||||
response *api.InputSigningKeyUpdateResponse,
|
||||
) error {
|
||||
logrus.WithFields(logrus.Fields{}).Infof("Producing to topic '%s'", t.OutputSigningKeyUpdateTopic)
|
||||
output := &api.OutputSigningKeyUpdate{
|
||||
SigningKeyUpdate: request.SigningKeyUpdate,
|
||||
Type: "m.signing_key_update",
|
||||
Timestamp: gomatrixserverlib.AsTimestamp(time.Now()),
|
||||
}
|
||||
js, err := json.Marshal(output)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m := &sarama.ProducerMessage{
|
||||
Topic: t.OutputSigningKeyUpdateTopic,
|
||||
Key: sarama.StringEncoder(request.UserID),
|
||||
Value: sarama.ByteEncoder(js),
|
||||
}
|
||||
_, _, err = t.Producer.SendMessage(m)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue