from . import handlers_base as base
class AvatarHandler(base.BaseHandler):
- def get(self, who):
+ def get(self, uid):
# Get the desired size of the avatar file
size = self.get_argument("size", 0)
except (TypeError, ValueError):
size = None
- logging.debug("Querying for avatar of %s" % who)
+ logging.debug("Querying for avatar of %s" % uid)
# Fetch user account
- account = self.backend.accounts.get_by_uid(who)
+ account = self.backend.accounts.get_by_uid(uid)
if not account:
- raise tornado.web.HTTPError(404)
+ raise tornado.web.HTTPError(404, "Could not find account %s" % uid)
# Allow downstream to cache this for 60 minutes
self.set_expires(3600)
# If there is no avatar, we serve a default image
if not avatar:
+ logging.debug("No avatar uploaded for %s" % account)
+
return self.redirect("https://static.ipfire.org%s" % self.static_url("img/default-avatar.jpg"))
# Set headers about content
- self.set_header("Content-Disposition", "inline; filename=\"%s.jpg\"" % who)
+ self.set_header("Content-Disposition", "inline; filename=\"%s.jpg\"" % account.uid)
self.set_header("Content-Type", "image/jpeg")
# Deliver payload