diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2019-10-11 22:19:15 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2019-10-11 22:19:15 +0200 |
commit | 61b04eb5fda0d1e94f673ad1c11f328a318bb09d (patch) | |
tree | f9dc3edde8de7f50e17bcd0bcc3873f8cda6c89c /src/Message.hs | |
parent | 681c68ef5843c13df1a8e5da3540b2b00ba2eb03 (diff) |
Identity merging and verification
Diffstat (limited to 'src/Message.hs')
-rw-r--r-- | src/Message.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Message.hs b/src/Message.hs index 0a1a70e..8892edb 100644 --- a/src/Message.hs +++ b/src/Message.hs @@ -11,17 +11,18 @@ import Data.Text (Text) import Data.Time.LocalTime import Identity +import PubKey import Storage data DirectMessage = DirectMessage - { msgFrom :: Stored Identity + { msgFrom :: Stored (Signed IdentityData) , msgPrev :: [Stored DirectMessage] , msgTime :: ZonedTime , msgText :: Text } data DirectMessageThread = DirectMessageThread - { msgPeer :: Stored Identity + { msgPeer :: Stored (Signed IdentityData) , msgHead :: [Stored DirectMessage] , msgSeen :: [Stored DirectMessage] } @@ -51,15 +52,15 @@ instance Storable DirectMessageThread where <*> loadRefs "seen" -emptyDirectThread :: Stored Identity -> DirectMessageThread -emptyDirectThread peer = DirectMessageThread peer [] [] +emptyDirectThread :: UnifiedIdentity -> DirectMessageThread +emptyDirectThread peer = DirectMessageThread (idData peer) [] [] -createDirectMessage :: Stored Identity -> DirectMessageThread -> Text -> IO (Stored DirectMessage, Stored DirectMessageThread) +createDirectMessage :: UnifiedIdentity -> DirectMessageThread -> Text -> IO (Stored DirectMessage, Stored DirectMessageThread) createDirectMessage self thread msg = do - let st = storedStorage self + let st = storedStorage $ idData self time <- getZonedTime smsg <- wrappedStore st DirectMessage - { msgFrom = finalOwner self + { msgFrom = idData $ finalOwner self , msgPrev = msgHead thread , msgTime = time , msgText = msg |