mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Log org.matrix.msgid fields if they are present
This commit is contained in:
parent
e839b44913
commit
f80dc00eaf
@ -89,6 +89,11 @@ func (t *ToDeviceTable) Messages(deviceID string, from, limit int64) (msgs []jso
|
||||
msgs = make([]json.RawMessage, len(rows))
|
||||
for i := range rows {
|
||||
msgs[i] = json.RawMessage(rows[i].Message)
|
||||
m := gjson.ParseBytes(msgs[i])
|
||||
msgId := m.Get(`content.org\.matrix\.msgid`).Str
|
||||
if msgId != "" {
|
||||
log.Debug().Str("msgid", msgId).Str("device", deviceID).Msg("ToDeviceTable.Messages")
|
||||
}
|
||||
}
|
||||
upTo = rows[len(rows)-1].Position
|
||||
return
|
||||
@ -118,6 +123,10 @@ func (t *ToDeviceTable) InsertMessages(deviceID string, msgs []json.RawMessage)
|
||||
Type: m.Get("type").Str,
|
||||
Sender: m.Get("sender").Str,
|
||||
}
|
||||
msgId := m.Get(`content.org\.matrix\.msgid`).Str
|
||||
if msgId != "" {
|
||||
log.Debug().Str("msgid", msgId).Str("device", deviceID).Msg("ToDeviceTable.InsertMessages")
|
||||
}
|
||||
switch rows[i].Type {
|
||||
case "m.room_key_request":
|
||||
action := m.Get("content.action").Str
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func TestToDeviceTable(t *testing.T) {
|
||||
@ -279,6 +280,30 @@ func TestToDeviceTableBytesInEqualBytesOut(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMsgID(t *testing.T) {
|
||||
data := json.RawMessage(`{
|
||||
"content": {
|
||||
"algorithm": "m.olm.v1.curve25519-aes-sha2",
|
||||
"ciphertext": {
|
||||
"gMObR+/4dqL5T4DisRRRYBJpn+OjzFnkyCFOktP6Eyw": {
|
||||
"body": "AwogrdbTbG8VCW....slqU",
|
||||
"type": 0
|
||||
}
|
||||
},
|
||||
"org.matrix.msgid": "6390a372-fd3c-4f56-b0d5-2f2ce39f2d56",
|
||||
"sender_key": "EWnYTm/yIQ1lStSIqO6fdVYvS69OfU2DzrX+q+1d+w8"
|
||||
},
|
||||
"type": "m.room.encrypted",
|
||||
"sender": "@sample:localhost:8480"
|
||||
}`)
|
||||
m := gjson.ParseBytes(data)
|
||||
got := m.Get(`content.org\.matrix\.msgid`).Str
|
||||
want := "6390a372-fd3c-4f56-b0d5-2f2ce39f2d56"
|
||||
if got != want {
|
||||
t.Fatalf("got %v want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func bytesEqual(t *testing.T, got, want json.RawMessage) {
|
||||
t.Helper()
|
||||
if !bytes.Equal(got, want) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user