MCPcopy Create free account
hub / github.com/daodst/chat / onMessage

Method onMessage

federationapi/consumers/keychange.go:77–96  ·  view source on GitHub ↗

onMessage is called in response to a message received on the key change events topic from the key server.

(ctx context.Context, msg *nats.Msg)

Source from the content-addressed store, hash-verified

75// onMessage is called in response to a message received on the
76// key change events topic from the key server.
77func (t *KeyChangeConsumer) onMessage(ctx context.Context, msg *nats.Msg) bool {
78 var m api.DeviceMessage
79 if err := json.Unmarshal(msg.Data, &m); err != nil {
80 logrus.WithError(err).Errorf("failed to read device message from key change topic")
81 return true
82 }
83 if m.DeviceKeys == nil && m.OutputCrossSigningKeyUpdate == nil {
84 // This probably shouldn't happen but stops us from panicking if we come
85 // across an update that doesn't satisfy either types.
86 return true
87 }
88 switch m.Type {
89 case api.TypeCrossSigningUpdate:
90 return t.onCrossSigningMessage(m)
91 case api.TypeDeviceKeyUpdate:
92 fallthrough
93 default:
94 return t.onDeviceKeyMessage(m)
95 }
96}
97
98func (t *KeyChangeConsumer) onDeviceKeyMessage(m api.DeviceMessage) bool {
99 if m.DeviceKeys == nil {

Callers

nothing calls this directly

Calls 2

onCrossSigningMessageMethod · 0.95
onDeviceKeyMessageMethod · 0.95

Tested by

no test coverage detected