diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2019-11-25 22:15:05 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2019-11-26 22:16:35 +0100 |
commit | a70628457a5ceccd37d1ba2e1791d4493b5a0502 (patch) | |
tree | 1daddb314ae7284f7e5c0c1e6308c19c681aedd1 /src/Message/Service.hs | |
parent | dd4c6aeae1cf30035f3c7c3d52e58082f6b7aa36 (diff) |
Load and announce identity updates
Diffstat (limited to 'src/Message/Service.hs')
-rw-r--r-- | src/Message/Service.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Message/Service.hs b/src/Message/Service.hs index 37aa3ab..3c3946d 100644 --- a/src/Message/Service.hs +++ b/src/Message/Service.hs @@ -13,7 +13,6 @@ import Data.Time.LocalTime import Identity import Message -import PubKey import Service import State import Storage @@ -25,14 +24,14 @@ instance Service DirectMessageService where emptyServiceState = DirectMessageService serviceHandler smsg = do let msg = fromStored smsg - powner <- asks svcPeerOwner + powner <- asks $ finalOwner . svcPeer tzone <- liftIO $ getCurrentTimeZone svcPrint $ formatMessage tzone msg - if | idData powner == msgFrom msg + if | powner `sameIdentity` msgFrom msg -> do erb <- gets svcLocal let st = storedStorage erb erb' <- liftIO $ do - slist <- case find ((== idData powner) . msgPeer . fromStored) (storedFromSList $ lsMessages $ fromStored erb) of + slist <- case find (sameIdentity powner . msgPeer . fromStored) (storedFromSList $ lsMessages $ fromStored erb) of Just thread -> do thread' <- wrappedStore st (fromStored thread) { msgHead = smsg : msgHead (fromStored thread) } slistReplaceS thread thread' $ lsMessages $ fromStored erb Nothing -> slistAdd (emptyDirectThread powner) { msgHead = [smsg] } $ lsMessages $ fromStored erb @@ -46,7 +45,7 @@ instance Service DirectMessageService where formatMessage :: TimeZone -> DirectMessage -> String formatMessage tzone msg = concat [ formatTime defaultTimeLocale "[%H:%M] " $ utcToLocalTime tzone $ zonedTimeToUTC $ msgTime msg - , maybe "<unnamed>" T.unpack $ iddName $ fromStored $ signedData $ fromStored $ msgFrom msg + , maybe "<unnamed>" T.unpack $ idName $ msgFrom msg , ": " , T.unpack $ msgText msg ] |