diff --git a/syncapi/storage/postgres/invites_table.go b/syncapi/storage/postgres/invites_table.go index 97001ae2c..576b2cf7d 100644 --- a/syncapi/storage/postgres/invites_table.go +++ b/syncapi/storage/postgres/invites_table.go @@ -20,11 +20,12 @@ import ( "database/sql" "encoding/json" + "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/syncapi/storage/tables" "github.com/matrix-org/dendrite/syncapi/types" - "github.com/matrix-org/gomatrixserverlib" ) const inviteEventsSchema = ` @@ -56,7 +57,7 @@ const deleteInviteEventSQL = "" + const selectInviteEventsInRangeSQL = "" + "SELECT room_id, headered_event_json, deleted FROM syncapi_invite_events" + - " WHERE target_user_id = $1 AND id > $2 AND id <= $3" + + " WHERE target_user_id = $1 AND id > $2 AND id <= $3 AND deleted = false" + " ORDER BY id DESC" const selectMaxInviteIDSQL = "" + diff --git a/syncapi/storage/sqlite3/invites_table.go b/syncapi/storage/sqlite3/invites_table.go index 58ab8461e..9f2812979 100644 --- a/syncapi/storage/sqlite3/invites_table.go +++ b/syncapi/storage/sqlite3/invites_table.go @@ -20,11 +20,12 @@ import ( "database/sql" "encoding/json" + "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/syncapi/storage/tables" "github.com/matrix-org/dendrite/syncapi/types" - "github.com/matrix-org/gomatrixserverlib" ) const inviteEventsSchema = ` @@ -51,7 +52,7 @@ const deleteInviteEventSQL = "" + const selectInviteEventsInRangeSQL = "" + "SELECT room_id, headered_event_json, deleted FROM syncapi_invite_events" + - " WHERE target_user_id = $1 AND id > $2 AND id <= $3" + + " WHERE target_user_id = $1 AND id > $2 AND id <= $3 AND deleted = false" + " ORDER BY id DESC" const selectMaxInviteIDSQL = "" +