diff --git a/core/uploads.py b/core/uploads.py index 2e0b48b..cdecf11 100644 --- a/core/uploads.py +++ b/core/uploads.py @@ -1,6 +1,5 @@ import os import secrets -import urllib.parse from typing import TYPE_CHECKING from django.utils import timezone @@ -18,16 +17,6 @@ def upload_namer(prefix, instance, filename): By default, obscures the original name with a random UUID. """ _, old_extension = os.path.splitext(filename) - - if prefix == "profile_images": - # If we're saving images for an Identity, we name predictably as - # avatar images are not considered "secret", and otherwise we'll waste - # space. - handle_safe = urllib.parse.quote(instance.handle) - return ( - f"{prefix}/{handle_safe[:2]}/{handle_safe[:4]}/{handle_safe}{old_extension}" - ) - new_filename = secrets.token_urlsafe(20) now = timezone.now() return f"{prefix}/{now.year}/{now.month}/{now.day}/{new_filename}{old_extension}" diff --git a/users/models/identity.py b/users/models/identity.py index 27a6ac8..0105f75 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -5,14 +5,12 @@ from urllib.parse import urlparse import httpx import urlman from asgiref.sync import async_to_sync, sync_to_async -from django.conf import settings from django.db import IntegrityError, models from django.template.defaultfilters import linebreaks_filter from django.utils import timezone from django.utils.functional import lazy from core.exceptions import ActorMismatchError -from core.files import get_remote_file from core.html import sanitize_post, strip_html from core.ld import ( canonicalise, @@ -50,20 +48,6 @@ class IdentityStates(StateGraph): return cls.updated # Run the actor fetch and progress to updated if it succeeds if await identity.fetch_actor(): - # Also stash their icon if we can - if identity.icon_uri: - try: - file, mimetype = await get_remote_file( - identity.icon_uri, - timeout=settings.SETUP.REMOTE_TIMEOUT, - max_size=settings.SETUP.AVATAR_MAX_IMAGE_FILESIZE_KB * 1024, - ) - except httpx.RequestError: - # We've still got enough info to consider ourselves updated - return cls.updated - if file: - identity.icon = file - await sync_to_async(identity.save)() return cls.updated @classmethod