diff --git a/Handler/AlbumSettings.hs b/Handler/AlbumSettings.hs index 154304f..324fb0e 100644 --- a/Handler/AlbumSettings.hs +++ b/Handler/AlbumSettings.hs @@ -4,6 +4,7 @@ import Import import qualified Data.Text as T import System.Directory import System.FilePath +import qualified Data.List as L getAlbumSettingsR :: AlbumId -> Handler Html getAlbumSettingsR albumId = do @@ -58,9 +59,27 @@ postAlbumSettingsR albumId = do ((result, albumSettingsWidget), enctype) <- runFormPost $ albumSettingsForm album albumId users case result of FormSuccess temp -> do + newShares <- return (L.sort $ albumShares temp) + oldShares <- return (L.sort $ albumShares album) + case newShares /= oldShares of + True -> do + rcptIds <- return $ L.nub $ newShares L.\\ oldShares + rcptMails <- mapM (\uId -> do + user <- runDB $ getJust uId + return $ userEmail user + ) rcptIds + mapM (\addr -> sendMail addr "A new album was shared with you" $ + [shamlet| +