Compare commits

...

2 commits

Author SHA1 Message Date
7590773710 add theme color to /v1/health 2025-10-11 19:15:28 +02:00
213a48130f add /v1/guild/:id 2025-10-09 16:38:02 +02:00
2 changed files with 14 additions and 1 deletions

View file

@ -81,3 +81,4 @@ class UserLoader(AuthUser):
id: int
username: str
display_name: str
theme_color: int

View file

@ -47,7 +47,8 @@ async def health():
name = app_config.app_name,
post_count = await Post.count(),
user_count = await User.active_count(),
me = Snowflake(current_user.id).to_b32l() if current_user else None
me = Snowflake(current_user.id).to_b32l() if current_user else None,
theme_color = current_user.theme_color if current_user else 0
)
return hi
@ -160,6 +161,17 @@ async def _guild_info(gu: Guild):
badges = []
)
@bp.get('/guild/<b32l:gid>')
async def guild_info_id(gid: int):
async with db as session:
gu: Guild | None = (await session.execute(select(Guild).where(Guild.id == gid))).scalar()
if gu is None:
return dict(error='Not found'), 404
gj = await _guild_info(gu)
return dict(guilds={f'{Snowflake(gu.id):l}': gj})
@bp.get('/guild/@<gname>')
async def guild_info_only(gname: str):
async with db as session: