Let users pick their Gravatar as their profile image (SCR-1)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m42s
CI / test (push) Successful in 5m46s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 7s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m42s
CI / test (push) Successful in 5m46s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 7s
Opt-in per user and gated by AVATAR_GRAVATAR_ENABLED. The server fetches the image by the SHA-256 of the account email and caches it with the uploads, so browsers never contact Gravatar. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c55a6596d0
commit
9243fe4d3f
8 files changed
+328
-4
No files matched your search
@@ -9,7 +9,10 @@ from scrobbler.services import avatars
|
||||
blp = Blueprint(
|
||||
"Avatar",
|
||||
__name__,
|
||||
description="Your profile image: upload one, or remove it.",
|
||||
description=(
|
||||
"Your profile image: upload one, use your Gravatar (if this server allows it), "
|
||||
"or remove it."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -59,6 +62,29 @@ def upload_avatar(files):
|
||||
return g.user
|
||||
|
||||
|
||||
@blp.route("/gravatar", methods=["POST"])
|
||||
@authenticated(blp)
|
||||
@blp.response(200, UserSchema)
|
||||
@blp.alt_response(404, schema=ErrorSchema, description="Gravatar is off, or has no image for you")
|
||||
@blp.alt_response(502, schema=ErrorSchema, description="Gravatar couldn't be reached")
|
||||
def use_gravatar():
|
||||
"""Use your Gravatar as your profile image
|
||||
|
||||
The server fetches the image for your account email from Gravatar (sending it a hash
|
||||
of the address) and keeps a copy. Call again to refresh it. Only available when the
|
||||
server's admin has enabled it; see `gravatar_enabled` on `/auth/me`.
|
||||
"""
|
||||
try:
|
||||
avatars.use_gravatar(g.user)
|
||||
except avatars.GravatarDisabled:
|
||||
abort(404, code="gravatar_disabled", message="This server doesn't use Gravatar.")
|
||||
except avatars.GravatarMissing:
|
||||
abort(404, code="no_gravatar", message="Gravatar has no image for your email address.")
|
||||
except avatars.GravatarUnavailable:
|
||||
abort(502, code="gravatar_unavailable", message="Gravatar couldn't be reached.")
|
||||
return g.user
|
||||
|
||||
|
||||
@blp.route("", methods=["DELETE"])
|
||||
@authenticated(blp)
|
||||
@blp.response(204)
|
||||
|
||||
Reference in new issue
Block a user