Only update exclude_from_sync if we're re-including it

This commit is contained in:
Neil Alexander 2021-02-17 10:14:30 +00:00
parent 8400b4e6e0
commit 4f123f72ab
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 3 additions and 2 deletions

View file

@ -75,7 +75,7 @@ const insertEventSQL = "" +
"INSERT INTO syncapi_output_room_events (" +
"room_id, event_id, headered_event_json, type, sender, contains_url, add_state_ids, remove_state_ids, session_id, transaction_id, exclude_from_sync" +
") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) " +
"ON CONFLICT ON CONSTRAINT syncapi_event_id_idx DO UPDATE SET exclude_from_sync = $11 " +
"ON CONFLICT ON CONSTRAINT syncapi_event_id_idx DO UPDATE SET exclude_from_sync = $11 WHERE $11 == false" +
"RETURNING id"
const selectEventsSQL = "" +

View file

@ -54,7 +54,7 @@ const insertEventSQL = "" +
"INSERT INTO syncapi_output_room_events (" +
"id, room_id, event_id, headered_event_json, type, sender, contains_url, add_state_ids, remove_state_ids, session_id, transaction_id, exclude_from_sync" +
") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) " +
"ON CONFLICT (event_id) DO UPDATE SET exclude_from_sync = $13"
"ON CONFLICT (event_id) DO UPDATE SET exclude_from_sync = $13 WHERE $14 == false"
const selectEventsSQL = "" +
"SELECT event_id, id, headered_event_json, session_id, exclude_from_sync, transaction_id FROM syncapi_output_room_events WHERE event_id = $1"
@ -303,6 +303,7 @@ func (s *outputRoomEventsStatements) InsertEvent(
txnID,
excludeFromSync,
excludeFromSync,
excludeFromSync,
)
return streamPos, err
}