diff --git a/apps/participation/management/commands/fix_matrix_channels.py b/apps/participation/management/commands/fix_matrix_channels.py index 4be6bb6..9213e9f 100644 --- a/apps/participation/management/commands/fix_matrix_channels.py +++ b/apps/participation/management/commands/fix_matrix_channels.py @@ -23,7 +23,10 @@ class Command(BaseCommand): else: # pragma: no cover if not os.path.isfile(".matrix_avatar"): avatar_uri = Matrix.get_avatar() - if not isinstance(avatar_uri, str): + if isinstance(avatar_uri, str): + with open(".matrix_avatar", "w") as f: + f.write(avatar_uri) + else: stat_file = os.stat("tfjm/static/logo.png") with open("tfjm/static/logo.png", "rb") as f: resp = Matrix.upload(f, filename="logo.png", content_type="image/png", diff --git a/tfjm/matrix.py b/tfjm/matrix.py index 20732d6..3d7e48d 100644 --- a/tfjm/matrix.py +++ b/tfjm/matrix.py @@ -76,7 +76,7 @@ class Matrix: """ client = await cls._get_client() resp = await client.get_avatar() - return resp.avatar_url if resp.status_code == 200 else resp + return resp.avatar_url if hasattr(resp, "avatar_url") else resp @classmethod @async_to_sync