Resoted avatars.
This commit is contained in:
parent
9378e95a5b
commit
d3844ac7a7
@ -51,19 +51,25 @@ class AvatarView(BaseView):
|
||||
|
||||
async def get_animal(self):
|
||||
uid = self.request.match_info.get("uid")
|
||||
if uid == "unique":
|
||||
uid = str(uuid.uuid4())
|
||||
key = "avatar_animal_" + uid
|
||||
|
||||
avatar = await self.app.get(key)
|
||||
if avatar:
|
||||
return web.Response(text=avatar, content_type="image/svg+xml")
|
||||
|
||||
while True:
|
||||
try:
|
||||
return web.Response(text=self._get(uid), content_type="image/svg+xml")
|
||||
avatar = generate_avatar_with_options(self.request.query)
|
||||
await self.app.set(key, avatar)
|
||||
return web.Response(text=avatar, content_type="image/svg+xml")
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
||||
def _get(self, uid):
|
||||
if uid in self.avatars:
|
||||
return self.avatars[uid]
|
||||
|
||||
avatar = generate_avatar_with_options(self.request.query)
|
||||
self.avatars[uid] = avatar
|
||||
return avatar
|
||||
|
||||
async def get_default(self):
|
||||
|
Loading…
Reference in New Issue
Block a user