diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-02-08 13:45:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-08 13:45:48 +0000 |
commit | 0e26662a552b671ef201490defbbea59df4250c1 (patch) | |
tree | 0b7224dd67c87a87b6d1b0decaba090aa722b051 /roomserver | |
parent | a2b4777ae5c4aa06ce7933bbd1b251bd777788b2 (diff) |
Allow events to be un-rejected (#2159)
* Allow un-rejecting an event later
* SQL
* Only un-reject, don't re-reject
* Clarify ambiguous column reference
Diffstat (limited to 'roomserver')
-rw-r--r-- | roomserver/storage/postgres/events_table.go | 6 | ||||
-rw-r--r-- | roomserver/storage/sqlite3/events_table.go | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/roomserver/storage/postgres/events_table.go b/roomserver/storage/postgres/events_table.go index 6c384775..ece1d9e3 100644 --- a/roomserver/storage/postgres/events_table.go +++ b/roomserver/storage/postgres/events_table.go @@ -71,10 +71,10 @@ CREATE TABLE IF NOT EXISTS roomserver_events ( ` const insertEventSQL = "" + - "INSERT INTO roomserver_events (room_nid, event_type_nid, event_state_key_nid, event_id, reference_sha256, auth_event_nids, depth, is_rejected)" + + "INSERT INTO roomserver_events AS e (room_nid, event_type_nid, event_state_key_nid, event_id, reference_sha256, auth_event_nids, depth, is_rejected)" + " VALUES ($1, $2, $3, $4, $5, $6, $7, $8)" + - " ON CONFLICT ON CONSTRAINT roomserver_event_id_unique" + - " DO NOTHING" + + " ON CONFLICT ON CONSTRAINT roomserver_event_id_unique DO UPDATE" + + " SET is_rejected = $8 WHERE e.is_rejected = FALSE" + " RETURNING event_nid, state_snapshot_nid" const selectEventSQL = "" + diff --git a/roomserver/storage/sqlite3/events_table.go b/roomserver/storage/sqlite3/events_table.go index e1e6a597..cef09fe6 100644 --- a/roomserver/storage/sqlite3/events_table.go +++ b/roomserver/storage/sqlite3/events_table.go @@ -49,7 +49,8 @@ const eventsSchema = ` const insertEventSQL = ` INSERT INTO roomserver_events (room_nid, event_type_nid, event_state_key_nid, event_id, reference_sha256, auth_event_nids, depth, is_rejected) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) - ON CONFLICT DO NOTHING + ON CONFLICT DO UPDATE + SET is_rejected = $8 WHERE is_rejected = 0 RETURNING event_nid, state_snapshot_nid; ` |