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)
| 75 | // onMessage is called in response to a message received on the |
| 76 | // key change events topic from the key server. |
| 77 | func (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 | |
| 98 | func (t *KeyChangeConsumer) onDeviceKeyMessage(m api.DeviceMessage) bool { |
| 99 | if m.DeviceKeys == nil { |
nothing calls this directly
no test coverage detected