summaryrefslogtreecommitdiff
path: root/src/Message.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2020-06-17 22:30:47 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2020-06-17 22:30:47 +0200
commita4437f0479a721aeebac305e403b88b18a5f7d5f (patch)
tree075e7db76a5a0c2021dec61a8bad2620ad01fd08 /src/Message.hs
parentb08e5a3e6d82ca5e5a2e29e791a2e61bf08964a4 (diff)
Storage: typed heads
Diffstat (limited to 'src/Message.hs')
-rw-r--r--src/Message.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Message.hs b/src/Message.hs
index 0039d7e..874e375 100644
--- a/src/Message.hs
+++ b/src/Message.hs
@@ -113,14 +113,15 @@ findMsgProperty pid sel mss = concat $ flip findProperty mss $ \x -> do
return $ sel x
-sendDirectMessage :: (MonadIO m, MonadError String m) => UnifiedIdentity -> Peer -> Text -> m (Stored DirectMessage)
-sendDirectMessage self peer text = do
+sendDirectMessage :: (MonadIO m, MonadError String m) => Head LocalState -> Peer -> Text -> m (Stored DirectMessage)
+sendDirectMessage h peer text = do
pid <- case peerIdentity peer of PeerIdentityFull pid -> return pid
_ -> throwError "incomplete peer identity"
- let st = storedStorage $ idData self
+ let st = refStorage $ headRef h
+ self = headLocalIdentity h
powner = finalOwner pid
- smsg <- liftIO $ updateSharedState st $ \prev -> do
+ smsg <- liftIO $ updateSharedState h $ \prev -> do
let sent = findMsgProperty powner msSent prev
received = findMsgProperty powner msReceived prev