Skip to content

Commit

Permalink
Add login and alogin to MatrixAdminClient
Browse files Browse the repository at this point in the history
  • Loading branch information
thebalaa committed Aug 6, 2024
1 parent b706cec commit f9820aa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fractal/matrix/admin_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Tuple

import requests
from asgiref.sync import async_to_sync


class MatrixAdminClient:
Expand Down Expand Up @@ -51,7 +52,7 @@ async def create_or_modify_user(
deactivated=False,
user_type=None,
locked=False,
) -> Tuple[str, str]:
) -> None:
"""
Create or modify a user account using the Synapse Admin API.
Expand Down Expand Up @@ -105,11 +106,16 @@ async def create_or_modify_user(
body = {k: v for k, v in body.items() if v is not None}

# Make the API request
response = self.do_request("PUT", endpoint, body)
# TODO make me async
self.do_request("PUT", endpoint, body)

async def alogin(self, user_id, password):
from fractal.matrix import MatrixClient

async with MatrixClient(self.homeserver_url) as client:
client.user = user_id
result = await client.login(password)
return result.user_id, result.access_token
return result.user_id, result.access_token

def login(self, user_id, password):
return async_to_sync(self.alogin)(user_id, password)

0 comments on commit f9820aa

Please sign in to comment.