mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-07 02:31:59 +00:00
Call set_avatar_url with target_user, not user_id (#8872)
* Call set_avatar_url with target_user, not user_id Fixes https://github.com/matrix-org/synapse/issues/8871 * Create 8872.bugfix * Update synapse/rest/admin/users.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Testing * Update changelog.d/8872.bugfix Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
This commit is contained in:
parent
1f3748f033
commit
ff1f0ee094
1
changelog.d/8872.bugfix
Normal file
1
changelog.d/8872.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix a bug where `PUT /_synapse/admin/v2/users/<user_id>` failed to create a new user when `avatar_url` is specified. Bug introduced in Synapse v1.9.0.
|
@ -320,9 +320,9 @@ class UserRestServletV2(RestServlet):
|
||||
data={},
|
||||
)
|
||||
|
||||
if "avatar_url" in body and type(body["avatar_url"]) == str:
|
||||
if "avatar_url" in body and isinstance(body["avatar_url"], str):
|
||||
await self.profile_handler.set_avatar_url(
|
||||
user_id, requester, body["avatar_url"], True
|
||||
target_user, requester, body["avatar_url"], True
|
||||
)
|
||||
|
||||
ret = await self.admin_handler.get_user(target_user)
|
||||
|
@ -561,7 +561,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
"admin": True,
|
||||
"displayname": "Bob's name",
|
||||
"threepids": [{"medium": "email", "address": "bob@bob.bob"}],
|
||||
"avatar_url": None,
|
||||
"avatar_url": "mxc://fibble/wibble",
|
||||
}
|
||||
)
|
||||
|
||||
@ -578,6 +578,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
self.assertEqual("bob@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
self.assertEqual(True, channel.json_body["admin"])
|
||||
self.assertEqual("mxc://fibble/wibble", channel.json_body["avatar_url"])
|
||||
|
||||
# Get user
|
||||
request, channel = self.make_request(
|
||||
@ -592,6 +593,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
self.assertEqual(True, channel.json_body["admin"])
|
||||
self.assertEqual(False, channel.json_body["is_guest"])
|
||||
self.assertEqual(False, channel.json_body["deactivated"])
|
||||
self.assertEqual("mxc://fibble/wibble", channel.json_body["avatar_url"])
|
||||
|
||||
def test_create_user(self):
|
||||
"""
|
||||
@ -606,6 +608,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
"admin": False,
|
||||
"displayname": "Bob's name",
|
||||
"threepids": [{"medium": "email", "address": "bob@bob.bob"}],
|
||||
"avatar_url": "mxc://fibble/wibble",
|
||||
}
|
||||
)
|
||||
|
||||
@ -622,6 +625,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
self.assertEqual("bob@bob.bob", channel.json_body["threepids"][0]["address"])
|
||||
self.assertEqual(False, channel.json_body["admin"])
|
||||
self.assertEqual("mxc://fibble/wibble", channel.json_body["avatar_url"])
|
||||
|
||||
# Get user
|
||||
request, channel = self.make_request(
|
||||
@ -636,6 +640,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
self.assertEqual(False, channel.json_body["admin"])
|
||||
self.assertEqual(False, channel.json_body["is_guest"])
|
||||
self.assertEqual(False, channel.json_body["deactivated"])
|
||||
self.assertEqual("mxc://fibble/wibble", channel.json_body["avatar_url"])
|
||||
|
||||
@override_config(
|
||||
{"limit_usage_by_mau": True, "max_mau_value": 2, "mau_trial_days": 0}
|
||||
|
Loading…
Reference in New Issue
Block a user