mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
make set_profile_* an upsert rather than update, now create_profile is gone
This commit is contained in:
parent
debf04556b
commit
fb47ce3e6a
@ -125,33 +125,28 @@ class ProfileWorkerStore(SQLBaseStore):
|
|||||||
|
|
||||||
|
|
||||||
class ProfileStore(ProfileWorkerStore):
|
class ProfileStore(ProfileWorkerStore):
|
||||||
def create_profile(self, user_localpart):
|
|
||||||
return self._simple_insert(
|
|
||||||
table="profiles",
|
|
||||||
values={"user_id": user_localpart},
|
|
||||||
desc="create_profile",
|
|
||||||
)
|
|
||||||
|
|
||||||
def set_profile_displayname(self, user_localpart, new_displayname, batchnum):
|
def set_profile_displayname(self, user_localpart, new_displayname, batchnum):
|
||||||
return self._simple_update_one(
|
return self._simple_upsert(
|
||||||
table="profiles",
|
table="profiles",
|
||||||
keyvalues={"user_id": user_localpart},
|
keyvalues={"user_id": user_localpart},
|
||||||
updatevalues={
|
values={
|
||||||
"displayname": new_displayname,
|
"displayname": new_displayname,
|
||||||
"batch": batchnum,
|
"batch": batchnum,
|
||||||
},
|
},
|
||||||
desc="set_profile_displayname",
|
desc="set_profile_displayname",
|
||||||
|
lock=False # we can do this because user_id has a unique index
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_profile_avatar_url(self, user_localpart, new_avatar_url, batchnum):
|
def set_profile_avatar_url(self, user_localpart, new_avatar_url, batchnum):
|
||||||
return self._simple_update_one(
|
return self._simple_upsert(
|
||||||
table="profiles",
|
table="profiles",
|
||||||
keyvalues={"user_id": user_localpart},
|
keyvalues={"user_id": user_localpart},
|
||||||
updatevalues={
|
values={
|
||||||
"avatar_url": new_avatar_url,
|
"avatar_url": new_avatar_url,
|
||||||
"batch": batchnum,
|
"batch": batchnum,
|
||||||
},
|
},
|
||||||
desc="set_profile_avatar_url",
|
desc="set_profile_avatar_url",
|
||||||
|
lock=False # we can do this because user_id has a unique index
|
||||||
)
|
)
|
||||||
|
|
||||||
def add_remote_profile_cache(self, user_id, displayname, avatar_url):
|
def add_remote_profile_cache(self, user_id, displayname, avatar_url):
|
||||||
|
Loading…
Reference in New Issue
Block a user