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/sqlite3/send_to_device_table.go | |
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/sqlite3/send_to_device_table.go')
-rw-r--r-- | syncapi/storage/sqlite3/send_to_device_table.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/syncapi/storage/sqlite3/send_to_device_table.go b/syncapi/storage/sqlite3/send_to_device_table.go index 0b1d5bbf..5285acbe 100644 --- a/syncapi/storage/sqlite3/send_to_device_table.go +++ b/syncapi/storage/sqlite3/send_to_device_table.go @@ -49,7 +49,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 = ` @@ -120,9 +120,6 @@ func (s *sendToDeviceStatements) SelectSendToDeviceMessages( logrus.WithError(err).Errorf("Failed to retrieve send-to-device message") return } - if id > lastPos { - lastPos = id - } event := types.SendToDeviceEvent{ ID: id, UserID: userID, @@ -132,6 +129,9 @@ func (s *sendToDeviceStatements) SelectSendToDeviceMessages( logrus.WithError(err).Errorf("Failed to unmarshal send-to-device message") continue } + if id > lastPos { + lastPos = id + } events = append(events, event) } if lastPos == 0 { |