Add EDU server wiring

This commit is contained in:
Neil Alexander 2021-07-28 14:06:23 +01:00
parent dcadec88d9
commit 8683f7553f
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
9 changed files with 105 additions and 0 deletions

View file

@ -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
}