aboutsummaryrefslogtreecommitdiff
path: root/federationapi
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-06-15 14:27:07 +0100
committerGitHub <noreply@github.com>2022-06-15 14:27:07 +0100
commit7120eb6bc943af6f725b0c61cfd110330f04064a (patch)
treea7e278689e44b36eeefe01cd7b8ecb247119c940 /federationapi
parent1b90cc95367947fa00616b4426d0c894b33c9862 (diff)
Add `InputDeviceListUpdate` to the keyserver, remove old input API (#2536)
* Add `InputDeviceListUpdate` to the keyserver, remove old input API * Fix copyright * Log more information when a device list update fails
Diffstat (limited to 'federationapi')
-rw-r--r--federationapi/federationapi.go1
-rw-r--r--federationapi/producers/syncapi.go17
-rw-r--r--federationapi/routing/send.go8
3 files changed, 20 insertions, 6 deletions
diff --git a/federationapi/federationapi.go b/federationapi/federationapi.go
index ff159bee..97bcc12a 100644
--- a/federationapi/federationapi.go
+++ b/federationapi/federationapi.go
@@ -63,6 +63,7 @@ func AddPublicRoutes(
TopicSendToDeviceEvent: cfg.Matrix.JetStream.Prefixed(jetstream.OutputSendToDeviceEvent),
TopicTypingEvent: cfg.Matrix.JetStream.Prefixed(jetstream.OutputTypingEvent),
TopicPresenceEvent: cfg.Matrix.JetStream.Prefixed(jetstream.OutputPresenceEvent),
+ TopicDeviceListUpdate: cfg.Matrix.JetStream.Prefixed(jetstream.InputDeviceListUpdate),
ServerName: cfg.Matrix.ServerName,
UserAPI: userAPI,
}
diff --git a/federationapi/producers/syncapi.go b/federationapi/producers/syncapi.go
index 49415003..6453d026 100644
--- a/federationapi/producers/syncapi.go
+++ b/federationapi/producers/syncapi.go
@@ -17,6 +17,7 @@ package producers
import (
"context"
"encoding/json"
+ "fmt"
"strconv"
"time"
@@ -34,6 +35,7 @@ type SyncAPIProducer struct {
TopicSendToDeviceEvent string
TopicTypingEvent string
TopicPresenceEvent string
+ TopicDeviceListUpdate string
JetStream nats.JetStreamContext
ServerName gomatrixserverlib.ServerName
UserAPI userapi.UserInternalAPI
@@ -161,3 +163,18 @@ func (p *SyncAPIProducer) SendPresence(
_, err := p.JetStream.PublishMsg(m, nats.Context(ctx))
return err
}
+
+func (p *SyncAPIProducer) SendDeviceListUpdate(
+ ctx context.Context, deviceListUpdate *gomatrixserverlib.DeviceListUpdateEvent,
+) (err error) {
+ m := nats.NewMsg(p.TopicDeviceListUpdate)
+ m.Header.Set(jetstream.UserID, deviceListUpdate.UserID)
+ m.Data, err = json.Marshal(deviceListUpdate)
+ if err != nil {
+ return fmt.Errorf("json.Marshal: %w", err)
+ }
+
+ log.Debugf("Sending device list update: %+v", m.Header)
+ _, err = p.JetStream.PublishMsg(m, nats.Context(ctx))
+ return err
+}
diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go
index c25dabce..43003be3 100644
--- a/federationapi/routing/send.go
+++ b/federationapi/routing/send.go
@@ -501,11 +501,7 @@ func (t *txnReq) processDeviceListUpdate(ctx context.Context, e gomatrixserverli
} else if serverName != t.Origin {
return
}
- var inputRes keyapi.InputDeviceListUpdateResponse
- t.keyAPI.InputDeviceListUpdate(context.Background(), &keyapi.InputDeviceListUpdateRequest{
- Event: payload,
- }, &inputRes)
- if inputRes.Error != nil {
- util.GetLogger(ctx).WithError(inputRes.Error).WithField("user_id", payload.UserID).Error("failed to InputDeviceListUpdate")
+ if err := t.producer.SendDeviceListUpdate(ctx, &payload); err != nil {
+ util.GetLogger(ctx).WithError(err).WithField("user_id", payload.UserID).Error("failed to InputDeviceListUpdate")
}
}