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

Method DeviceKeysEqual

keyserver/api/api.go:113–127  ·  view source on GitHub ↗

DeviceKeysEqual returns true if the device keys updates contain the same display name and key JSON. This will return false if either of the updates is not a device keys update, or if the user ID/device ID differ between the two.

(m2 *DeviceMessage)

Source from the content-addressed store, hash-verified

111// the updates is not a device keys update, or if the user ID/device ID
112// differ between the two.
113func (m1 *DeviceMessage) DeviceKeysEqual(m2 *DeviceMessage) bool {
114 if m1.DeviceKeys == nil || m2.DeviceKeys == nil {
115 return false
116 }
117 if m1.UserID != m2.UserID || m1.DeviceID != m2.DeviceID {
118 return false
119 }
120 if m1.DisplayName != m2.DisplayName {
121 return false // different display names
122 }
123 if len(m1.KeyJSON) == 0 || len(m2.KeyJSON) == 0 {
124 return false // either is empty
125 }
126 return bytes.Equal(m1.KeyJSON, m2.KeyJSON)
127}
128
129// DeviceKeys represents a set of device keys for a single device
130// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload

Callers 1

emitDeviceKeyChangesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected