Add an /avatars/#UserId route which redirects to the user's current avatar every time, so you don't need to update remote references to it

This commit is contained in:
Danielle McLean 2017-10-11 21:38:53 +11:00
parent 1df217ac01
commit e69202829a
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
4 changed files with 15 additions and 1 deletions

12
src/Handler/Avatars.hs Normal file
View file

@ -0,0 +1,12 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Handler.Avatars where
import Import
import Model.Cache ( getCached )
import Settings.StaticR ( staticR )
getAvatarR :: UserId -> Handler ()
getAvatarR = redirect <=< fmap (avatarR . entityVal) . getCached
where avatarR user = staticR ["img", userAvatar user]