Skip to content

Commit

Permalink
Adds ability to make a matrix_id an admin
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-russell committed Jul 10, 2024
1 parent d0bf62f commit 145fc9f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fractal/matrix/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,28 @@ async def set_displayname(self, displayname: str) -> None:
raise Exception(res.message)
return None

async def synapse_admin_make_user_admin(self, matrix_id: str) -> None:
"""
Make a user an admin on the homeserver. Assumes that you are an admin to
the homeserver.
Args:
matrix_id: The matrix ID of the user to make an admin.
"""
url = f"{self.homeserver}/_synapse/admin/v1/users/{matrix_id}/admin"
headers = {"Authorization": f"Bearer {self.access_token}"}

request_data = {"admin": True}
async with aiohttp.ClientSession() as session:
async with session.put(url, json=request_data, headers=headers) as response:
if not response.ok:
txt = await response.text()
logger.error(
f"Failed to update registration token. Error Response status {response.status}: {txt}"
)
raise Exception(f"Failed to update registration token. Error Response status {response.status}: {txt}")
return None


class MatrixClient:
"""
Expand Down

0 comments on commit 145fc9f

Please sign in to comment.