diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-02-24 15:46:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-24 15:46:41 +0000 |
commit | a301934f4610ffce490fbb925aaa898aac2829bc (patch) | |
tree | 434bea439924bc29295fe2fe0b5774af55dab19b /synapse/storage/data_stores | |
parent | Fix minor issues with email config (#6962) (diff) | |
download | synapse-a301934f4610ffce490fbb925aaa898aac2829bc.tar.xz |
Upsert room version when we join over federation (#6968)
This is intended as a precursor to storing room versions when we receive an invite over federation, but has the happy side-effect of fixing #3374 at last. In short: change the store_room with try/except to a proper upsert which updates the right columns.
Diffstat (limited to 'synapse/storage/data_stores')
-rw-r--r-- | synapse/storage/data_stores/main/room.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/storage/data_stores/main/room.py b/synapse/storage/data_stores/main/room.py index 9a17e336ba..70137dfbe4 100644 --- a/synapse/storage/data_stores/main/room.py +++ b/synapse/storage/data_stores/main/room.py @@ -954,6 +954,23 @@ class RoomStore(RoomBackgroundUpdateStore, RoomWorkerStore, SearchStore): self.config = hs.config + async def upsert_room_on_join(self, room_id: str, room_version: RoomVersion): + """Ensure that the room is stored in the table + + Called when we join a room over federation, and overwrites any room version + currently in the table. + """ + await self.db.simple_upsert( + desc="upsert_room_on_join", + table="rooms", + keyvalues={"room_id": room_id}, + values={"room_version": room_version.identifier}, + insertion_values={"is_public": False, "creator": ""}, + # rooms has a unique constraint on room_id, so no need to lock when doing an + # emulated upsert. + lock=False, + ) + @defer.inlineCallbacks def store_room( self, |