2016-02-14 18:10:21 +09:00
|
|
|
{- This file is part of Vervis.
|
|
|
|
-
|
|
|
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
|
|
|
-
|
|
|
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
|
|
|
-
|
|
|
|
- The author(s) have dedicated all copyright and related and neighboring
|
|
|
|
- rights to this software to the public domain worldwide. This software is
|
|
|
|
- distributed without any warranty.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the CC0 Public Domain Dedication along
|
|
|
|
- with this software. If not, see
|
|
|
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
-}
|
|
|
|
|
2016-05-19 21:06:27 +09:00
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
2016-02-14 18:10:21 +09:00
|
|
|
|
2016-02-23 17:45:03 +09:00
|
|
|
module Vervis.Model where
|
2016-02-14 18:10:21 +09:00
|
|
|
|
2016-02-29 23:04:23 +09:00
|
|
|
import ClassyPrelude.Conduit
|
|
|
|
import Yesod hiding (Header, parseTime)
|
|
|
|
|
2016-02-14 18:10:21 +09:00
|
|
|
import Database.Persist.Quasi
|
2016-05-19 21:06:27 +09:00
|
|
|
import Database.Persist.Sql (fromSqlKey)
|
2016-02-16 20:41:13 +09:00
|
|
|
import Yesod.Auth.HashDB (HashDBUser (..))
|
2016-02-14 18:10:21 +09:00
|
|
|
|
2016-05-03 08:51:53 +09:00
|
|
|
import Vervis.Model.Repo
|
|
|
|
|
2016-02-14 18:10:21 +09:00
|
|
|
-- You can define all of your database entities in the entities file.
|
2016-02-16 20:41:13 +09:00
|
|
|
-- You can find more information on persistent and how to declare entities at:
|
2016-02-14 18:10:21 +09:00
|
|
|
-- http://www.yesodweb.com/book/persistent/
|
|
|
|
share [mkPersist sqlSettings, mkMigrate "migrateAll"]
|
|
|
|
$(persistFileWith lowerCaseSettings "config/models")
|
2016-02-16 20:41:13 +09:00
|
|
|
|
|
|
|
instance HashDBUser Person where
|
|
|
|
userPasswordHash = personHash
|
|
|
|
setPasswordHash hash person = person { personHash = Just hash }
|
2016-05-19 21:06:27 +09:00
|
|
|
|
|
|
|
-- "Vervis.Discussion" uses a 'HashMap' where the key type is 'MessageId'
|
|
|
|
instance Hashable MessageId where
|
|
|
|
hashWithSalt salt = hashWithSalt salt . fromSqlKey
|
|
|
|
hash = hash . fromSqlKey
|