Skip to content

Commit

Permalink
Bug fix in user class for missing admin field for non admin users.
Browse files Browse the repository at this point in the history
  • Loading branch information
isFakeAccount committed Dec 21, 2023
1 parent 62ad3f9 commit d345aff
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions async_lemmy_py/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Optional, Self, Any

from aiohttp import ClientSession
from click import Option


@dataclass
Expand All @@ -23,9 +24,9 @@ class User:
actor_id: str
local: bool
deleted: bool
admin: bool
bot_account: bool
instance_id: int
admin: Optional[bool] = None
bio: Optional[str] = None
inbox_url: Optional[str] = None
matrix_user_id: Optional[str] = None
Expand All @@ -50,7 +51,7 @@ async def get_flair(self) -> Optional[UserFlair]:
async with ClientSession() as session:
params = {"community_actor_id": "https://lemmy.basedcount.com/c/pcm", "user_actor_id": self.actor_id}
async with session.get("https://lemmy.basedcount.com/flair/api/v1/user", params=params) as resp:
data = await resp.json()
if data is None:
if resp.status == 404:
return None
data = await resp.json()
return UserFlair(**data)

0 comments on commit d345aff

Please sign in to comment.