mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -06:00
Review comments
This commit is contained in:
parent
0b4e2817c3
commit
9520c718cc
|
|
@ -27,6 +27,8 @@ CREATE TABLE IF NOT EXISTS current_room_state (
|
||||||
-- Clobber based on 3-uple of room_id, type and state_key
|
-- Clobber based on 3-uple of room_id, type and state_key
|
||||||
CONSTRAINT room_state_unique UNIQUE (room_id, type, state_key)
|
CONSTRAINT room_state_unique UNIQUE (room_id, type, state_key)
|
||||||
);
|
);
|
||||||
|
-- for event deletion
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS event_id_idx ON current_room_state(event_id);
|
||||||
`
|
`
|
||||||
|
|
||||||
const upsertRoomStateSQL = "" +
|
const upsertRoomStateSQL = "" +
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ CREATE TABLE IF NOT EXISTS output_room_events (
|
||||||
add_state_ids TEXT[],
|
add_state_ids TEXT[],
|
||||||
remove_state_ids TEXT[]
|
remove_state_ids TEXT[]
|
||||||
);
|
);
|
||||||
|
-- for event selection
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS event_id_idx ON output_room_events(event_id);
|
||||||
`
|
`
|
||||||
|
|
||||||
const insertEventSQL = "" +
|
const insertEventSQL = "" +
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,12 @@ func (d *SyncServerDatabase) WriteEvent(ev *gomatrixserverlib.Event, addStateEve
|
||||||
if err := d.events.InsertEvent(txn, ev, addStateEventIDs, removeStateEventIDs); err != nil {
|
if err := d.events.InsertEvent(txn, ev, addStateEventIDs, removeStateEventIDs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(addStateEventIDs) == 0 && len(removeStateEventIDs) == 0 {
|
||||||
|
// Nothing to do, the event may have just been a message event.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Update the current room state based on the added/removed state event IDs.
|
// Update the current room state based on the added/removed state event IDs.
|
||||||
// In the common case there is a single added event ID which is the state event itself, assuming `ev` is a state event.
|
// In the common case there is a single added event ID which is the state event itself, assuming `ev` is a state event.
|
||||||
// However, conflict resolution may result in there being different events being added, or even some removed.
|
// However, conflict resolution may result in there being different events being added, or even some removed.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue