modified: app.py
This commit is contained in:
7
app.py
7
app.py
@@ -114,6 +114,12 @@ def fetch_and_cache_profile_picture(user_id, avatar_url):
|
||||
|
||||
local_image_path = os.path.join(PROFILE_IMAGE_DIR, f"{user_id}.png")
|
||||
|
||||
# Prüfen, ob das Bild bereits lokal gespeichert ist
|
||||
if os.path.exists(local_image_path):
|
||||
print(f"Profile picture for user {user_id} already exists locally.")
|
||||
r.set(str(user_id), local_image_path)
|
||||
return local_image_path
|
||||
|
||||
try:
|
||||
# Bild von der URL herunterladen und speichern
|
||||
response = requests.get(avatar_url, timeout=10)
|
||||
@@ -131,6 +137,7 @@ def fetch_and_cache_profile_picture(user_id, avatar_url):
|
||||
print(f"Error fetching profile picture for user {user_id}: {e}")
|
||||
return "/static/default_profile.png"
|
||||
|
||||
|
||||
def get_profile_picture(user_id, avatar_url):
|
||||
"""Versucht, das Profilbild eines Benutzers aus Redis, lokalem Speicher und zuletzt durch Download zu holen."""
|
||||
# 1. Versuch: Redis
|
||||
|
||||
Reference in New Issue
Block a user