feat: migrate UID system from usernames to email addresses
- Database migration: Updated publicstream.uid from usernames to email addresses - devuser → oib@bubuit.net - oibchello → oib@chello.at - Updated related tables (UploadLog, UserQuota) to use email-based UIDs - Fixed backend audio route to map email UIDs to username-based directories - Updated SSE event payloads to use email for UID and username for display - Removed redundant display_name field from SSE events - Fixed frontend rendering conflicts between nav.js and streams-ui.js - Updated stream player template to display usernames instead of email addresses - Added cache-busting parameters to force browser refresh - Created migration script for future reference Benefits: - Eliminates UID duplicates and inconsistency - Provides stable, unique email-based identifiers - Maintains user-friendly username display - Follows proper data normalization practices Fixes: Stream UI now displays usernames (devuser, oibchello) instead of email addresses
This commit is contained in:
15
main.py
15
main.py
@ -92,7 +92,20 @@ from range_response import range_response
|
||||
@app.get("/audio/{uid}/{filename}")
|
||||
def get_audio(uid: str, filename: str, request: Request, db: Session = Depends(get_db)):
|
||||
# Allow public access ONLY to stream.opus
|
||||
user_dir = os.path.join("data", uid)
|
||||
|
||||
# Map email-based UID to username for file system access
|
||||
# If UID contains @, it's an email - look up the corresponding username
|
||||
if '@' in uid:
|
||||
from models import User
|
||||
user = db.exec(select(User).where(User.email == uid)).first()
|
||||
if not user:
|
||||
raise HTTPException(status_code=404, detail="User not found")
|
||||
filesystem_uid = user.username
|
||||
else:
|
||||
# Legacy support for username-based UIDs
|
||||
filesystem_uid = uid
|
||||
|
||||
user_dir = os.path.join("data", filesystem_uid)
|
||||
file_path = os.path.join(user_dir, filename)
|
||||
real_user_dir = os.path.realpath(user_dir)
|
||||
real_file_path = os.path.realpath(file_path)
|
||||
|
Reference in New Issue
Block a user