This commit is contained in:
+2
-8
@@ -19,7 +19,7 @@ from backend.app.api.setup import has_administrator
|
||||
from backend.app.api.user_config import router as user_config_router
|
||||
from backend.app.core.config import settings
|
||||
from backend.app.database import AVATARS_DIR
|
||||
from backend.app.services.link_service import list_public_links
|
||||
from backend.app.services.link_service import get_public_profile, list_public_links
|
||||
|
||||
logging.basicConfig(level=getattr(logging, settings.log_level, logging.INFO))
|
||||
|
||||
@@ -99,13 +99,7 @@ def health_check():
|
||||
@app.get('/{username}/', response_class=HTMLResponse)
|
||||
async def public_user_feed(request: Request, username: str):
|
||||
feed = list_public_links(username)
|
||||
profile = None
|
||||
if feed:
|
||||
profile = {
|
||||
'username': feed[0]['username'],
|
||||
'avatar_url': feed[0]['avatar_url'],
|
||||
'bio': feed[0]['bio'],
|
||||
}
|
||||
profile = get_public_profile(username)
|
||||
return templates.TemplateResponse(
|
||||
request,
|
||||
'feed.html',
|
||||
|
||||
@@ -127,6 +127,15 @@ def list_public_links(username: str | None = None):
|
||||
return records
|
||||
|
||||
|
||||
def get_public_profile(username: str) -> dict | None:
|
||||
with get_connection() as conn:
|
||||
row = conn.execute(
|
||||
'SELECT username, avatar_url, bio FROM users WHERE username = ?',
|
||||
(username,),
|
||||
).fetchone()
|
||||
return dict(row) if row else None
|
||||
|
||||
|
||||
def update_link(
|
||||
link_id: str,
|
||||
user_id: str,
|
||||
|
||||
Reference in New Issue
Block a user