diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2022-07-12 08:23:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-12 08:23:58 +0200 |
commit | 09f0ff14c88fec2ae5b3db79054378a8ced255a9 (patch) | |
tree | f433d00d3320c32ffb91ec695748a9afefbe4604 /syncapi/storage/postgres | |
parent | 3ea21273bcc151b36eec412d0ec550642fe9b04f (diff) |
Minor SendToDevice fix (#2565)
* Avoid unnecessary marshalling if sending to the local server
* Fix ordering of ToDevice messages
* Revive SendToDevice test
Diffstat (limited to 'syncapi/storage/postgres')
-rw-r--r-- | syncapi/storage/postgres/send_to_device_table.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/syncapi/storage/postgres/send_to_device_table.go b/syncapi/storage/postgres/send_to_device_table.go index 47c1cdae..96d6844f 100644 --- a/syncapi/storage/postgres/send_to_device_table.go +++ b/syncapi/storage/postgres/send_to_device_table.go @@ -23,6 +23,7 @@ import ( "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/syncapi/storage/tables" "github.com/matrix-org/dendrite/syncapi/types" + "github.com/sirupsen/logrus" ) const sendToDeviceSchema = ` @@ -51,7 +52,7 @@ const selectSendToDeviceMessagesSQL = ` SELECT id, user_id, device_id, content FROM syncapi_send_to_device WHERE user_id = $1 AND device_id = $2 AND id > $3 AND id <= $4 - ORDER BY id DESC + ORDER BY id ASC ` const deleteSendToDeviceMessagesSQL = ` @@ -112,17 +113,18 @@ func (s *sendToDeviceStatements) SelectSendToDeviceMessages( if err = rows.Scan(&id, &userID, &deviceID, &content); err != nil { return } - if id > lastPos { - lastPos = id - } event := types.SendToDeviceEvent{ ID: id, UserID: userID, DeviceID: deviceID, } if err = json.Unmarshal([]byte(content), &event.SendToDeviceEvent); err != nil { + logrus.WithError(err).Errorf("Failed to unmarshal send-to-device message") continue } + if id > lastPos { + lastPos = id + } events = append(events, event) } if lastPos == 0 { |