mirror of
https://github.com/matrix-org/synapse.git
synced 2025-02-11 09:45:48 +00:00
Actually stop reading from column user_id
of tables profiles
(#15955)
This commit is contained in:
parent
e1fa42249c
commit
f08d05dd2c
1
changelog.d/15955.misc
Normal file
1
changelog.d/15955.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Stop reading from column `user_id` of table `profiles`.
|
@ -196,7 +196,7 @@ class DataStore(
|
|||||||
txn: LoggingTransaction,
|
txn: LoggingTransaction,
|
||||||
) -> Tuple[List[JsonDict], int]:
|
) -> Tuple[List[JsonDict], int]:
|
||||||
filters = []
|
filters = []
|
||||||
args = [self.hs.config.server.server_name]
|
args: list = []
|
||||||
|
|
||||||
# Set ordering
|
# Set ordering
|
||||||
order_by_column = UserSortOrder(order_by).value
|
order_by_column = UserSortOrder(order_by).value
|
||||||
@ -263,7 +263,7 @@ class DataStore(
|
|||||||
|
|
||||||
sql_base = f"""
|
sql_base = f"""
|
||||||
FROM users as u
|
FROM users as u
|
||||||
LEFT JOIN profiles AS p ON u.name = '@' || p.user_id || ':' || ?
|
LEFT JOIN profiles AS p ON u.name = p.full_user_id
|
||||||
LEFT JOIN erased_users AS eu ON u.name = eu.user_id
|
LEFT JOIN erased_users AS eu ON u.name = eu.user_id
|
||||||
{where_clause}
|
{where_clause}
|
||||||
"""
|
"""
|
||||||
|
@ -697,7 +697,7 @@ class StatsStore(StateDeltasStore):
|
|||||||
txn: LoggingTransaction,
|
txn: LoggingTransaction,
|
||||||
) -> Tuple[List[JsonDict], int]:
|
) -> Tuple[List[JsonDict], int]:
|
||||||
filters = []
|
filters = []
|
||||||
args = [self.hs.config.server.server_name]
|
args: list = []
|
||||||
|
|
||||||
if search_term:
|
if search_term:
|
||||||
filters.append("(lmr.user_id LIKE ? OR displayname LIKE ?)")
|
filters.append("(lmr.user_id LIKE ? OR displayname LIKE ?)")
|
||||||
@ -733,7 +733,7 @@ class StatsStore(StateDeltasStore):
|
|||||||
|
|
||||||
sql_base = """
|
sql_base = """
|
||||||
FROM local_media_repository as lmr
|
FROM local_media_repository as lmr
|
||||||
LEFT JOIN profiles AS p ON lmr.user_id = '@' || p.user_id || ':' || ?
|
LEFT JOIN profiles AS p ON lmr.user_id = p.full_user_id
|
||||||
{}
|
{}
|
||||||
GROUP BY lmr.user_id, displayname
|
GROUP BY lmr.user_id, displayname
|
||||||
""".format(
|
""".format(
|
||||||
|
@ -409,23 +409,22 @@ class UserDirectoryBackgroundUpdateStore(StateDeltasStore):
|
|||||||
txn, users_to_work_on
|
txn, users_to_work_on
|
||||||
)
|
)
|
||||||
|
|
||||||
# Next fetch their profiles. Note that the `user_id` here is the
|
# Next fetch their profiles. Note that not all users have profiles.
|
||||||
# *localpart*, and that not all users have profiles.
|
|
||||||
profile_rows = self.db_pool.simple_select_many_txn(
|
profile_rows = self.db_pool.simple_select_many_txn(
|
||||||
txn,
|
txn,
|
||||||
table="profiles",
|
table="profiles",
|
||||||
column="user_id",
|
column="full_user_id",
|
||||||
iterable=[get_localpart_from_id(u) for u in users_to_insert],
|
iterable=list(users_to_insert),
|
||||||
retcols=(
|
retcols=(
|
||||||
"user_id",
|
"full_user_id",
|
||||||
"displayname",
|
"displayname",
|
||||||
"avatar_url",
|
"avatar_url",
|
||||||
),
|
),
|
||||||
keyvalues={},
|
keyvalues={},
|
||||||
)
|
)
|
||||||
profiles = {
|
profiles = {
|
||||||
f"@{row['user_id']}:{self.server_name}": _UserDirProfile(
|
row["full_user_id"]: _UserDirProfile(
|
||||||
f"@{row['user_id']}:{self.server_name}",
|
row["full_user_id"],
|
||||||
row["displayname"],
|
row["displayname"],
|
||||||
row["avatar_url"],
|
row["avatar_url"],
|
||||||
)
|
)
|
||||||
|
@ -1418,7 +1418,7 @@ class DeactivateAccountTestCase(unittest.HomeserverTestCase):
|
|||||||
# To test deactivation for users without a profile, we delete the profile information for our user.
|
# To test deactivation for users without a profile, we delete the profile information for our user.
|
||||||
self.get_success(
|
self.get_success(
|
||||||
self.store.db_pool.simple_delete_one(
|
self.store.db_pool.simple_delete_one(
|
||||||
table="profiles", keyvalues={"user_id": "user"}
|
table="profiles", keyvalues={"full_user_id": "@user:test"}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user