diff options
author | H. Shay <hillerys@element.io> | 2023-08-24 15:13:39 -0700 |
---|---|---|
committer | H. Shay <hillerys@element.io> | 2023-08-24 15:13:39 -0700 |
commit | f6401d7ee640e2438f8851db57c71f94bcd0c873 (patch) | |
tree | 99a2234897beda770b9512b637f71b5cda6ffc71 /synapse/storage | |
parent | stop writing to column `user_id` of table `user_filters` (diff) | |
download | synapse-f6401d7ee640e2438f8851db57c71f94bcd0c873.tar.xz |
stop writing to column `user_id` of table `profiles`
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/databases/main/profile.py | 12 | ||||
-rw-r--r-- | synapse/storage/databases/main/registration.py | 9 |
2 files changed, 7 insertions, 14 deletions
diff --git a/synapse/storage/databases/main/profile.py b/synapse/storage/databases/main/profile.py index 3ba9cc8853..660a5507b7 100644 --- a/synapse/storage/databases/main/profile.py +++ b/synapse/storage/databases/main/profile.py @@ -173,10 +173,9 @@ class ProfileWorkerStore(SQLBaseStore): ) async def create_profile(self, user_id: UserID) -> None: - user_localpart = user_id.localpart await self.db_pool.simple_insert( table="profiles", - values={"user_id": user_localpart, "full_user_id": user_id.to_string()}, + values={"full_user_id": user_id.to_string()}, desc="create_profile", ) @@ -191,13 +190,11 @@ class ProfileWorkerStore(SQLBaseStore): new_displayname: The new display name. If this is None, the user's display name is removed. """ - user_localpart = user_id.localpart await self.db_pool.simple_upsert( table="profiles", - keyvalues={"user_id": user_localpart}, + keyvalues={"full_user_id": user_id.to_string()}, values={ "displayname": new_displayname, - "full_user_id": user_id.to_string(), }, desc="set_profile_displayname", ) @@ -213,11 +210,10 @@ class ProfileWorkerStore(SQLBaseStore): new_avatar_url: The new avatar URL. If this is None, the user's avatar is removed. """ - user_localpart = user_id.localpart await self.db_pool.simple_upsert( table="profiles", - keyvalues={"user_id": user_localpart}, - values={"avatar_url": new_avatar_url, "full_user_id": user_id.to_string()}, + keyvalues={"full_user_id": user_id.to_string()}, + values={"avatar_url": new_avatar_url}, desc="set_profile_avatar_url", ) diff --git a/synapse/storage/databases/main/registration.py b/synapse/storage/databases/main/registration.py index d3a01d526f..8d62c89548 100644 --- a/synapse/storage/databases/main/registration.py +++ b/synapse/storage/databases/main/registration.py @@ -2404,7 +2404,7 @@ class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore): shadow_banned: bool, approved: bool, ) -> None: - user_id_obj = UserID.from_string(user_id) + UserID.from_string(user_id) now = int(self._clock.time()) @@ -2464,12 +2464,9 @@ class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore): if create_profile_with_displayname: # set a default displayname serverside to avoid ugly race # between auto-joins and clients trying to set displaynames - # - # *obviously* the 'profiles' table uses localpart for user_id - # while everything else uses the full mxid. txn.execute( - "INSERT INTO profiles(full_user_id, user_id, displayname) VALUES (?,?,?)", - (user_id, user_id_obj.localpart, create_profile_with_displayname), + "INSERT INTO profiles(full_user_id, displayname) VALUES (?,?)", + (user_id, create_profile_with_displayname), ) if self.hs.config.stats.stats_enabled: |