From a70628457a5ceccd37d1ba2e1791d4493b5a0502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Mon, 25 Nov 2019 22:15:05 +0100 Subject: Load and announce identity updates --- src/Message/Service.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Message') 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 "" T.unpack $ iddName $ fromStored $ signedData $ fromStored $ msgFrom msg + , maybe "" T.unpack $ idName $ msgFrom msg , ": " , T.unpack $ msgText msg ] -- cgit v1.2.3