{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}

module Simplex.Chat.View where

import qualified Data.Aeson as J
import qualified Data.Aeson.TH as JQ
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as LB
import Data.Char (isSpace, toUpper)
import Data.Function (on)
import Data.Int (Int64)
import Data.List (groupBy, intercalate, intersperse, sortOn)
import Data.List.NonEmpty (NonEmpty (..))
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Maybe (fromMaybe, isJust, isNothing, mapMaybe)
import Data.String
import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Encoding (decodeLatin1)
import Data.Time (LocalTime (..), TimeOfDay (..), TimeZone (..), utcToLocalTime)
import Data.Time.Calendar (addDays)
import Data.Time.Clock (UTCTime)
import Data.Time.Format (defaultTimeLocale, formatTime)
import qualified Data.Version as V
import qualified Network.HTTP.Types as Q
import Numeric (showFFloat)
import Simplex.Chat.Call
import Simplex.Chat.Controller
import Simplex.Chat.Help
import Simplex.Chat.Library.Commands (maxImageSize)
import Simplex.Chat.Markdown
import Simplex.Chat.Messages hiding (NewChatItem (..))
import Simplex.Chat.Messages.CIContent
import Simplex.Chat.Operators
import Simplex.Chat.Protocol
import Simplex.Chat.Remote.AppVersion (AppVersion (..), pattern AppVersionRange)
import Simplex.Chat.Remote.Types
import Simplex.Chat.Store (AddressSettings (..), AutoAccept (..), StoreError (..), UserContactLink (..))
import Simplex.Chat.Styled
import Simplex.Chat.Types
import Simplex.Chat.Types.Preferences
import Simplex.Chat.Types.Shared
import Simplex.Chat.Types.UITheme
import qualified Simplex.FileTransfer.Transport as XFTP
import Simplex.Messaging.Agent (DatabaseDiff (..))
import Simplex.Messaging.Agent.Client (ProtocolTestFailure (..), ProtocolTestStep (..), SubscriptionsInfo (..))
import Simplex.Messaging.Agent.Env.SQLite (NetworkConfig (..), ServerRoles (..))
import Simplex.Messaging.Agent.Protocol
import Simplex.Messaging.Agent.Store.Entity
import Simplex.Messaging.Client (SMPProxyFallback, SMPProxyMode (..), SocksMode (..))
import qualified Simplex.Messaging.Crypto as C
import Simplex.Messaging.Crypto.File (CryptoFile (..), CryptoFileArgs (..))
import qualified Simplex.Messaging.Crypto.Ratchet as CR
import Simplex.Messaging.Encoding
import Simplex.Messaging.Encoding.String
import Simplex.Messaging.Parsers (dropPrefix, taggedObjectJSON)
import Simplex.Messaging.Protocol (AProtoServerWithAuth (..), AProtocolType, BlockingInfo (..), BlockingReason (..), NetworkError (..), ProtocolServer (..), ProtocolTypeI, SProtocolType (..), UserProtocol)
import qualified Simplex.Messaging.Protocol as SMP
import Simplex.Messaging.Transport.Client (TransportHost (..))
import Simplex.Messaging.Util (safeDecodeUtf8, tshow)
import Simplex.Messaging.Version hiding (version)
import Simplex.RemoteControl.Types (RCCtrlAddress (..), RCErrorType (..))
import System.Console.ANSI.Types
#if !defined(dbPostgres)
import Simplex.Messaging.Agent.Store.SQLite.DB (SlowQueryStats (..))
#endif

type CurrentTime = UTCTime

data WCallCommand
  = WCCallStart {WCallCommand -> CallMedia
media :: CallMedia, WCallCommand -> Maybe String
aesKey :: Maybe String, WCallCommand -> Bool
useWorker :: Bool}
  | WCCallOffer {WCallCommand -> ContactName
offer :: Text, WCallCommand -> ContactName
iceCandidates :: Text, media :: CallMedia, aesKey :: Maybe String, useWorker :: Bool}
  | WCCallAnswer {WCallCommand -> ContactName
answer :: Text, iceCandidates :: Text}

$(JQ.deriveToJSON (taggedObjectJSON $ dropPrefix "WCCall") ''WCallCommand)

serializeChatError :: Bool -> ChatConfig -> ChatError -> String
serializeChatError :: Bool -> ChatConfig -> ChatError -> String
serializeChatError Bool
isCmd ChatConfig
cfg = [String] -> String
unlines ([String] -> String)
-> (ChatError -> [String]) -> ChatError -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyledString -> String) -> [StyledString] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map StyledString -> String
unStyle ([StyledString] -> [String])
-> (ChatError -> [StyledString]) -> ChatError -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> ChatConfig -> ChatError -> [StyledString]
chatErrorToView Bool
isCmd ChatConfig
cfg

serializeChatResponse :: ChatResponseEvent r => (Maybe RemoteHostId, Maybe User) -> ChatConfig -> CurrentTime -> TimeZone -> Maybe RemoteHostId -> r -> String
serializeChatResponse :: forall r.
ChatResponseEvent r =>
(Maybe ContactId, Maybe User)
-> ChatConfig
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> r
-> String
serializeChatResponse (Maybe ContactId, Maybe User)
hu ChatConfig
cfg UTCTime
ts TimeZone
tz Maybe ContactId
remoteHost_ = [String] -> String
unlines ([String] -> String) -> (r -> [String]) -> r -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (StyledString -> String) -> [StyledString] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map StyledString -> String
unStyle ([StyledString] -> [String])
-> (r -> [StyledString]) -> r -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> r
-> [StyledString]
forall r.
ChatResponseEvent r =>
(Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> r
-> [StyledString]
responseToView (Maybe ContactId, Maybe User)
hu ChatConfig
cfg Bool
False UTCTime
ts TimeZone
tz Maybe ContactId
remoteHost_

class ChatResponseEvent r where
  responseToView :: (Maybe RemoteHostId, Maybe User) -> ChatConfig -> Bool -> CurrentTime -> TimeZone -> Maybe RemoteHostId -> r -> [StyledString]
  isCommandResponse :: Bool

instance ChatResponseEvent ChatResponse where
  responseToView :: (Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> ChatResponse
-> [StyledString]
responseToView = (Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> ChatResponse
-> [StyledString]
chatResponseToView
  isCommandResponse :: Bool
isCommandResponse = Bool
True

instance ChatResponseEvent ChatEvent where
  responseToView :: (Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> ChatEvent
-> [StyledString]
responseToView = (Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> ChatEvent
-> [StyledString]
chatEventToView
  isCommandResponse :: Bool
isCommandResponse = Bool
False

chatErrorToView :: Bool -> ChatConfig -> ChatError -> [StyledString]
chatErrorToView :: Bool -> ChatConfig -> ChatError -> [StyledString]
chatErrorToView Bool
isCmd ChatConfig {ChatLogLevel
logLevel :: ChatLogLevel
logLevel :: ChatConfig -> ChatLogLevel
logLevel, Bool
testView :: Bool
testView :: ChatConfig -> Bool
testView} = Bool -> ChatLogLevel -> Bool -> ChatError -> [StyledString]
viewChatError Bool
isCmd ChatLogLevel
logLevel Bool
testView

chatResponseToView :: (Maybe RemoteHostId, Maybe User) -> ChatConfig -> Bool -> CurrentTime -> TimeZone -> Maybe RemoteHostId -> ChatResponse -> [StyledString]
chatResponseToView :: (Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> ChatResponse
-> [StyledString]
chatResponseToView (Maybe ContactId, Maybe User)
hu cfg :: ChatConfig
cfg@ChatConfig {ChatLogLevel
logLevel :: ChatConfig -> ChatLogLevel
logLevel :: ChatLogLevel
logLevel, Bool
showReactions :: Bool
showReactions :: ChatConfig -> Bool
showReactions, Bool
testView :: ChatConfig -> Bool
testView :: Bool
testView} Bool
liveItems UTCTime
ts TimeZone
tz Maybe ContactId
outputRH = \case
  CRActiveUser User {LocalProfile
profile :: LocalProfile
profile :: User -> LocalProfile
profile, Maybe UIThemeEntityOverrides
uiThemes :: Maybe UIThemeEntityOverrides
uiThemes :: User -> Maybe UIThemeEntityOverrides
uiThemes} -> Profile -> [StyledString]
viewUserProfile (LocalProfile -> Profile
fromLocalProfile LocalProfile
profile) [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> Maybe UIThemeEntityOverrides -> [StyledString]
viewUITheme Maybe UIThemeEntityOverrides
uiThemes
  CRUsersList [UserInfo]
users -> [UserInfo] -> [StyledString]
viewUsersList [UserInfo]
users
  ChatResponse
CRChatStarted -> [StyledString
"chat started"]
  ChatResponse
CRChatRunning -> [StyledString
"chat is running"]
  ChatResponse
CRChatStopped -> [StyledString
"chat stopped"]
  CRConnectionsDiff Bool
showIds DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
    | Bool
showIds -> DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffIds DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
    | Bool
otherwise -> DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSummary DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
  CRApiChats User
u [AChat]
chats -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ if Bool
testView then [AChat] -> [StyledString]
testViewChats [AChat]
chats else [[AChat] -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON [AChat]
chats]
  CRChats [AChat]
chats -> UTCTime -> TimeZone -> [AChat] -> [StyledString]
viewChats UTCTime
ts TimeZone
tz [AChat]
chats
  CRApiChat User
u AChat
chat Maybe NavigationInfo
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ if Bool
testView then AChat -> [StyledString]
testViewChat AChat
chat else [AChat -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON AChat
chat]
  CRChatTags User
u [ChatTag]
tags -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [[ChatTag] -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON [ChatTag]
tags]
  CRServerTestResult User
u AProtoServerWithAuth
srv Maybe ProtocolTestFailure
testFailure -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AProtoServerWithAuth -> Maybe ProtocolTestFailure -> [StyledString]
viewServerTestResult AProtoServerWithAuth
srv Maybe ProtocolTestFailure
testFailure
  CRServerOperatorConditions (ServerOperatorConditions [ServerOperator]
ops UsageConditions
_ Maybe UsageConditionsAction
ca) -> [ServerOperator] -> Maybe UsageConditionsAction -> [StyledString]
viewServerOperators [ServerOperator]
ops Maybe UsageConditionsAction
ca
  CRUserServers User
u [UserOperatorServers]
uss -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (UserOperatorServers -> [StyledString])
-> [UserOperatorServers] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap UserOperatorServers -> [StyledString]
viewUserServers [UserOperatorServers]
uss [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (if Bool
testView then [] else [StyledString]
serversUserHelp)
  CRUserServersValidation {} -> []
  CRUsageConditions UsageConditions
current ContactName
_ Maybe UsageConditions
accepted_ -> UsageConditions -> Maybe UsageConditions -> [StyledString]
viewUsageConditions UsageConditions
current Maybe UsageConditions
accepted_
  CRChatItemTTL User
u Maybe ContactId
ttl -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Maybe ContactId -> [StyledString]
viewChatItemTTL Maybe ContactId
ttl
  CRNetworkConfig NetworkConfig
netCfg -> NetworkConfig -> [StyledString]
viewNetworkConfig NetworkConfig
netCfg
  CRContactInfo User
u Contact
ct Maybe ConnectionStats
cStats Maybe Profile
customUserProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> Maybe ConnectionStats -> Maybe Profile -> [StyledString]
viewContactInfo Contact
ct Maybe ConnectionStats
cStats Maybe Profile
customUserProfile
  CRGroupInfo User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [StyledString]
viewGroupInfo GroupInfo
g
  CRGroupMemberInfo User
u GroupInfo
g GroupMember
m Maybe ConnectionStats
cStats -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> Maybe ConnectionStats -> [StyledString]
viewGroupMemberInfo GroupInfo
g GroupMember
m Maybe ConnectionStats
cStats
  CRQueueInfo User
_ Maybe RcvMsgInfo
msgInfo ServerQueueInfo
qInfo ->
    [ StyledString
"last received msg: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (RcvMsgInfo -> StyledString) -> Maybe RcvMsgInfo -> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"none" RcvMsgInfo -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON Maybe RcvMsgInfo
msgInfo,
      StyledString
"server queue info: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ServerQueueInfo -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON ServerQueueInfo
qInfo
    ]
  CRContactSwitchStarted {} -> [StyledString
"switch started"]
  CRGroupMemberSwitchStarted {} -> [StyledString
"switch started"]
  CRContactSwitchAborted {} -> [StyledString
"switch aborted"]
  CRGroupMemberSwitchAborted {} -> [StyledString
"switch aborted"]
  CRContactRatchetSyncStarted {} -> [StyledString
"connection synchronization started"]
  CRGroupMemberRatchetSyncStarted {} -> [StyledString
"connection synchronization started"]
  CRConnectionVerified User
u Bool
verified ContactName
code -> User -> [StyledString] -> [StyledString]
ttyUser User
u [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ if Bool
verified then ContactName
"connection verified" else ContactName
"connection not verified, current code is " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
code]
  CRContactCode User
u Contact
ct ContactName
code -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> ContactName -> Bool -> [StyledString]
viewContactCode Contact
ct ContactName
code Bool
testView
  CRGroupMemberCode User
u GroupInfo
g GroupMember
m ContactName
code -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> ContactName -> Bool -> [StyledString]
viewGroupMemberCode GroupInfo
g GroupMember
m ContactName
code Bool
testView
  CRNewChatItems User
u [AChatItem]
chatItems -> (User -> [StyledString] -> [StyledString])
-> (forall (c :: ChatType) (d :: MsgDirection).
    User
    -> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString])
-> User
-> [AChatItem]
-> UTCTime
-> TimeZone
-> [StyledString]
viewChatItems User -> [StyledString] -> [StyledString]
ttyUser User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u [AChatItem]
chatItems UTCTime
ts TimeZone
tz
  CRChatItems User
u Maybe ChatName
_ [AChatItem]
chatItems -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (AChatItem -> [StyledString]) -> [AChatItem] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat ChatItem c d
item) -> ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewChatItem ChatInfo c
chat ChatItem c d
item Bool
True UTCTime
ts TimeZone
tz [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> ChatItem c d -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> [StyledString]
viewItemReactions ChatItem c d
item) [AChatItem]
chatItems
  CRChatItemInfo User
u AChatItem
ci ChatItemInfo
ciInfo -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatItem -> ChatItemInfo -> TimeZone -> [StyledString]
viewChatItemInfo AChatItem
ci ChatItemInfo
ciInfo TimeZone
tz
  CRChatItemId User
u Maybe ContactId
itemId -> User -> [StyledString] -> [StyledString]
ttyUser User
u [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String -> (ContactId -> String) -> Maybe ContactId -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"no item" ContactId -> String
forall a. Show a => a -> String
show Maybe ContactId
itemId]
  CRChatItemUpdated User
u (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat ChatItem c d
item) -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u ChatInfo c
chat ChatItem c d
item ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
forall (d :: MsgDirection) (c :: ChatType).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewItemUpdate ChatInfo c
chat ChatItem c d
item Bool
liveItems UTCTime
ts TimeZone
tz
  CRChatItemNotChanged User
u AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatItem -> [StyledString]
viewItemNotChanged AChatItem
ci
  CRTagsUpdated User
u [ChatTag]
_ [ContactId]
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"chat tags updated"]
  CRChatItemsDeleted User
u [ChatItemDeletion]
deletions Bool
byUser Bool
timed -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (forall (c :: ChatType) (d :: MsgDirection).
 ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString])
-> [ChatItemDeletion]
-> Bool
-> Bool
-> UTCTime
-> TimeZone
-> Bool
-> [StyledString]
viewChatItemsDeleted (User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u) [ChatItemDeletion]
deletions Bool
byUser Bool
timed UTCTime
ts TimeZone
tz Bool
testView
  CRGroupChatItemsDeleted User
u GroupInfo
g [ContactId]
ciIds Bool
byUser Maybe GroupMember
member_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo
-> [ContactId] -> Bool -> Maybe GroupMember -> [StyledString]
viewGroupChatItemsDeleted GroupInfo
g [ContactId]
ciIds Bool
byUser Maybe GroupMember
member_
  CRChatItemReaction User
u Bool
added (ACIReaction SChatType c
_ SMsgDirection d
_ ChatInfo c
chat CIReaction c d
reaction) -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User
-> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
unmutedReaction User
u ChatInfo c
chat CIReaction c d
reaction ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Bool
-> ChatInfo c
-> CIReaction c d
-> Bool
-> UTCTime
-> TimeZone
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
Bool
-> ChatInfo c
-> CIReaction c d
-> Bool
-> UTCTime
-> TimeZone
-> [StyledString]
viewItemReaction Bool
showReactions ChatInfo c
chat CIReaction c d
reaction Bool
added UTCTime
ts TimeZone
tz
  CRReactionMembers User
u [MemberReaction]
memberReactions -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [MemberReaction] -> [StyledString]
viewReactionMembers [MemberReaction]
memberReactions
  CRBroadcastSent User
u MsgContent
mc Int
s Int
f UTCTime
t -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ MsgContent
-> Int -> Int -> UTCTime -> TimeZone -> UTCTime -> [StyledString]
viewSentBroadcast MsgContent
mc Int
s Int
f UTCTime
ts TimeZone
tz UTCTime
t
  CRCmdOk Maybe User
u_ -> Maybe User -> [StyledString] -> [StyledString]
ttyUser' Maybe User
u_ [StyledString
"ok"]
  CRChatHelp HelpSection
section -> case HelpSection
section of
    HelpSection
HSMain -> [StyledString]
chatHelpInfo
    HelpSection
HSFiles -> [StyledString]
filesHelpInfo
    HelpSection
HSGroups -> [StyledString]
groupsHelpInfo
    HelpSection
HSContacts -> [StyledString]
contactsHelpInfo
    HelpSection
HSMyAddress -> [StyledString]
myAddressHelpInfo
    HelpSection
HSIncognito -> [StyledString]
incognitoHelpInfo
    HelpSection
HSMessages -> [StyledString]
messagesHelpInfo
    HelpSection
HSMarkdown -> [StyledString]
markdownInfo
    HelpSection
HSRemote -> [StyledString]
remoteHelpInfo
    HelpSection
HSSettings -> [StyledString]
settingsInfo
    HelpSection
HSDatabase -> [StyledString]
databaseHelpInfo
  CRWelcome User
user -> User -> [StyledString]
chatWelcome User
user
  CRContactsList User
u [Contact]
cs -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [Contact] -> [StyledString]
viewContactsList [Contact]
cs
  CRUserContactLink User
u UserContactLink {CreatedLinkContact
connLinkContact :: CreatedLinkContact
connLinkContact :: UserContactLink -> CreatedLinkContact
connLinkContact, AddressSettings
addressSettings :: AddressSettings
addressSettings :: UserContactLink -> AddressSettings
addressSettings} -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> CreatedLinkContact -> [StyledString]
connReqContact_ StyledString
"Your chat address:" CreatedLinkContact
connLinkContact [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> AddressSettings -> [StyledString]
viewAddressSettings AddressSettings
addressSettings
  CRUserContactLinkUpdated User
u UserContactLink {AddressSettings
addressSettings :: UserContactLink -> AddressSettings
addressSettings :: AddressSettings
addressSettings} -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AddressSettings -> [StyledString]
viewAddressSettings AddressSettings
addressSettings
  CRContactRequestRejected User
u UserContactRequest {localDisplayName :: UserContactRequest -> ContactName
localDisplayName = ContactName
c} Maybe Contact
_ct_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": contact request rejected"]
  CRGroupCreated User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> Bool -> [StyledString]
viewGroupCreated GroupInfo
g Bool
testView
  CRGroupMembers User
u Group
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Group -> [StyledString]
viewGroupMembers Group
g
  CRMemberSupportChats User
u GroupInfo
g [GroupMember]
ms -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [GroupMember] -> [StyledString]
viewMemberSupportChats GroupInfo
g [GroupMember]
ms
  -- CRGroupConversationsArchived u _g _conversations -> ttyUser u []
  -- CRGroupConversationsDeleted u _g _conversations -> ttyUser u []
  CRGroupsList User
u [GroupInfo]
gs -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [GroupInfo] -> [StyledString]
viewGroupsList [GroupInfo]
gs
  CRSentGroupInvitation User
u GroupInfo
g Contact
c GroupMember
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> Contact -> [StyledString]
viewSentGroupInvitation GroupInfo
g Contact
c
  CRFileTransferStatus User
u (FileTransfer, [Integer])
ftStatus -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (FileTransfer, [Integer]) -> [StyledString]
viewFileTransferStatus (FileTransfer, [Integer])
ftStatus
  CRFileTransferStatusXFTP User
u AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatItem -> [StyledString]
viewFileTransferStatusXFTP AChatItem
ci
  CRUserProfile User
u Profile
p -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Profile -> [StyledString]
viewUserProfile Profile
p
  CRUserProfileNoChange User
u -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"user profile did not change"]
  CRUserPrivacy User
u User
u' -> (Maybe ContactId, Maybe User)
-> Maybe ContactId -> User -> [StyledString] -> [StyledString]
ttyUserPrefix (Maybe ContactId, Maybe User)
hu Maybe ContactId
outputRH User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User -> User -> [StyledString]
viewUserPrivacy User
u User
u'
  CRVersionInfo CoreVersionInfo
info [UpMigration]
_ [UpMigration]
_ -> ChatLogLevel -> CoreVersionInfo -> [StyledString]
viewVersionInfo ChatLogLevel
logLevel CoreVersionInfo
info
  CRInvitation User
u CreatedLinkInvitation
ccLink PendingContactConnection
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ CreatedLinkInvitation -> [StyledString]
viewConnReqInvitation CreatedLinkInvitation
ccLink
  CRConnectionIncognitoUpdated User
u PendingContactConnection
c Maybe Profile
customUserProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ PendingContactConnection -> Maybe Profile -> Bool -> [StyledString]
viewConnectionIncognitoUpdated PendingContactConnection
c Maybe Profile
customUserProfile Bool
testView
  CRConnectionUserChanged User
u PendingContactConnection
c PendingContactConnection
c' User
nu -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User
-> PendingContactConnection
-> User
-> PendingContactConnection
-> [StyledString]
viewConnectionUserChanged User
u PendingContactConnection
c User
nu PendingContactConnection
c'
  CRConnectionPlan User
u ACreatedConnLink
connLink ConnectionPlan
connectionPlan -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatConfig -> ACreatedConnLink -> ConnectionPlan -> [StyledString]
viewConnectionPlan ChatConfig
cfg ACreatedConnLink
connLink ConnectionPlan
connectionPlan
  CRNewPreparedChat User
u (AChat SChatType c
_ (Chat ChatInfo c
cInfo [CChatItem c]
_ ChatStats
_)) -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ case ChatInfo c
cInfo of
    DirectChat Contact
ct -> [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": contact is prepared"]
    GroupChat GroupInfo
g Maybe GroupChatScopeInfo
_ -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": group is prepared"]
    ChatInfo c
_ -> [StyledString
"prepared chat error: unexpected type"]
  CRContactUserChanged User
u Contact
c User
nu Contact
c' -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User -> Contact -> User -> Contact -> [StyledString]
viewContactUserChanged User
u Contact
c User
nu Contact
c'
  CRGroupUserChanged User
u GroupInfo
g User
nu GroupInfo
g' -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User -> GroupInfo -> User -> GroupInfo -> [StyledString]
viewGroupUserChanged User
u GroupInfo
g User
nu GroupInfo
g'
  CRSentConfirmation User
u PendingContactConnection
_ Maybe Profile
_customUserProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"confirmation sent!"]
  CRSentInvitation User
u PendingContactConnection
_ Maybe Profile
customUserProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Maybe Profile -> Bool -> [StyledString]
viewSentInvitation Maybe Profile
customUserProfile Bool
testView
  CRStartedConnectionToContact User
u Contact
c Maybe Profile
customUserProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> Maybe Profile -> Bool -> [StyledString]
viewStartedConnectionToContact Contact
c Maybe Profile
customUserProfile Bool
testView
  CRStartedConnectionToGroup User
u GroupInfo
g Maybe Profile
customUserProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> Maybe Profile -> Bool -> [StyledString]
viewStartedConnectionToGroup GroupInfo
g Maybe Profile
customUserProfile Bool
testView
  CRSentInvitationToContact User
u Contact
_c Maybe Profile
customUserProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Maybe Profile -> Bool -> [StyledString]
viewSentInvitation Maybe Profile
customUserProfile Bool
testView
  CRItemsReadForChat User
u AChatInfo
_chatId -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"items read for chat"]
  CRContactDeleted User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u [Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": contact is deleted"]
  CRChatCleared User
u AChatInfo
chatInfo -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatInfo -> [StyledString]
viewChatCleared AChatInfo
chatInfo
  CRAcceptingContactRequest User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> [StyledString]
viewAcceptingContactRequest Contact
c
  CRContactAlreadyExists User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u [Contact -> StyledString
ttyFullContact Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": contact already exists"]
  CRUserContactLinkCreated User
u CreatedLinkContact
ccLink -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> CreatedLinkContact -> [StyledString]
connReqContact_ StyledString
"Your new chat address is created!" CreatedLinkContact
ccLink
  CRUserContactLinkDeleted User
u -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString]
viewUserContactLinkDeleted
  CRUserAcceptedGroupSent User
u GroupInfo
_g Maybe Contact
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [] -- [ttyGroup' g <> ": joining the group..."]
  CRUserDeletedMembers User
u GroupInfo
g [GroupMember]
members Bool
wm -> case [GroupMember]
members of
    [GroupMember
m] -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you removed " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" from the group" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Bool -> StyledString
forall {a}. IsString a => Bool -> a
withMessages Bool
wm]
    [GroupMember]
mems' -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you removed " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([GroupMember] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [GroupMember]
mems') StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" members from the group" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Bool -> StyledString
forall {a}. IsString a => Bool -> a
withMessages Bool
wm]
  CRLeftMemberUser User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you left the group"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> [StyledString]
groupPreserved GroupInfo
g
  CRGroupDeletedUser User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you deleted the group"]
  CRForwardPlan User
u Int
count [ContactId]
itemIds Maybe ForwardConfirmation
fc -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Int -> [ContactId] -> Maybe ForwardConfirmation -> [StyledString]
viewForwardPlan Int
count [ContactId]
itemIds Maybe ForwardConfirmation
fc
  CRRcvFileAccepted User
u AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatItem -> [StyledString]
savingFile' AChatItem
ci
  CRRcvFileAcceptedSndCancelled User
u RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ RcvFileTransfer -> [StyledString]
viewRcvFileSndCancelled RcvFileTransfer
ft
  CRSndFileCancelled User
u Maybe AChatItem
_ FileTransferMeta
ftm [SndFileTransfer]
fts -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ FileTransferMeta -> [SndFileTransfer] -> [StyledString]
viewSndFileCancelled FileTransferMeta
ftm [SndFileTransfer]
fts
  CRRcvFileCancelled User
u Maybe AChatItem
_ RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> RcvFileTransfer -> [StyledString]
receivingFile_ StyledString
"cancelled" RcvFileTransfer
ft
  CRUserProfileUpdated User
u Profile
p Profile
p' UserProfileUpdateSummary
summary -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Profile -> Profile -> UserProfileUpdateSummary -> [StyledString]
viewUserProfileUpdated Profile
p Profile
p' UserProfileUpdateSummary
summary
  CRUserProfileImage User
u Profile
p -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Profile -> [StyledString]
viewUserProfileImage Profile
p
  CRContactPrefsUpdated {user :: ChatResponse -> User
user = User
u, Contact
fromContact :: Contact
fromContact :: ChatResponse -> Contact
fromContact, Contact
toContact :: Contact
toContact :: ChatResponse -> Contact
toContact} -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User -> Contact -> Contact -> [StyledString]
viewUserContactPrefsUpdated User
u Contact
fromContact Contact
toContact
  CRContactAliasUpdated User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> [StyledString]
viewContactAliasUpdated Contact
c
  CRGroupAliasUpdated User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [StyledString]
viewGroupAliasUpdated GroupInfo
g
  CRConnectionAliasUpdated User
u PendingContactConnection
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ PendingContactConnection -> [StyledString]
viewConnectionAliasUpdated PendingContactConnection
c
  CRRcvStandaloneFileCreated User
u RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ String -> RcvFileTransfer -> [StyledString]
receivingFileStandalone String
"started" RcvFileTransfer
ft
  CRSndStandaloneFileCreated User
u FileTransferMeta
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> FileTransferMeta -> [StyledString]
uploadingFileStandalone StyledString
"started" FileTransferMeta
ft
  CRStandaloneFileInfo Maybe Value
info_ -> [StyledString]
-> (Value -> [StyledString]) -> Maybe Value -> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString
"no file information in URI"] (\Value
j -> [Value -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON Value
j]) Maybe Value
info_
  CRJoinedGroupMember User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> [StyledString]
viewJoinedGroupMember GroupInfo
g GroupMember
m
  CRMemberAccepted User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> [StyledString]
viewMemberAccepted GroupInfo
g GroupMember
m
  CRMemberSupportChatRead User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> [StyledString]
viewSupportChatRead GroupInfo
g GroupMember
m
  CRMemberSupportChatDeleted User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" support chat deleted"]
  CRMembersRoleUser User
u GroupInfo
g [GroupMember]
members GroupMemberRole
r' -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [GroupMember] -> GroupMemberRole -> [StyledString]
viewMemberRoleUserChanged GroupInfo
g [GroupMember]
members GroupMemberRole
r'
  CRMembersBlockedForAllUser User
u GroupInfo
g [GroupMember]
members Bool
blocked -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [GroupMember] -> Bool -> [StyledString]
viewMembersBlockedForAllUser GroupInfo
g [GroupMember]
members Bool
blocked
  CRGroupUpdated User
u GroupInfo
g GroupInfo
g' Maybe GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupInfo -> Maybe GroupMember -> [StyledString]
viewGroupUpdated GroupInfo
g GroupInfo
g' Maybe GroupMember
m
  CRGroupProfile User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [StyledString]
viewGroupProfile GroupInfo
g
  CRGroupDescription User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [StyledString]
viewGroupDescription GroupInfo
g
  CRGroupLinkCreated User
u GroupInfo
g GroupLink
gLink -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> GroupInfo -> GroupLink -> [StyledString]
groupLink_ StyledString
"Group link is created!" GroupInfo
g GroupLink
gLink
  CRGroupLink User
u GroupInfo
g GroupLink
gLink -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> GroupInfo -> GroupLink -> [StyledString]
groupLink_ StyledString
"Group link:" GroupInfo
g GroupLink
gLink
  CRGroupLinkDeleted User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [StyledString]
viewGroupLinkDeleted GroupInfo
g
  CRNewMemberContact User
u Contact
_ GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"contact for member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is created"]
  CRNewMemberContactSentInv User
u Contact
_ct GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"sent invitation to connect directly to member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m]
  CRMemberContactAccepted User
u Contact
ct -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is accepted, starting connection"]
  CRCallInvitations [RcvCallInvitation]
_ -> []
  CRContactConnectionDeleted User
u PendingContactConnection {ContactId
pccConnId :: ContactId
pccConnId :: PendingContactConnection -> ContactId
pccConnId} -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"connection :" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
pccConnId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" deleted"]
  CRNtfTokenStatus NtfTknStatus
status -> [StyledString
"device token status: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (NtfTknStatus -> ByteString
forall a. Encoding a => a -> ByteString
smpEncode NtfTknStatus
status)]
  CRNtfToken DeviceToken
_ NtfTknStatus
status NotificationsMode
mode NtfServer
srv -> [StyledString
"device token status: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (NtfTknStatus -> ByteString
forall a. Encoding a => a -> ByteString
smpEncode NtfTknStatus
status) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", notifications mode: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (NotificationsMode -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode NotificationsMode
mode) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", server: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> NtfServer -> StyledString
forall a. Show a => a -> StyledString
sShow NtfServer
srv]
  CRNtfConns {[NtfConn]
ntfConns :: [NtfConn]
ntfConns :: ChatResponse -> [NtfConn]
ntfConns} -> (NtfConn -> StyledString) -> [NtfConn] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (\NtfConn {AgentConnId
agentConnId :: AgentConnId
agentConnId :: NtfConn -> AgentConnId
agentConnId, Maybe NtfMsgInfo
expectedMsg_ :: Maybe NtfMsgInfo
expectedMsg_ :: NtfConn -> Maybe NtfMsgInfo
expectedMsg_} -> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ AgentConnId -> String
forall a. Show a => a -> String
show AgentConnId
agentConnId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Maybe NtfMsgInfo -> String
forall a. Show a => a -> String
show Maybe NtfMsgInfo
expectedMsg_) [NtfConn]
ntfConns
  CRConnNtfMessages NonEmpty RcvNtfMsgInfo
ntfMsgs -> [NonEmpty RcvNtfMsgInfo -> StyledString
forall a. Show a => a -> StyledString
sShow NonEmpty RcvNtfMsgInfo
ntfMsgs]
  CRCurrentRemoteHost Maybe RemoteHostInfo
rhi_ ->
    [ StyledString
-> (RemoteHostInfo -> StyledString)
-> Maybe RemoteHostInfo
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
        StyledString
"Using local profile"
        (\RemoteHostInfo {remoteHostId :: RemoteHostInfo -> ContactId
remoteHostId = ContactId
rhId, ContactName
hostDeviceName :: ContactName
hostDeviceName :: RemoteHostInfo -> ContactName
hostDeviceName} -> StyledString
"Using remote host " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rhId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
hostDeviceName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")")
        Maybe RemoteHostInfo
rhi_
    ]
  CRRemoteHostList [RemoteHostInfo]
hs -> [RemoteHostInfo] -> [StyledString]
viewRemoteHosts [RemoteHostInfo]
hs
  CRRemoteHostStarted {Maybe RemoteHostInfo
remoteHost_ :: Maybe RemoteHostInfo
remoteHost_ :: ChatResponse -> Maybe RemoteHostInfo
remoteHost_, ContactName
invitation :: ContactName
invitation :: ChatResponse -> ContactName
invitation, localAddrs :: ChatResponse -> NonEmpty RCCtrlAddress
localAddrs = RCCtrlAddress {TransportHost
address :: TransportHost
address :: RCCtrlAddress -> TransportHost
address} :| [RCCtrlAddress]
addrs, String
ctrlPort :: String
ctrlPort :: ChatResponse -> String
ctrlPort} ->
    [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
-> (RemoteHostInfo -> String) -> Maybe RemoteHostInfo -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String
"new remote host" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
started) (\RemoteHostInfo {remoteHostId :: RemoteHostInfo -> ContactId
remoteHostId = ContactId
rhId} -> String
"remote host " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
rhId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
started) Maybe RemoteHostInfo
remoteHost_]
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"other addresses: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
" " ((RCCtrlAddress -> String) -> [RCCtrlAddress] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (\RCCtrlAddress {address :: RCCtrlAddress -> TransportHost
address = TransportHost
a} -> ByteString -> String
B.unpack (TransportHost -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode TransportHost
a)) [RCCtrlAddress]
addrs) | Bool -> Bool
not ([RCCtrlAddress] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [RCCtrlAddress]
addrs)]
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"Remote session invitation:", ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
invitation]
    where
      started :: String
started = String
" started on " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ByteString -> String
B.unpack (TransportHost -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode TransportHost
address) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
":" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
ctrlPort
  CRRemoteFileStored ContactId
rhId (CryptoFile String
filePath Maybe CryptoFileArgs
cfArgs_) ->
    [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"file " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
filePath String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" stored on remote host " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
rhId]
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (CryptoFileArgs -> [StyledString])
-> Maybe CryptoFileArgs
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: []) (StyledString -> [StyledString])
-> (CryptoFileArgs -> StyledString)
-> CryptoFileArgs
-> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> CryptoFileArgs -> StyledString
cryptoFileArgsStr Bool
testView) Maybe CryptoFileArgs
cfArgs_
  CRRemoteCtrlList [RemoteCtrlInfo]
cs -> [RemoteCtrlInfo] -> [StyledString]
viewRemoteCtrls [RemoteCtrlInfo]
cs
  CRRemoteCtrlConnecting {Maybe RemoteCtrlInfo
remoteCtrl_ :: Maybe RemoteCtrlInfo
remoteCtrl_ :: ChatResponse -> Maybe RemoteCtrlInfo
remoteCtrl_, CtrlAppInfo
ctrlAppInfo :: CtrlAppInfo
ctrlAppInfo :: ChatResponse -> CtrlAppInfo
ctrlAppInfo, AppVersion
appVersion :: AppVersion
appVersion :: ChatResponse -> AppVersion
appVersion} ->
    [ (StyledString
-> (RemoteCtrlInfo -> StyledString)
-> Maybe RemoteCtrlInfo
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"connecting new remote controller" (\RemoteCtrlInfo {ContactId
remoteCtrlId :: ContactId
remoteCtrlId :: RemoteCtrlInfo -> ContactId
remoteCtrlId} -> StyledString
"connecting remote controller " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
remoteCtrlId) Maybe RemoteCtrlInfo
remoteCtrl_ StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": ")
        StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CtrlAppInfo -> AppVersion -> Bool -> StyledString
viewRemoteCtrl CtrlAppInfo
ctrlAppInfo AppVersion
appVersion Bool
True
    ]
  CRRemoteCtrlConnected RemoteCtrlInfo {remoteCtrlId :: RemoteCtrlInfo -> ContactId
remoteCtrlId = ContactId
rcId, ContactName
ctrlDeviceName :: ContactName
ctrlDeviceName :: RemoteCtrlInfo -> ContactName
ctrlDeviceName} ->
    [StyledString
"remote controller " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rcId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" session started with " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
ctrlDeviceName]
  CRSQLResult [ContactName]
rows -> (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain [ContactName]
rows
#if !defined(dbPostgres)
  CRArchiveExported [ArchiveError]
archiveErrs -> if [ArchiveError] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ArchiveError]
archiveErrs then [StyledString
"ok"] else [StyledString
"archive export errors: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ArchiveError] -> String
forall a. Show a => a -> String
show [ArchiveError]
archiveErrs)]
  CRArchiveImported [ArchiveError]
archiveErrs -> if [ArchiveError] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ArchiveError]
archiveErrs then [StyledString
"ok"] else [StyledString
"archive import errors: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ArchiveError] -> String
forall a. Show a => a -> String
show [ArchiveError]
archiveErrs)]
  CRSlowSQLQueries {[SlowSQLQuery]
chatQueries :: [SlowSQLQuery]
chatQueries :: ChatResponse -> [SlowSQLQuery]
chatQueries, [SlowSQLQuery]
agentQueries :: [SlowSQLQuery]
agentQueries :: ChatResponse -> [SlowSQLQuery]
agentQueries} ->
    let viewQuery :: SlowSQLQuery -> StyledString
viewQuery SlowSQLQuery {ContactName
query :: ContactName
query :: SlowSQLQuery -> ContactName
query, queryStats :: SlowSQLQuery -> SlowQueryStats
queryStats = SlowQueryStats {ContactId
count :: ContactId
count :: SlowQueryStats -> ContactId
count, ContactId
timeMax :: ContactId
timeMax :: SlowQueryStats -> ContactId
timeMax, ContactId
timeAvg :: ContactId
timeAvg :: SlowQueryStats -> ContactId
timeAvg}} =
          (StyledString
"count: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
count)
            StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
" :: max: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
timeMax StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ms")
            StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
" :: avg: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
timeAvg StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ms")
            StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
" :: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ContactName] -> ContactName
T.unwords ([ContactName] -> ContactName) -> [ContactName] -> ContactName
forall a b. (a -> b) -> a -> b
$ ContactName -> [ContactName]
T.lines ContactName
query))
     in (StyledString
"Chat queries" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (SlowSQLQuery -> StyledString) -> [SlowSQLQuery] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map SlowSQLQuery -> StyledString
viewQuery [SlowSQLQuery]
chatQueries) [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
""] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (StyledString
"Agent queries" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (SlowSQLQuery -> StyledString) -> [SlowSQLQuery] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map SlowSQLQuery -> StyledString
viewQuery [SlowSQLQuery]
agentQueries)
#endif
  CRDebugLocks {Maybe ContactName
chatLockName :: Maybe ContactName
chatLockName :: ChatResponse -> Maybe ContactName
chatLockName, Map ContactName ContactName
chatEntityLocks :: Map ContactName ContactName
chatEntityLocks :: ChatResponse -> Map ContactName ContactName
chatEntityLocks, AgentLocks
agentLocks :: AgentLocks
agentLocks :: ChatResponse -> AgentLocks
agentLocks} ->
    [ StyledString
-> (ContactName -> StyledString)
-> Maybe ContactName
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"no chat lock" ((StyledString
"chat lock: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>) (StyledString -> StyledString)
-> (ContactName -> StyledString) -> ContactName -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain) Maybe ContactName
chatLockName,
      StyledString
"chat entity locks: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Map ContactName ContactName -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON Map ContactName ContactName
chatEntityLocks,
      StyledString
"agent locks: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentLocks -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON AgentLocks
agentLocks
    ]
  CRAgentSubsTotal User
u SMPServerSubs
subsTotal Bool
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"total subscriptions: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SMPServerSubs -> StyledString
forall a. Show a => a -> StyledString
sShow SMPServerSubs
subsTotal]
  CRAgentServersSummary User
u PresentedServersSummary
serversSummary -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"agent servers summary: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> PresentedServersSummary -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON PresentedServersSummary
serversSummary]
  CRAgentSubs {Map ContactName Int
activeSubs :: Map ContactName Int
activeSubs :: ChatResponse -> Map ContactName Int
activeSubs, Map ContactName Int
pendingSubs :: Map ContactName Int
pendingSubs :: ChatResponse -> Map ContactName Int
pendingSubs, Map ContactName [String]
removedSubs :: Map ContactName [String]
removedSubs :: ChatResponse -> Map ContactName [String]
removedSubs} ->
    [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"Subscriptions: active = " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Map ContactName Int -> Int
forall a. Num a => Map ContactName a -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum Map ContactName Int
activeSubs) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
", pending = " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Map ContactName Int -> Int
forall a. Num a => Map ContactName a -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum Map ContactName Int
pendingSubs) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
", removed = " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show (Map ContactName Int -> Int
forall a. Num a => Map ContactName a -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (Map ContactName Int -> Int) -> Map ContactName Int -> Int
forall a b. (a -> b) -> a -> b
$ ([String] -> Int)
-> Map ContactName [String] -> Map ContactName Int
forall a b k. (a -> b) -> Map k a -> Map k b
M.map [String] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length Map ContactName [String]
removedSubs)]
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (StyledString
"active subscriptions:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: Map ContactName Int -> [StyledString]
forall a. Show a => Map ContactName a -> [StyledString]
listSubs Map ContactName Int
activeSubs)
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (StyledString
"pending subscriptions:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: Map ContactName Int -> [StyledString]
forall a. Show a => Map ContactName a -> [StyledString]
listSubs Map ContactName Int
pendingSubs)
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (StyledString
"removed subscriptions:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: Map ContactName [String] -> [StyledString]
forall a. Show a => Map ContactName a -> [StyledString]
listSubs Map ContactName [String]
removedSubs)
    where
      listSubs :: Show a => Map Text a -> [StyledString]
      listSubs :: forall a. Show a => Map ContactName a -> [StyledString]
listSubs = ((ContactName, a) -> StyledString)
-> [(ContactName, a)] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (\(ContactName
srv, a
info) -> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
srv ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
": " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> a -> ContactName
forall a. Show a => a -> ContactName
tshow a
info) ([(ContactName, a)] -> [StyledString])
-> (Map ContactName a -> [(ContactName, a)])
-> Map ContactName a
-> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map ContactName a -> [(ContactName, a)]
forall k a. Map k a -> [(k, a)]
M.assocs
  CRAgentSubsDetails SubscriptionsInfo {[SubInfo]
activeSubscriptions :: [SubInfo]
activeSubscriptions :: SubscriptionsInfo -> [SubInfo]
activeSubscriptions, [SubInfo]
pendingSubscriptions :: [SubInfo]
pendingSubscriptions :: SubscriptionsInfo -> [SubInfo]
pendingSubscriptions, [SubInfo]
removedSubscriptions :: [SubInfo]
removedSubscriptions :: SubscriptionsInfo -> [SubInfo]
removedSubscriptions} ->
    (StyledString
"active subscriptions:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (SubInfo -> StyledString) -> [SubInfo] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map SubInfo -> StyledString
forall a. Show a => a -> StyledString
sShow [SubInfo]
activeSubscriptions)
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (StyledString
"pending subscriptions: " StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (SubInfo -> StyledString) -> [SubInfo] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map SubInfo -> StyledString
forall a. Show a => a -> StyledString
sShow [SubInfo]
pendingSubscriptions)
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (StyledString
"removed subscriptions: " StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (SubInfo -> StyledString) -> [SubInfo] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map SubInfo -> StyledString
forall a. Show a => a -> StyledString
sShow [SubInfo]
removedSubscriptions)
  CRAgentWorkersSummary {AgentWorkersSummary
agentWorkersSummary :: AgentWorkersSummary
agentWorkersSummary :: ChatResponse -> AgentWorkersSummary
agentWorkersSummary} -> [StyledString
"agent workers summary: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentWorkersSummary -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON AgentWorkersSummary
agentWorkersSummary]
  CRAgentWorkersDetails {AgentWorkersDetails
agentWorkersDetails :: AgentWorkersDetails
agentWorkersDetails :: ChatResponse -> AgentWorkersDetails
agentWorkersDetails} ->
    [ StyledString
"agent workers details:",
      AgentWorkersDetails -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON AgentWorkersDetails
agentWorkersDetails -- this would be huge, but copypastable when has its own line
    ]
  CRAgentQueuesInfo {AgentQueuesInfo
agentQueuesInfo :: AgentQueuesInfo
agentQueuesInfo :: ChatResponse -> AgentQueuesInfo
agentQueuesInfo} ->
    [ StyledString
"agent queues info:",
      String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString)
-> (ByteString -> String) -> ByteString -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> String
LB.unpack (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ AgentQueuesInfo -> ByteString
forall a. ToJSON a => a -> ByteString
J.encode AgentQueuesInfo
agentQueuesInfo
    ]
  CRAppSettings AppSettings
as -> [StyledString
"app settings: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AppSettings -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON AppSettings
as]
  CRCustomChatResponse Maybe User
u ContactName
r -> Maybe User -> [StyledString] -> [StyledString]
ttyUser' Maybe User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ContactName] -> [StyledString])
-> [ContactName] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ContactName -> [ContactName]
T.lines ContactName
r
  where
    ttyUser :: User -> [StyledString] -> [StyledString]
    ttyUser :: User -> [StyledString] -> [StyledString]
ttyUser user :: User
user@User {Bool
showNtfs :: Bool
showNtfs :: User -> Bool
showNtfs, Bool
activeUser :: Bool
activeUser :: User -> Bool
activeUser, Maybe UserPwdHash
viewPwdHash :: Maybe UserPwdHash
viewPwdHash :: User -> Maybe UserPwdHash
viewPwdHash} [StyledString]
ss
      | (Bool
showNtfs Bool -> Bool -> Bool
&& Maybe UserPwdHash -> Bool
forall a. Maybe a -> Bool
isNothing Maybe UserPwdHash
viewPwdHash) Bool -> Bool -> Bool
|| Bool
activeUser = (Maybe ContactId, Maybe User)
-> Maybe ContactId -> User -> [StyledString] -> [StyledString]
ttyUserPrefix (Maybe ContactId, Maybe User)
hu Maybe ContactId
outputRH User
user [StyledString]
ss
      | Bool
otherwise = []
    ttyUser' :: Maybe User -> [StyledString] -> [StyledString]
    ttyUser' :: Maybe User -> [StyledString] -> [StyledString]
ttyUser' = ([StyledString] -> [StyledString])
-> (User -> [StyledString] -> [StyledString])
-> Maybe User
-> [StyledString]
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString] -> [StyledString]
forall a. a -> a
id User -> [StyledString] -> [StyledString]
ttyUser
    testViewChats :: [AChat] -> [StyledString]
    testViewChats :: [AChat] -> [StyledString]
testViewChats [AChat]
chats = [[(ContactName, ContactName, Maybe ConnStatus)] -> StyledString
forall a. Show a => a -> StyledString
sShow ([(ContactName, ContactName, Maybe ConnStatus)] -> StyledString)
-> [(ContactName, ContactName, Maybe ConnStatus)] -> StyledString
forall a b. (a -> b) -> a -> b
$ (AChat -> (ContactName, ContactName, Maybe ConnStatus))
-> [AChat] -> [(ContactName, ContactName, Maybe ConnStatus)]
forall a b. (a -> b) -> [a] -> [b]
map AChat -> (ContactName, ContactName, Maybe ConnStatus)
toChatView [AChat]
chats]
      where
        toChatView :: AChat -> (Text, Text, Maybe ConnStatus)
        toChatView :: AChat -> (ContactName, ContactName, Maybe ConnStatus)
toChatView (AChat SChatType c
_ (Chat ChatInfo c
cInfo [CChatItem c]
items ChatStats
_)) = case ChatInfo c
cInfo of
          DirectChat Contact {ContactName
localDisplayName :: ContactName
localDisplayName :: Contact -> ContactName
localDisplayName, Maybe Connection
activeConn :: Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn} -> (ContactName
"@" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
localDisplayName, [CChatItem c] -> Maybe GroupMember -> ContactName
forall (c :: ChatType).
[CChatItem c] -> Maybe GroupMember -> ContactName
toCIPreview [CChatItem c]
items Maybe GroupMember
forall a. Maybe a
Nothing, Connection -> ConnStatus
connStatus (Connection -> ConnStatus) -> Maybe Connection -> Maybe ConnStatus
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Connection
activeConn)
          GroupChat GroupInfo {GroupMember
membership :: GroupMember
membership :: GroupInfo -> GroupMember
membership, ContactName
localDisplayName :: ContactName
localDisplayName :: GroupInfo -> ContactName
localDisplayName} Maybe GroupChatScopeInfo
_scopeInfo -> (ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
localDisplayName, [CChatItem c] -> Maybe GroupMember -> ContactName
forall (c :: ChatType).
[CChatItem c] -> Maybe GroupMember -> ContactName
toCIPreview [CChatItem c]
items (GroupMember -> Maybe GroupMember
forall a. a -> Maybe a
Just GroupMember
membership), Maybe ConnStatus
forall a. Maybe a
Nothing)
          LocalChat NoteFolder
_ -> (ContactName
"*", [CChatItem c] -> Maybe GroupMember -> ContactName
forall (c :: ChatType).
[CChatItem c] -> Maybe GroupMember -> ContactName
toCIPreview [CChatItem c]
items Maybe GroupMember
forall a. Maybe a
Nothing, Maybe ConnStatus
forall a. Maybe a
Nothing)
          ContactRequest UserContactRequest {ContactName
localDisplayName :: UserContactRequest -> ContactName
localDisplayName :: ContactName
localDisplayName} -> (ContactName
"<@" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
localDisplayName, [CChatItem c] -> Maybe GroupMember -> ContactName
forall (c :: ChatType).
[CChatItem c] -> Maybe GroupMember -> ContactName
toCIPreview [CChatItem c]
items Maybe GroupMember
forall a. Maybe a
Nothing, Maybe ConnStatus
forall a. Maybe a
Nothing)
          ContactConnection PendingContactConnection {ContactId
pccConnId :: PendingContactConnection -> ContactId
pccConnId :: ContactId
pccConnId, ConnStatus
pccConnStatus :: ConnStatus
pccConnStatus :: PendingContactConnection -> ConnStatus
pccConnStatus} -> (ContactName
":" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> String -> ContactName
T.pack (ContactId -> String
forall a. Show a => a -> String
show ContactId
pccConnId), [CChatItem c] -> Maybe GroupMember -> ContactName
forall (c :: ChatType).
[CChatItem c] -> Maybe GroupMember -> ContactName
toCIPreview [CChatItem c]
items Maybe GroupMember
forall a. Maybe a
Nothing, ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
pccConnStatus)
          CInfoInvalidJSON {} -> (ContactName
"invalid chat info", ContactName
"", Maybe ConnStatus
forall a. Maybe a
Nothing)
        toCIPreview :: [CChatItem c] -> Maybe GroupMember -> Text
        toCIPreview :: forall (c :: ChatType).
[CChatItem c] -> Maybe GroupMember -> ContactName
toCIPreview (CChatItem c
ci : [CChatItem c]
_) Maybe GroupMember
membership_ = CChatItem c -> Maybe GroupMember -> ContactName
forall (c :: ChatType).
CChatItem c -> Maybe GroupMember -> ContactName
testViewItem CChatItem c
ci Maybe GroupMember
membership_
        toCIPreview [CChatItem c]
_ Maybe GroupMember
_ = ContactName
""
    testViewChat :: AChat -> [StyledString]
    testViewChat :: AChat -> [StyledString]
testViewChat (AChat SChatType c
_ Chat {ChatInfo c
chatInfo :: ChatInfo c
chatInfo :: forall (c :: ChatType). Chat c -> ChatInfo c
chatInfo, [CChatItem c]
chatItems :: [CChatItem c]
chatItems :: forall (c :: ChatType). Chat c -> [CChatItem c]
chatItems}) = [[((Int, ContactName), Maybe (Int, ContactName), Maybe String)]
-> StyledString
forall a. Show a => a -> StyledString
sShow ([((Int, ContactName), Maybe (Int, ContactName), Maybe String)]
 -> StyledString)
-> [((Int, ContactName), Maybe (Int, ContactName), Maybe String)]
-> StyledString
forall a b. (a -> b) -> a -> b
$ (CChatItem c
 -> ((Int, ContactName), Maybe (Int, ContactName), Maybe String))
-> [CChatItem c]
-> [((Int, ContactName), Maybe (Int, ContactName), Maybe String)]
forall a b. (a -> b) -> [a] -> [b]
map CChatItem c
-> ((Int, ContactName), Maybe (Int, ContactName), Maybe String)
forall (c :: ChatType).
CChatItem c
-> ((Int, ContactName), Maybe (Int, ContactName), Maybe String)
toChatView [CChatItem c]
chatItems]
      where
        toChatView :: CChatItem c -> ((Int, Text), Maybe (Int, Text), Maybe String)
        toChatView :: forall (c :: ChatType).
CChatItem c
-> ((Int, ContactName), Maybe (Int, ContactName), Maybe String)
toChatView ci :: CChatItem c
ci@(CChatItem SMsgDirection d
dir ChatItem {Maybe (CIQuote c)
quotedItem :: Maybe (CIQuote c)
quotedItem :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIQuote c)
quotedItem, Maybe (CIFile d)
file :: Maybe (CIFile d)
file :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIFile d)
file}) =
          ((MsgDirection -> Int
msgDirectionInt (MsgDirection -> Int) -> MsgDirection -> Int
forall a b. (a -> b) -> a -> b
$ SMsgDirection d -> MsgDirection
forall (d :: MsgDirection). SMsgDirection d -> MsgDirection
toMsgDirection SMsgDirection d
dir, CChatItem c -> Maybe GroupMember -> ContactName
forall (c :: ChatType).
CChatItem c -> Maybe GroupMember -> ContactName
testViewItem CChatItem c
ci (ChatInfo c -> Maybe GroupMember
forall (c :: ChatType). ChatInfo c -> Maybe GroupMember
chatInfoMembership ChatInfo c
chatInfo)), Maybe (Int, ContactName)
qItem, Maybe String
fPath)
          where
            qItem :: Maybe (Int, ContactName)
qItem = case Maybe (CIQuote c)
quotedItem of
              Maybe (CIQuote c)
Nothing -> Maybe (Int, ContactName)
forall a. Maybe a
Nothing
              Just CIQuote {chatDir :: forall (c :: ChatType). CIQuote c -> CIQDirection c
chatDir = CIQDirection c
quoteDir, MsgContent
content :: MsgContent
content :: forall (c :: ChatType). CIQuote c -> MsgContent
content} ->
                (Int, ContactName) -> Maybe (Int, ContactName)
forall a. a -> Maybe a
Just (MsgDirection -> Int
msgDirectionInt (MsgDirection -> Int) -> MsgDirection -> Int
forall a b. (a -> b) -> a -> b
$ CIQDirection c -> MsgDirection
forall (c :: ChatType). CIQDirection c -> MsgDirection
quoteMsgDirection CIQDirection c
quoteDir, MsgContent -> ContactName
msgContentText MsgContent
content)
            fPath :: Maybe String
fPath = case Maybe (CIFile d)
file of
              Just CIFile {fileSource :: forall (d :: MsgDirection). CIFile d -> Maybe CryptoFile
fileSource = Just (CryptoFile String
fp Maybe CryptoFileArgs
_)} -> String -> Maybe String
forall a. a -> Maybe a
Just String
fp
              Maybe (CIFile d)
_ -> Maybe String
forall a. Maybe a
Nothing
    testViewItem :: CChatItem c -> Maybe GroupMember -> Text
    testViewItem :: forall (c :: ChatType).
CChatItem c -> Maybe GroupMember -> ContactName
testViewItem (CChatItem SMsgDirection d
_ ci :: ChatItem c d
ci@ChatItem {meta :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIMeta c d
meta = CIMeta {ContactName
itemText :: ContactName
itemText :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> ContactName
itemText}}) Maybe GroupMember
membership_ =
      let deleted_ :: ContactName
deleted_ = ContactName
-> (ContactName -> ContactName) -> Maybe ContactName -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (\ContactName
t -> ContactName
" [" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
t ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"]") (ChatItem c d -> Maybe GroupMember -> Maybe ContactName
forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe GroupMember -> Maybe ContactName
chatItemDeletedText ChatItem c d
ci Maybe GroupMember
membership_)
       in ContactName
itemText ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
deleted_
    unmuted :: User -> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
    unmuted :: forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u ChatInfo c
chat ci :: ChatItem c d
ci@ChatItem {CIDirection c d
chatDir :: CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir} = User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
unmuted' User
u ChatInfo c
chat CIDirection c d
chatDir (Bool -> [StyledString] -> [StyledString])
-> Bool -> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatItem c d -> Bool
forall (c :: ChatType) (d :: MsgDirection). ChatItem c d -> Bool
isUserMention ChatItem c d
ci
    unmutedReaction :: User -> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
    unmutedReaction :: forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
unmutedReaction User
u ChatInfo c
chat CIReaction {CIDirection c d
chatDir :: CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
CIReaction c d -> CIDirection c d
chatDir} = User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
unmuted' User
u ChatInfo c
chat CIDirection c d
chatDir Bool
False
    unmuted' :: User -> ChatInfo c -> CIDirection c d -> Bool -> [StyledString] -> [StyledString]
    unmuted' :: forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
unmuted' User
u ChatInfo c
chat CIDirection c d
chatDir Bool
mention [StyledString]
s
      | User -> ChatInfo c -> CIDirection c d -> Bool -> Bool
forall (c :: ChatType) (d :: MsgDirection).
User -> ChatInfo c -> CIDirection c d -> Bool -> Bool
chatDirNtf User
u ChatInfo c
chat CIDirection c d
chatDir Bool
mention = [StyledString]
s
      | Bool
testView = (StyledString -> StyledString) -> [StyledString] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" <muted>") [StyledString]
s
      | Bool
otherwise = []
    withMessages :: Bool -> a
withMessages Bool
wm = if Bool
wm then a
" with all messages" else a
""

ttyUserPrefix :: (Maybe RemoteHostId, Maybe User) -> Maybe RemoteHostId -> User -> [StyledString] -> [StyledString]
ttyUserPrefix :: (Maybe ContactId, Maybe User)
-> Maybe ContactId -> User -> [StyledString] -> [StyledString]
ttyUserPrefix (Maybe ContactId, Maybe User)
_ Maybe ContactId
_ User
_ [] = []
ttyUserPrefix (Maybe ContactId
currentRH, Maybe User
user_) Maybe ContactId
outputRH User {ContactId
userId :: ContactId
userId :: User -> ContactId
userId, localDisplayName :: User -> ContactName
localDisplayName = ContactName
u} [StyledString]
ss
  | [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
prefix = [StyledString]
ss
  | Bool
otherwise = StyledString -> [StyledString] -> [StyledString]
prependFirst (StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [StyledString] -> StyledString
forall a. Monoid a => [a] -> a
mconcat [StyledString]
prefix StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] ") [StyledString]
ss
  where
    prefix :: [StyledString]
prefix = StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
intersperse StyledString
", " ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [StyledString]
remotePrefix [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
userPrefix
    remotePrefix :: [StyledString]
remotePrefix = [StyledString
-> (ContactId -> StyledString) -> Maybe ContactId -> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"local" ((StyledString
"remote: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>) (StyledString -> StyledString)
-> (ContactId -> StyledString) -> ContactId -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String -> StyledString)
-> (ContactId -> String) -> ContactId -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactId -> String
forall a. Show a => a -> String
show) Maybe ContactId
outputRH | Maybe ContactId
outputRH Maybe ContactId -> Maybe ContactId -> Bool
forall a. Eq a => a -> a -> Bool
/= Maybe ContactId
currentRH]
    userPrefix :: [StyledString]
userPrefix = [StyledString
"user: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight ContactName
u | ContactId -> Maybe ContactId
forall a. a -> Maybe a
Just ContactId
userId Maybe ContactId -> Maybe ContactId -> Bool
forall a. Eq a => a -> a -> Bool
/= Maybe ContactId
currentUserId]
    currentUserId :: Maybe ContactId
currentUserId = (\User {userId :: User -> ContactId
userId = ContactId
uId} -> ContactId
uId) (User -> ContactId) -> Maybe User -> Maybe ContactId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe User
user_

viewSubErrorsSummary :: [ConnSubResult] -> [StyledString]
viewSubErrorsSummary :: [ConnSubResult] -> [StyledString]
viewSubErrorsSummary [ConnSubResult]
subErrs = [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
ttyError (String -> ContactName
T.pack (String -> ContactName) -> (Int -> String) -> Int -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String
forall a. Show a => a -> String
show (Int -> ContactName) -> Int -> ContactName
forall a b. (a -> b) -> a -> b
$ [ConnSubResult] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ConnSubResult]
subErrs) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" subscription errors (run with -c option to show each error)" | Bool -> Bool
not ([ConnSubResult] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ConnSubResult]
subErrs)]

contactList :: [ContactRef] -> String
contactList :: [ContactRef] -> String
contactList [ContactRef]
cs = ContactName -> String
T.unpack (ContactName -> String)
-> ([ContactName] -> ContactName) -> [ContactName] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> [ContactName] -> ContactName
T.intercalate ContactName
", " ([ContactName] -> String) -> [ContactName] -> String
forall a b. (a -> b) -> a -> b
$ (ContactRef -> ContactName) -> [ContactRef] -> [ContactName]
forall a b. (a -> b) -> [a] -> [b]
map (\ContactRef {localDisplayName :: ContactRef -> ContactName
localDisplayName = ContactName
n} -> ContactName
"@" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
n) [ContactRef]
cs

chatEventToView :: (Maybe RemoteHostId, Maybe User) -> ChatConfig -> Bool -> CurrentTime -> TimeZone -> Maybe RemoteHostId -> ChatEvent -> [StyledString]
chatEventToView :: (Maybe ContactId, Maybe User)
-> ChatConfig
-> Bool
-> UTCTime
-> TimeZone
-> Maybe ContactId
-> ChatEvent
-> [StyledString]
chatEventToView (Maybe ContactId, Maybe User)
hu ChatConfig {ChatLogLevel
logLevel :: ChatConfig -> ChatLogLevel
logLevel :: ChatLogLevel
logLevel, Bool
showReactions :: ChatConfig -> Bool
showReactions :: Bool
showReactions, Bool
showReceipts :: Bool
showReceipts :: ChatConfig -> Bool
showReceipts, Bool
testView :: ChatConfig -> Bool
testView :: Bool
testView} Bool
liveItems UTCTime
ts TimeZone
tz Maybe ContactId
outputRH = \case
  ChatEvent
CEvtChatSuspended -> [StyledString
"chat suspended"]
  CEvtContactSwitch User
u Contact
ct SwitchProgress
progress -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> SwitchProgress -> [StyledString]
viewContactSwitch Contact
ct SwitchProgress
progress
  CEvtGroupMemberSwitch User
u GroupInfo
g GroupMember
m SwitchProgress
progress -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> SwitchProgress -> [StyledString]
viewGroupMemberSwitch GroupInfo
g GroupMember
m SwitchProgress
progress
  CEvtContactRatchetSync User
u Contact
ct RatchetSyncProgress
progress -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> RatchetSyncProgress -> [StyledString]
viewContactRatchetSync Contact
ct RatchetSyncProgress
progress
  CEvtGroupMemberRatchetSync User
u GroupInfo
g GroupMember
m RatchetSyncProgress
progress -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> RatchetSyncProgress -> [StyledString]
viewGroupMemberRatchetSync GroupInfo
g GroupMember
m RatchetSyncProgress
progress
  CEvtChatInfoUpdated User
_ AChatInfo
_ -> []
  CEvtNewChatItems User
u [AChatItem]
chatItems -> (User -> [StyledString] -> [StyledString])
-> (forall (c :: ChatType) (d :: MsgDirection).
    User
    -> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString])
-> User
-> [AChatItem]
-> UTCTime
-> TimeZone
-> [StyledString]
viewChatItems User -> [StyledString] -> [StyledString]
ttyUser User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u [AChatItem]
chatItems UTCTime
ts TimeZone
tz
  CEvtChatItemsStatusesUpdated User
u [AChatItem]
chatItems
    | [AChatItem] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AChatItem]
chatItems Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
20 ->
        (AChatItem -> [StyledString]) -> [AChatItem] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap
          (\AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatItem -> UTCTime -> TimeZone -> Bool -> Bool -> [StyledString]
viewChatItemStatusUpdated AChatItem
ci UTCTime
ts TimeZone
tz Bool
testView Bool
showReceipts)
          [AChatItem]
chatItems
    | Bool
testView Bool -> Bool -> Bool
&& Bool
showReceipts ->
        User -> [StyledString] -> [StyledString]
ttyUser User
u [Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([AChatItem] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AChatItem]
chatItems) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" message statuses updated"]
    | Bool
otherwise -> []
  CEvtChatItemUpdated User
u (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat ChatItem c d
item) -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u ChatInfo c
chat ChatItem c d
item ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
forall (d :: MsgDirection) (c :: ChatType).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewItemUpdate ChatInfo c
chat ChatItem c d
item Bool
liveItems UTCTime
ts TimeZone
tz
  CEvtChatItemNotChanged User
u AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatItem -> [StyledString]
viewItemNotChanged AChatItem
ci
  CEvtChatItemReaction User
u Bool
added (ACIReaction SChatType c
_ SMsgDirection d
_ ChatInfo c
chat CIReaction c d
reaction) -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User
-> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
unmutedReaction User
u ChatInfo c
chat CIReaction c d
reaction ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Bool
-> ChatInfo c
-> CIReaction c d
-> Bool
-> UTCTime
-> TimeZone
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
Bool
-> ChatInfo c
-> CIReaction c d
-> Bool
-> UTCTime
-> TimeZone
-> [StyledString]
viewItemReaction Bool
showReactions ChatInfo c
chat CIReaction c d
reaction Bool
added UTCTime
ts TimeZone
tz
  CEvtChatItemsDeleted User
u [ChatItemDeletion]
deletions Bool
byUser Bool
timed -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (forall (c :: ChatType) (d :: MsgDirection).
 ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString])
-> [ChatItemDeletion]
-> Bool
-> Bool
-> UTCTime
-> TimeZone
-> Bool
-> [StyledString]
viewChatItemsDeleted (User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u) [ChatItemDeletion]
deletions Bool
byUser Bool
timed UTCTime
ts TimeZone
tz Bool
testView
  CEvtGroupChatItemsDeleted User
u GroupInfo
g [ContactId]
ciIds Bool
byUser Maybe GroupMember
member_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo
-> [ContactId] -> Bool -> Maybe GroupMember -> [StyledString]
viewGroupChatItemsDeleted GroupInfo
g [ContactId]
ciIds Bool
byUser Maybe GroupMember
member_
  CEvtChatItemDeletedNotFound User
u Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} SharedMsgId
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [ContactName -> StyledString
ttyFrom (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
c ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"> [deleted - original message not found]"]
  CEvtUserAcceptedGroupSent User
u GroupInfo
_g Maybe Contact
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [] -- [ttyGroup' g <> ": joining the group..."]
  CEvtSentGroupInvitation User
u GroupInfo
g Contact
c GroupMember
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> Contact -> [StyledString]
viewSentGroupInvitation GroupInfo
g Contact
c
  CEvtContactDeletedByContact User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u [Contact -> StyledString
ttyFullContact Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" deleted contact with you"]
  CEvtAcceptingContactRequest User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> [StyledString]
viewAcceptingContactRequest Contact
c
  CEvtAcceptingBusinessRequest User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [StyledString]
viewAcceptingBusinessRequest GroupInfo
g
  CEvtContactRequestAlreadyAccepted User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u [Contact -> StyledString
ttyFullContact Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": sent you a duplicate contact request, but you are already connected, no action needed"]
  CEvtBusinessRequestAlreadyAccepted User
u GroupInfo
g -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyFullGroup GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": sent you a duplicate connection request, but you are already connected, no action needed"]
  CEvtGroupLinkConnecting User
u GroupInfo
g GroupMember
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": joining the group..."]
  CEvtBusinessLinkConnecting User
u GroupInfo
g GroupMember
_ Contact
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": joining the group..."]
  CEvtUnknownMemberCreated User
u GroupInfo
g GroupMember
fwdM GroupMember
um -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
fwdM StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" forwarded a message from an unknown member, creating unknown member record " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
um]
  CEvtUnknownMemberBlocked User
u GroupInfo
g GroupMember
byM GroupMember
um -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
byM StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" blocked an unknown member, creating unknown member record " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
um]
  CEvtUnknownMemberAnnounced User
u GroupInfo
g GroupMember
_ GroupMember
um GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": unknown member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
um StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" updated to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m]
  CEvtRcvFileDescrReady User
_ AChatItem
_ RcvFileTransfer
_ RcvFileDescr
_ -> []
  CEvtRcvFileAccepted User
u AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ AChatItem -> [StyledString]
savingFile' AChatItem
ci
  CEvtRcvFileAcceptedSndCancelled User
u RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ RcvFileTransfer -> [StyledString]
viewRcvFileSndCancelled RcvFileTransfer
ft
  CEvtRcvFileProgressXFTP {} -> []
  CEvtContactUpdated {user :: ChatEvent -> User
user = User
u, fromContact :: ChatEvent -> Contact
fromContact = Contact
c, toContact :: ChatEvent -> Contact
toContact = Contact
c'} -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> Contact -> [StyledString]
viewContactUpdated Contact
c Contact
c' [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> User -> Contact -> Contact -> [StyledString]
viewContactPrefsUpdated User
u Contact
c Contact
c'
  CEvtGroupMemberUpdated {} -> []
  CEvtReceivedContactRequest User
u UserContactRequest {localDisplayName :: UserContactRequest -> ContactName
localDisplayName = ContactName
c, Profile
profile :: Profile
profile :: UserContactRequest -> Profile
profile} Maybe AChat
_chat -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ContactName -> Profile -> [StyledString]
viewReceivedContactRequest ContactName
c Profile
profile
  CEvtRcvFileStart User
u AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (Maybe ContactId, Maybe User)
-> Bool -> String -> AChatItem -> [StyledString]
receivingFile_' (Maybe ContactId, Maybe User)
hu Bool
testView String
"started" AChatItem
ci
  CEvtRcvFileComplete User
u AChatItem
ci -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (Maybe ContactId, Maybe User)
-> Bool -> String -> AChatItem -> [StyledString]
receivingFile_' (Maybe ContactId, Maybe User)
hu Bool
testView String
"completed" AChatItem
ci
  CEvtRcvStandaloneFileComplete User
u String
_ RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ String -> RcvFileTransfer -> [StyledString]
receivingFileStandalone String
"completed" RcvFileTransfer
ft
  CEvtRcvFileSndCancelled User
u AChatItem
_ RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ RcvFileTransfer -> [StyledString]
viewRcvFileSndCancelled RcvFileTransfer
ft
  CEvtRcvFileError User
u (Just AChatItem
ci) AgentErrorType
e RcvFileTransfer
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (Maybe ContactId, Maybe User)
-> Bool -> String -> AChatItem -> [StyledString]
receivingFile_' (Maybe ContactId, Maybe User)
hu Bool
testView String
"error" AChatItem
ci [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [AgentErrorType -> StyledString
forall a. Show a => a -> StyledString
sShow AgentErrorType
e]
  CEvtRcvFileError User
u Maybe AChatItem
Nothing AgentErrorType
e RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ String -> RcvFileTransfer -> [StyledString]
receivingFileStandalone String
"error" RcvFileTransfer
ft [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [AgentErrorType -> StyledString
forall a. Show a => a -> StyledString
sShow AgentErrorType
e]
  CEvtRcvFileWarning User
u (Just AChatItem
ci) AgentErrorType
e RcvFileTransfer
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (Maybe ContactId, Maybe User)
-> Bool -> String -> AChatItem -> [StyledString]
receivingFile_' (Maybe ContactId, Maybe User)
hu Bool
testView String
"warning: " AChatItem
ci [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [AgentErrorType -> StyledString
forall a. Show a => a -> StyledString
sShow AgentErrorType
e]
  CEvtRcvFileWarning User
u Maybe AChatItem
Nothing AgentErrorType
e RcvFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ String -> RcvFileTransfer -> [StyledString]
receivingFileStandalone String
"warning: " RcvFileTransfer
ft [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [AgentErrorType -> StyledString
forall a. Show a => a -> StyledString
sShow AgentErrorType
e]
  CEvtSndFileStart User
u AChatItem
_ SndFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> SndFileTransfer -> [StyledString]
sendingFile_ StyledString
"started" SndFileTransfer
ft
  CEvtSndFileComplete User
u AChatItem
_ SndFileTransfer
ft -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> SndFileTransfer -> [StyledString]
sendingFile_ StyledString
"completed" SndFileTransfer
ft
  CEvtSndFileProgressXFTP {} -> []
  CEvtSndFileRedirectStartXFTP User
u FileTransferMeta
ft FileTransferMeta
ftRedirect -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ FileTransferMeta -> FileTransferMeta -> [StyledString]
standaloneUploadRedirect FileTransferMeta
ft FileTransferMeta
ftRedirect
  CEvtSndStandaloneFileComplete User
u FileTransferMeta
ft [ContactName]
uris -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ FileTransferMeta -> [ContactName] -> [StyledString]
standaloneUploadComplete FileTransferMeta
ft [ContactName]
uris
  CEvtSndFileCompleteXFTP User
u AChatItem
ci FileTransferMeta
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> AChatItem -> [StyledString]
uploadingFile StyledString
"completed" AChatItem
ci
  CEvtSndFileError User
u Maybe AChatItem
Nothing FileTransferMeta
ft ContactName
e -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> FileTransferMeta -> [StyledString]
uploadingFileStandalone StyledString
"error" FileTransferMeta
ft [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
e]
  CEvtSndFileError User
u (Just AChatItem
ci) FileTransferMeta
_ ContactName
e -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> AChatItem -> [StyledString]
uploadingFile StyledString
"error" AChatItem
ci [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
e]
  CEvtSndFileWarning User
u Maybe AChatItem
Nothing FileTransferMeta
ft ContactName
e -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> FileTransferMeta -> [StyledString]
uploadingFileStandalone StyledString
"warning: " FileTransferMeta
ft [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
e]
  CEvtSndFileWarning User
u (Just AChatItem
ci) FileTransferMeta
_ ContactName
e -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> AChatItem -> [StyledString]
uploadingFile StyledString
"warning: " AChatItem
ci [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
e]
  CEvtSndFileRcvCancelled User
u Maybe AChatItem
_ ft :: SndFileTransfer
ft@SndFileTransfer {recipientDisplayName :: SndFileTransfer -> ContactName
recipientDisplayName = ContactName
c} ->
    User -> [StyledString] -> [StyledString]
ttyUser User
u [ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" cancelled receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SndFileTransfer -> StyledString
sndFile SndFileTransfer
ft]
  CEvtContactConnecting User
u Contact
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u []
  CEvtContactConnected User
u Contact
ct Maybe Profile
userCustomProfile -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> Maybe Profile -> Bool -> [StyledString]
viewContactConnected Contact
ct Maybe Profile
userCustomProfile Bool
testView
  CEvtContactSndReady User
u Contact
ct -> User -> [StyledString] -> [StyledString]
ttyUser User
u [Contact -> StyledString
ttyFullContact Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you can send messages to contact"]
  CEvtContactAnotherClient User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u [Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": contact is connected to another client"]
  CEvtConnectionsDiff DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff -> DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSync DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
  CEvtSubscriptionEnd User
u ConnectionEntity
acEntity ->
    let Connection {ContactId
connId :: ContactId
connId :: Connection -> ContactId
connId} = ConnectionEntity -> Connection
entityConnection ConnectionEntity
acEntity
     in User -> [StyledString] -> [StyledString]
ttyUser User
u [ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
connId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": END"]
  CEvtSubscriptionStatus SMPServer
srv SubscriptionStatus
status [AgentConnId]
conns -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ SubscriptionStatus -> String
subStatusStr SubscriptionStatus
status String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show ([AgentConnId] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AgentConnId]
conns) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" connections on server " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> SMPServer -> String
showSMPServer SMPServer
srv]
  CEvtReceivedGroupInvitation {user :: ChatEvent -> User
user = User
u, groupInfo :: ChatEvent -> GroupInfo
groupInfo = GroupInfo
g, contact :: ChatEvent -> Contact
contact = Contact
c, memberRole :: ChatEvent -> GroupMemberRole
memberRole = GroupMemberRole
r} -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> Contact -> GroupMemberRole -> [StyledString]
viewReceivedGroupInvitation GroupInfo
g Contact
c GroupMemberRole
r
  CEvtUserJoinedGroup User
u GroupInfo
g GroupMember
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> [StyledString]
viewUserJoinedGroup GroupInfo
g
  CEvtJoinedGroupMember User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> [StyledString]
viewJoinedGroupMember GroupInfo
g GroupMember
m
  CEvtHostConnected AProtocolType
p TransportHost
h -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"connected to " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> AProtocolType -> TransportHost -> String
viewHostEvent AProtocolType
p TransportHost
h]
  CEvtHostDisconnected AProtocolType
p TransportHost
h -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"disconnected from " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> AProtocolType -> TransportHost -> String
viewHostEvent AProtocolType
p TransportHost
h]
  CEvtJoinedGroupMemberConnecting User
u GroupInfo
g GroupMember
host GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> GroupMember -> [StyledString]
viewJoinedGroupMemberConnecting GroupInfo
g GroupMember
host GroupMember
m
  CEvtConnectedToGroupMember User
u GroupInfo
g GroupMember
m Maybe Contact
_ -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> [StyledString]
viewConnectedToGroupMember GroupInfo
g GroupMember
m
  CEvtMemberAcceptedByOther User
u GroupInfo
g GroupMember
acceptingMember GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> GroupMember -> [StyledString]
viewMemberAcceptedByOther GroupInfo
g GroupMember
acceptingMember GroupMember
m
  CEvtMemberRole User
u GroupInfo
g GroupMember
by GroupMember
m GroupMemberRole
r GroupMemberRole
r' -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo
-> GroupMember
-> GroupMember
-> GroupMemberRole
-> GroupMemberRole
-> [StyledString]
viewMemberRoleChanged GroupInfo
g GroupMember
by GroupMember
m GroupMemberRole
r GroupMemberRole
r'
  CEvtMemberBlockedForAll User
u GroupInfo
g GroupMember
by GroupMember
m Bool
blocked -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> GroupMember -> Bool -> [StyledString]
viewMemberBlockedForAll GroupInfo
g GroupMember
by GroupMember
m Bool
blocked
  CEvtDeletedMemberUser User
u GroupInfo
g GroupMember
by Bool
wm -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
by StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" removed you from the group" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Bool -> StyledString
forall {a}. IsString a => Bool -> a
withMessages Bool
wm] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> [StyledString]
groupPreserved GroupInfo
g
  CEvtDeletedMember User
u GroupInfo
g GroupMember
by GroupMember
m Bool
wm -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
by StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" removed " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" from the group" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Bool -> StyledString
forall {a}. IsString a => Bool -> a
withMessages Bool
wm]
  CEvtLeftMember User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" left the group"]
  CEvtGroupDeleted User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" deleted the group", StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/d #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to delete the local copy of the group"]
  CEvtGroupUpdated User
u GroupInfo
g GroupInfo
g' Maybe GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupInfo -> Maybe GroupMember -> [StyledString]
viewGroupUpdated GroupInfo
g GroupInfo
g' Maybe GroupMember
m
  CEvtAcceptingGroupJoinRequestMember User
_ GroupInfo
g GroupMember
m -> [GroupMember -> StyledString
ttyFullMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": accepting request to join group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"..."]
  CEvtNoMemberContactCreating User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" does not have direct connection, creating"]
  CEvtNewMemberContactReceivedInv User
u Contact
ct GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User -> Contact -> GroupInfo -> GroupMember -> [StyledString]
viewNewMemberContactReceivedInv User
u Contact
ct GroupInfo
g GroupMember
m
  CEvtContactAndMemberAssociated User
u Contact
ct GroupInfo
g GroupMember
m Contact
ct' -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> GroupInfo -> GroupMember -> Contact -> [StyledString]
viewContactAndMemberAssociated Contact
ct GroupInfo
g GroupMember
m Contact
ct'
  CEvtCallInvitation RcvCallInvitation {User
user :: User
user :: RcvCallInvitation -> User
user, Contact
contact :: Contact
contact :: RcvCallInvitation -> Contact
contact, CallType
callType :: CallType
callType :: RcvCallInvitation -> CallType
callType, Maybe Key
sharedKey :: Maybe Key
sharedKey :: RcvCallInvitation -> Maybe Key
sharedKey} -> User -> [StyledString] -> [StyledString]
ttyUser User
user ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> CallType -> Maybe Key -> [StyledString]
viewCallInvitation Contact
contact CallType
callType Maybe Key
sharedKey
  CEvtCallOffer {user :: ChatEvent -> User
user = User
u, Contact
contact :: ChatEvent -> Contact
contact :: Contact
contact, CallType
callType :: CallType
callType :: ChatEvent -> CallType
callType, WebRTCSession
offer :: WebRTCSession
offer :: ChatEvent -> WebRTCSession
offer, Maybe Key
sharedKey :: Maybe Key
sharedKey :: ChatEvent -> Maybe Key
sharedKey} -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> CallType -> WebRTCSession -> Maybe Key -> [StyledString]
viewCallOffer Contact
contact CallType
callType WebRTCSession
offer Maybe Key
sharedKey
  CEvtCallAnswer {user :: ChatEvent -> User
user = User
u, Contact
contact :: ChatEvent -> Contact
contact :: Contact
contact, WebRTCSession
answer :: WebRTCSession
answer :: ChatEvent -> WebRTCSession
answer} -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> WebRTCSession -> [StyledString]
viewCallAnswer Contact
contact WebRTCSession
answer
  CEvtCallExtraInfo {user :: ChatEvent -> User
user = User
u, Contact
contact :: ChatEvent -> Contact
contact :: Contact
contact} -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"call extra info from " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
contact]
  CEvtCallEnded {user :: ChatEvent -> User
user = User
u, Contact
contact :: ChatEvent -> Contact
contact :: Contact
contact} -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"call with " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
contact StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ended"]
  CEvtNtfMessage {} -> []
  CEvtRemoteHostSessionCode {Maybe RemoteHostInfo
remoteHost_ :: Maybe RemoteHostInfo
remoteHost_ :: ChatEvent -> Maybe RemoteHostInfo
remoteHost_, ContactName
sessionCode :: ContactName
sessionCode :: ChatEvent -> ContactName
sessionCode} ->
    [ StyledString
-> (RemoteHostInfo -> StyledString)
-> Maybe RemoteHostInfo
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"new remote host connecting" (\RemoteHostInfo {remoteHostId :: RemoteHostInfo -> ContactId
remoteHostId = ContactId
rhId} -> StyledString
"remote host " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rhId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" connecting") Maybe RemoteHostInfo
remoteHost_,
      StyledString
"Compare session code with host:",
      ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
sessionCode
    ]
  CEvtNewRemoteHost RemoteHostInfo {remoteHostId :: RemoteHostInfo -> ContactId
remoteHostId = ContactId
rhId, ContactName
hostDeviceName :: RemoteHostInfo -> ContactName
hostDeviceName :: ContactName
hostDeviceName} -> [StyledString
"new remote host " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rhId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" added: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
hostDeviceName]
  CEvtRemoteHostConnected RemoteHostInfo {remoteHostId :: RemoteHostInfo -> ContactId
remoteHostId = ContactId
rhId} -> [StyledString
"remote host " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rhId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" connected"]
  CEvtRemoteHostStopped {Maybe ContactId
remoteHostId_ :: Maybe ContactId
remoteHostId_ :: ChatEvent -> Maybe ContactId
remoteHostId_} ->
    [ StyledString
-> (ContactId -> StyledString) -> Maybe ContactId -> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"new remote host" (StyledString -> StyledString -> StyledString
forall a. Monoid a => a -> a -> a
mappend StyledString
"remote host " (StyledString -> StyledString)
-> (ContactId -> StyledString) -> ContactId -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow) Maybe ContactId
remoteHostId_ StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" stopped"
    ]
  CEvtRemoteCtrlFound {remoteCtrl :: ChatEvent -> RemoteCtrlInfo
remoteCtrl = RemoteCtrlInfo {ContactId
remoteCtrlId :: RemoteCtrlInfo -> ContactId
remoteCtrlId :: ContactId
remoteCtrlId, ContactName
ctrlDeviceName :: RemoteCtrlInfo -> ContactName
ctrlDeviceName :: ContactName
ctrlDeviceName}, Maybe CtrlAppInfo
ctrlAppInfo_ :: Maybe CtrlAppInfo
ctrlAppInfo_ :: ChatEvent -> Maybe CtrlAppInfo
ctrlAppInfo_, AppVersion
appVersion :: AppVersion
appVersion :: ChatEvent -> AppVersion
appVersion, Bool
compatible :: Bool
compatible :: ChatEvent -> Bool
compatible} ->
    [ (StyledString
"remote controller " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
remoteCtrlId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" found: ")
        StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (CtrlAppInfo -> StyledString)
-> Maybe CtrlAppInfo
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (StyledString
deviceName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"not compatible") (\CtrlAppInfo
info -> CtrlAppInfo -> AppVersion -> Bool -> StyledString
viewRemoteCtrl CtrlAppInfo
info AppVersion
appVersion Bool
compatible) Maybe CtrlAppInfo
ctrlAppInfo_
    ]
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/confirm remote ctrl " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
remoteCtrlId) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to connect" | Maybe CtrlAppInfo -> Bool
forall a. Maybe a -> Bool
isJust Maybe CtrlAppInfo
ctrlAppInfo_ Bool -> Bool -> Bool
&& Bool
compatible]
    where
      deviceName :: StyledString
deviceName = if ContactName -> Bool
T.null ContactName
ctrlDeviceName then StyledString
"" else ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
ctrlDeviceName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", "
  CEvtRemoteCtrlSessionCode {Maybe RemoteCtrlInfo
remoteCtrl_ :: Maybe RemoteCtrlInfo
remoteCtrl_ :: ChatEvent -> Maybe RemoteCtrlInfo
remoteCtrl_, ContactName
sessionCode :: ChatEvent -> ContactName
sessionCode :: ContactName
sessionCode} ->
    [ StyledString
-> (RemoteCtrlInfo -> StyledString)
-> Maybe RemoteCtrlInfo
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"new remote controller connected" (\RemoteCtrlInfo {ContactId
remoteCtrlId :: RemoteCtrlInfo -> ContactId
remoteCtrlId :: ContactId
remoteCtrlId} -> StyledString
"remote controller " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
remoteCtrlId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" connected") Maybe RemoteCtrlInfo
remoteCtrl_,
      StyledString
"Compare session code with controller and use:",
      StyledString
"/verify remote ctrl " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
sessionCode -- TODO maybe pass rcId
    ]
  CEvtRemoteCtrlStopped {RemoteCtrlStopReason
rcStopReason :: RemoteCtrlStopReason
rcStopReason :: ChatEvent -> RemoteCtrlStopReason
rcStopReason} -> RemoteCtrlStopReason -> [StyledString]
viewRemoteCtrlStopped RemoteCtrlStopReason
rcStopReason
  CEvtContactPQEnabled User
u Contact
c (CR.PQEncryption Bool
pqOn) -> User -> [StyledString] -> [StyledString]
ttyUser User
u [Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (if Bool
pqOn then StyledString
"quantum resistant" else StyledString
"standard") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" end-to-end encryption enabled"]
  CEvtContactDisabled User
u Contact
c -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] connection is disabled, to enable: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/enable " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
c) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", to delete: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/d " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
c)]
  CEvtConnectionDisabled ConnectionEntity
entity -> ConnectionEntity -> [StyledString]
viewConnectionEntityDisabled ConnectionEntity
entity
  CEvtConnectionInactive ConnectionEntity
entity Bool
inactive -> ConnectionEntity -> Bool -> [StyledString]
viewConnectionEntityInactive ConnectionEntity
entity Bool
inactive
  CEvtAgentRcvQueuesDeleted NonEmpty DeletedRcvQueue
delQs -> [StyledString
"completed deleting rcv queues: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow (NonEmpty DeletedRcvQueue -> Int
forall a. NonEmpty a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length NonEmpty DeletedRcvQueue
delQs) | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLInfo]
  CEvtAgentConnsDeleted NonEmpty AgentConnId
acIds -> [StyledString
"completed deleting connections: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow (NonEmpty AgentConnId -> Int
forall a. NonEmpty a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length NonEmpty AgentConnId
acIds) | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLInfo]
  CEvtAgentUserDeleted ContactId
auId -> [StyledString
"completed deleting user" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLInfo then StyledString
", agent user id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
auId else StyledString
""]
  CEvtMessageError User
u ContactName
prefix ContactName
err -> User -> [StyledString] -> [StyledString]
ttyUser User
u [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
prefix StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
err | ContactName
prefix ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
"error" Bool -> Bool -> Bool
|| ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLWarning]
  CEvtChatErrors [ChatError]
errs -> (ChatError -> [StyledString]) -> [ChatError] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Bool -> ChatLogLevel -> Bool -> ChatError -> [StyledString]
viewChatError Bool
False ChatLogLevel
logLevel Bool
testView) [ChatError]
errs
  CEvtTimedAction String
_ ContactId
_ -> []
  CEvtTerminalEvent TerminalEvent
te -> case TerminalEvent
te of
    TERejectingGroupJoinRequestMember User
_ GroupInfo
g GroupMember
m GroupRejectionReason
reason -> [GroupMember -> StyledString
ttyFullMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": rejecting request to join group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", reason: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupRejectionReason -> StyledString
forall a. Show a => a -> StyledString
sShow GroupRejectionReason
reason]
    TEGroupLinkRejected User
u GroupInfo
g GroupRejectionReason
reason -> User -> [StyledString] -> [StyledString]
ttyUser User
u [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": join rejected, reason: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupRejectionReason -> StyledString
forall a. Show a => a -> StyledString
sShow GroupRejectionReason
reason]
    TENewMemberContact User
u Contact
_ GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u [StyledString
"contact for member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is created"]
    TEContactVerificationReset User
u Contact
ct -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ Contact -> [StyledString]
viewContactVerificationReset Contact
ct
    TEGroupMemberVerificationReset User
u GroupInfo
g GroupMember
m -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> GroupMember -> [StyledString]
viewGroupMemberVerificationReset GroupInfo
g GroupMember
m
  CEvtCustomChatEvent Maybe User
u ContactName
r -> Maybe User -> [StyledString] -> [StyledString]
ttyUser' Maybe User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ContactName] -> [StyledString])
-> [ContactName] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ContactName -> [ContactName]
T.lines ContactName
r
  where
    ttyUser :: User -> [StyledString] -> [StyledString]
    ttyUser :: User -> [StyledString] -> [StyledString]
ttyUser user :: User
user@User {Bool
showNtfs :: User -> Bool
showNtfs :: Bool
showNtfs, Bool
activeUser :: User -> Bool
activeUser :: Bool
activeUser, Maybe UserPwdHash
viewPwdHash :: User -> Maybe UserPwdHash
viewPwdHash :: Maybe UserPwdHash
viewPwdHash} [StyledString]
ss
      | (Bool
showNtfs Bool -> Bool -> Bool
&& Maybe UserPwdHash -> Bool
forall a. Maybe a -> Bool
isNothing Maybe UserPwdHash
viewPwdHash) Bool -> Bool -> Bool
|| Bool
activeUser = (Maybe ContactId, Maybe User)
-> Maybe ContactId -> User -> [StyledString] -> [StyledString]
ttyUserPrefix (Maybe ContactId, Maybe User)
hu Maybe ContactId
outputRH User
user [StyledString]
ss
      | Bool
otherwise = []
    ttyUser' :: Maybe User -> [StyledString] -> [StyledString]
    ttyUser' :: Maybe User -> [StyledString] -> [StyledString]
ttyUser' = ([StyledString] -> [StyledString])
-> (User -> [StyledString] -> [StyledString])
-> Maybe User
-> [StyledString]
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString] -> [StyledString]
forall a. a -> a
id User -> [StyledString] -> [StyledString]
ttyUser
    withMessages :: Bool -> a
withMessages Bool
wm = if Bool
wm then a
" with all messages" else a
""
    unmuted :: User -> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
    unmuted :: forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u ChatInfo c
chat ci :: ChatItem c d
ci@ChatItem {CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir} = User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
unmuted' User
u ChatInfo c
chat CIDirection c d
chatDir (Bool -> [StyledString] -> [StyledString])
-> Bool -> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatItem c d -> Bool
forall (c :: ChatType) (d :: MsgDirection). ChatItem c d -> Bool
isUserMention ChatItem c d
ci
    unmutedReaction :: User -> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
    unmutedReaction :: forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> CIReaction c d -> [StyledString] -> [StyledString]
unmutedReaction User
u ChatInfo c
chat CIReaction {CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
CIReaction c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir} = User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
unmuted' User
u ChatInfo c
chat CIDirection c d
chatDir Bool
False
    unmuted' :: User -> ChatInfo c -> CIDirection c d -> Bool -> [StyledString] -> [StyledString]
    unmuted' :: forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c
-> CIDirection c d
-> Bool
-> [StyledString]
-> [StyledString]
unmuted' User
u ChatInfo c
chat CIDirection c d
chatDir Bool
mention [StyledString]
s
      | User -> ChatInfo c -> CIDirection c d -> Bool -> Bool
forall (c :: ChatType) (d :: MsgDirection).
User -> ChatInfo c -> CIDirection c d -> Bool -> Bool
chatDirNtf User
u ChatInfo c
chat CIDirection c d
chatDir Bool
mention = [StyledString]
s
      | Bool
testView = (StyledString -> StyledString) -> [StyledString] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" <muted>") [StyledString]
s
      | Bool
otherwise = []

userNtf :: User -> Bool
userNtf :: User -> Bool
userNtf User {Bool
showNtfs :: User -> Bool
showNtfs :: Bool
showNtfs, Bool
activeUser :: User -> Bool
activeUser :: Bool
activeUser} = Bool
showNtfs Bool -> Bool -> Bool
|| Bool
activeUser

chatDirNtf :: User -> ChatInfo c -> CIDirection c d -> Bool -> Bool
chatDirNtf :: forall (c :: ChatType) (d :: MsgDirection).
User -> ChatInfo c -> CIDirection c d -> Bool -> Bool
chatDirNtf User
user ChatInfo c
cInfo CIDirection c d
chatDir Bool
mention = case (ChatInfo c
cInfo, CIDirection c d
chatDir) of
  (DirectChat Contact
ct, CIDirection c d
CIDirectRcv) -> User -> Contact -> Bool -> Bool
contactNtf User
user Contact
ct Bool
mention
  (GroupChat GroupInfo
g Maybe GroupChatScopeInfo
_scopeInfo, CIGroupRcv GroupMember
m) -> User -> GroupInfo -> Bool -> Bool
groupNtf User
user GroupInfo
g Bool
mention Bool -> Bool -> Bool
&& Bool -> Bool
not (GroupMember -> Bool
memberBlocked GroupMember
m)
  (ChatInfo c, CIDirection c d)
_ -> Bool
True

contactNtf :: User -> Contact -> Bool -> Bool
contactNtf :: User -> Contact -> Bool -> Bool
contactNtf User
user Contact {ChatSettings
chatSettings :: ChatSettings
chatSettings :: Contact -> ChatSettings
chatSettings} Bool
mention =
  User -> Bool
userNtf User
user Bool -> Bool -> Bool
&& ChatSettings -> Bool -> Bool
showMessageNtf ChatSettings
chatSettings Bool
mention

groupNtf :: User -> GroupInfo -> Bool -> Bool
groupNtf :: User -> GroupInfo -> Bool -> Bool
groupNtf User
user GroupInfo {ChatSettings
chatSettings :: ChatSettings
chatSettings :: GroupInfo -> ChatSettings
chatSettings} Bool
mention =
  User -> Bool
userNtf User
user Bool -> Bool -> Bool
&& ChatSettings -> Bool -> Bool
showMessageNtf ChatSettings
chatSettings Bool
mention

showMessageNtf :: ChatSettings -> Bool -> Bool
showMessageNtf :: ChatSettings -> Bool -> Bool
showMessageNtf ChatSettings {MsgFilter
enableNtfs :: MsgFilter
enableNtfs :: ChatSettings -> MsgFilter
enableNtfs} Bool
mention =
  MsgFilter
enableNtfs MsgFilter -> MsgFilter -> Bool
forall a. Eq a => a -> a -> Bool
== MsgFilter
MFAll Bool -> Bool -> Bool
|| (Bool
mention Bool -> Bool -> Bool
&& MsgFilter
enableNtfs MsgFilter -> MsgFilter -> Bool
forall a. Eq a => a -> a -> Bool
== MsgFilter
MFMentions)

chatItemDeletedText :: ChatItem c d -> Maybe GroupMember -> Maybe Text
chatItemDeletedText :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe GroupMember -> Maybe ContactName
chatItemDeletedText ChatItem {meta :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIMeta c d
meta = CIMeta {Maybe (CIDeleted c)
itemDeleted :: Maybe (CIDeleted c)
itemDeleted :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe (CIDeleted c)
itemDeleted}, CIContent d
content :: CIContent d
content :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIContent d
content} Maybe GroupMember
membership_ =
  CIDeleted c -> ContactName
deletedText (CIDeleted c -> ContactName)
-> Maybe (CIDeleted c) -> Maybe ContactName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (CIDeleted c)
itemDeleted
  where
    deletedText :: CIDeleted c -> ContactName
deletedText = \case
      CIModerated Maybe UTCTime
_ GroupMember
m -> CIContent d -> ContactName
forall {d :: MsgDirection}. CIContent d -> ContactName
markedDeleted CIContent d
content ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
byMember GroupMember
m
      CIDeleted Maybe UTCTime
_ -> CIContent d -> ContactName
forall {d :: MsgDirection}. CIContent d -> ContactName
markedDeleted CIContent d
content
      CIBlocked Maybe UTCTime
_ -> ContactName
"blocked"
      CIBlockedByAdmin Maybe UTCTime
_ -> ContactName
"blocked by admin"
    markedDeleted :: CIContent d -> ContactName
markedDeleted = \case
      CIContent d
CISndModerated -> ContactName
"deleted"
      CIContent d
CIRcvModerated -> ContactName
"deleted"
      CIContent d
_ -> ContactName
"marked deleted"
    byMember :: GroupMember -> ContactName
byMember GroupMember {groupMemberId :: GroupMember -> ContactId
groupMemberId = ContactId
mId, localDisplayName :: GroupMember -> ContactName
localDisplayName = ContactName
n} = case Maybe GroupMember
membership_ of
      Just GroupMember {groupMemberId :: GroupMember -> ContactId
groupMemberId = ContactId
membershipId} ->
        ContactName
" by " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> if ContactId
mId ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
membershipId then ContactName
"you" else ContactName
n
      Maybe GroupMember
_ -> ContactName
""

viewUsersList :: [UserInfo] -> [StyledString]
viewUsersList :: [UserInfo] -> [StyledString]
viewUsersList [UserInfo]
us =
  let ss :: [StyledString]
ss = (UserInfo -> Maybe StyledString) -> [UserInfo] -> [StyledString]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe UserInfo -> Maybe StyledString
userInfo ([UserInfo] -> [StyledString]) -> [UserInfo] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (UserInfo -> ContactName) -> [UserInfo] -> [UserInfo]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn UserInfo -> ContactName
ldn [UserInfo]
us
   in if [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
ss then [StyledString
"no users"] else [StyledString]
ss
  where
    ldn :: UserInfo -> ContactName
ldn (UserInfo User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
n} Int
_) = ContactName -> ContactName
T.toLower ContactName
n
    userInfo :: UserInfo -> Maybe StyledString
userInfo (UserInfo User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
n, profile :: User -> LocalProfile
profile = LocalProfile {ContactName
fullName :: ContactName
fullName :: LocalProfile -> ContactName
fullName, Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr :: LocalProfile -> Maybe ContactName
shortDescr, Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType :: LocalProfile -> Maybe ChatPeerType
peerType}, Bool
activeUser :: User -> Bool
activeUser :: Bool
activeUser, Bool
showNtfs :: User -> Bool
showNtfs :: Bool
showNtfs, Maybe UserPwdHash
viewPwdHash :: User -> Maybe UserPwdHash
viewPwdHash :: Maybe UserPwdHash
viewPwdHash} Int
count)
      | Bool
activeUser Bool -> Bool -> Bool
|| Maybe UserPwdHash -> Bool
forall a. Maybe a -> Bool
isNothing Maybe UserPwdHash
viewPwdHash = StyledString -> Maybe StyledString
forall a. a -> Maybe a
Just (StyledString -> Maybe StyledString)
-> StyledString -> Maybe StyledString
forall a b. (a -> b) -> a -> b
$ ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
n ContactName
fullName Maybe ContactName
shortDescr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
infoStr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
bot
      | Bool
otherwise = Maybe StyledString
forall a. Maybe a
Nothing
      where
        infoStr :: StyledString
infoStr = if [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
info then StyledString
"" else StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [StyledString] -> StyledString
forall a. Monoid a => [a] -> a
mconcat (StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
intersperse StyledString
", " [StyledString]
info) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"
        info :: [StyledString]
info =
          [String -> StyledString
highlight' String
"active" | Bool
activeUser]
            [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [String -> StyledString
highlight' String
"hidden" | Maybe UserPwdHash -> Bool
forall a. Maybe a -> Bool
isJust Maybe UserPwdHash
viewPwdHash]
            [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"muted" | Bool -> Bool
not Bool
showNtfs]
            [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String
"unread: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
count) | Int
count Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
0]
        bot :: StyledString
bot = case Maybe ChatPeerType
peerType of
          Just ChatPeerType
CPTBot -> StyledString
" (bot)"
          Maybe ChatPeerType
_ -> StyledString
""

showSMPServer :: SMPServer -> String
showSMPServer :: SMPServer -> String
showSMPServer ProtocolServer {NonEmpty TransportHost
host :: NonEmpty TransportHost
host :: forall (p :: ProtocolType).
ProtocolServer p -> NonEmpty TransportHost
host} = ByteString -> String
B.unpack (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ NonEmpty TransportHost -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode NonEmpty TransportHost
host

viewHostEvent :: AProtocolType -> TransportHost -> String
viewHostEvent :: AProtocolType -> TransportHost -> String
viewHostEvent AProtocolType
p TransportHost
h = (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper (ByteString -> String
B.unpack (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ AProtocolType -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode AProtocolType
p) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" host " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ByteString -> String
B.unpack (TransportHost -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode TransportHost
h)

viewChats :: CurrentTime -> TimeZone -> [AChat] -> [StyledString]
viewChats :: UTCTime -> TimeZone -> [AChat] -> [StyledString]
viewChats UTCTime
ts TimeZone
tz = (AChat -> [StyledString]) -> [AChat] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap AChat -> [StyledString]
chatPreview ([AChat] -> [StyledString])
-> ([AChat] -> [AChat]) -> [AChat] -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [AChat] -> [AChat]
forall a. [a] -> [a]
reverse
  where
    chatPreview :: AChat -> [StyledString]
chatPreview (AChat SChatType c
_ (Chat ChatInfo c
chat [CChatItem c]
items ChatStats
_)) = case [CChatItem c]
items of
      CChatItem SMsgDirection d
_ ChatItem c d
ci : [CChatItem c]
_ -> case ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewChatItem ChatInfo c
chat ChatItem c d
ci Bool
True UTCTime
ts TimeZone
tz of
        StyledString
s : [StyledString]
_ -> [let s' :: StyledString
s' = Int -> StyledString -> StyledString
sTake Int
120 StyledString
s in if StyledString -> Int
sLength StyledString
s' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< StyledString -> Int
sLength StyledString
s then StyledString
s' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"..." else StyledString
s']
        [StyledString]
_ -> [StyledString]
chatName
      [CChatItem c]
_ -> [StyledString]
chatName
      where
        chatName :: [StyledString]
chatName = case ChatInfo c
chat of
          DirectChat Contact
ct -> [StyledString
"      " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyToContact' Contact
ct]
          GroupChat GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo -> [StyledString
"      " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo]
          ChatInfo c
_ -> []

viewChatItems ::
  (User -> [StyledString] -> [StyledString]) ->
  (forall c d. User -> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]) ->
  User ->
  [AChatItem] ->
  UTCTime ->
  TimeZone ->
  [StyledString]
viewChatItems :: (User -> [StyledString] -> [StyledString])
-> (forall (c :: ChatType) (d :: MsgDirection).
    User
    -> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString])
-> User
-> [AChatItem]
-> UTCTime
-> TimeZone
-> [StyledString]
viewChatItems User -> [StyledString] -> [StyledString]
ttyUser forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u [AChatItem]
chatItems UTCTime
ts TimeZone
tz
  | [AChatItem] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AChatItem]
chatItems Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
20 =
      (AChatItem -> [StyledString]) -> [AChatItem] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap
        (\(AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat ChatItem c d
item) -> User -> [StyledString] -> [StyledString]
ttyUser User
u ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
User
-> ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted User
u ChatInfo c
chat ChatItem c d
item ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewChatItem ChatInfo c
chat ChatItem c d
item Bool
False UTCTime
ts TimeZone
tz [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> ChatItem c d -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> [StyledString]
viewItemReactions ChatItem c d
item)
        [AChatItem]
chatItems
  | (AChatItem -> Bool) -> [AChatItem] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (\AChatItem
aci -> AChatItem -> MsgDirection
aChatItemDir AChatItem
aci MsgDirection -> MsgDirection -> Bool
forall a. Eq a => a -> a -> Bool
== MsgDirection
MDRcv) [AChatItem]
chatItems = User -> [StyledString] -> [StyledString]
ttyUser User
u [Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([AChatItem] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AChatItem]
chatItems) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" new messages"]
  | (AChatItem -> Bool) -> [AChatItem] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (\AChatItem
aci -> AChatItem -> MsgDirection
aChatItemDir AChatItem
aci MsgDirection -> MsgDirection -> Bool
forall a. Eq a => a -> a -> Bool
== MsgDirection
MDSnd) [AChatItem]
chatItems = User -> [StyledString] -> [StyledString]
ttyUser User
u [Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([AChatItem] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AChatItem]
chatItems) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" messages sent"]
  | Bool
otherwise = User -> [StyledString] -> [StyledString]
ttyUser User
u [Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([AChatItem] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AChatItem]
chatItems) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" new messages created"]

viewChatItem :: forall c d. MsgDirectionI d => ChatInfo c -> ChatItem c d -> Bool -> CurrentTime -> TimeZone -> [StyledString]
viewChatItem :: forall (c :: ChatType) (d :: MsgDirection).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewChatItem ChatInfo c
chat ci :: ChatItem c d
ci@ChatItem {CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir, meta :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIMeta c d
meta = meta :: CIMeta c d
meta@CIMeta {Maybe CIForwardedFrom
itemForwarded :: Maybe CIForwardedFrom
itemForwarded :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe CIForwardedFrom
itemForwarded, Maybe ContactId
forwardedByMember :: Maybe ContactId
forwardedByMember :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe ContactId
forwardedByMember, Bool
userMention :: Bool
userMention :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> Bool
userMention}, CIContent d
content :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIContent d
content :: CIContent d
content, Maybe (CIQuote c)
quotedItem :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIQuote c)
quotedItem :: Maybe (CIQuote c)
quotedItem, Maybe (CIFile d)
file :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIFile d)
file :: Maybe (CIFile d)
file} Bool
doShow UTCTime
ts TimeZone
tz =
  StyledString -> StyledString
withGroupMsgForwarded (StyledString -> StyledString)
-> (StyledString -> StyledString) -> StyledString -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyledString -> StyledString
withItemDeleted (StyledString -> StyledString) -> [StyledString] -> [StyledString]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [StyledString]
viewCI
  where
    viewCI :: [StyledString]
viewCI = case ChatInfo c
chat of
      DirectChat Contact
c -> case CIDirection c d
chatDir of
        CIDirection c d
CIDirectSnd -> case CIContent d
content of
          CISndMsgContent MsgContent
mc -> CIMeta c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> [StyledString] -> [StyledString]
hideLive CIMeta c d
meta ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> [StyledString]
withSndFile StyledString
to ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> MsgContent -> [StyledString]
sndMsg StyledString
to [StyledString]
context MsgContent
mc
          CISndGroupEvent {} -> StyledString -> [StyledString]
showSndItemProhibited StyledString
to
          CIContent d
_ -> StyledString -> [StyledString]
showSndItem StyledString
to
          where
            to :: StyledString
to = Contact -> StyledString
ttyToContact' Contact
c
        CIDirection c d
CIDirectRcv -> case CIContent d
content of
          CIRcvMsgContent MsgContent
mc -> StyledString -> [StyledString] -> [StyledString]
withRcvFile StyledString
from ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> MsgContent -> [StyledString]
rcvMsg StyledString
from [StyledString]
context MsgContent
mc
          CIRcvIntegrityError MsgErrorType
err -> StyledString
-> MsgErrorType
-> UTCTime
-> TimeZone
-> CIMeta c 'MDRcv
-> [StyledString]
forall (c :: ChatType).
StyledString
-> MsgErrorType
-> UTCTime
-> TimeZone
-> CIMeta c 'MDRcv
-> [StyledString]
viewRcvIntegrityError StyledString
from MsgErrorType
err UTCTime
ts TimeZone
tz CIMeta c d
CIMeta c 'MDRcv
meta
          CIRcvGroupEvent {} -> StyledString -> [StyledString]
showRcvItemProhibited StyledString
from
          CIContent d
_ -> StyledString -> [StyledString]
showRcvItem StyledString
from
          where
            from :: StyledString
from = Contact -> StyledString
ttyFromContact Contact
c
        where
          context :: [StyledString]
context =
            [StyledString]
-> (CIQuote 'CTDirect -> [StyledString])
-> Maybe (CIQuote 'CTDirect)
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
              ([StyledString]
-> (CIForwardedFrom -> [StyledString])
-> Maybe CIForwardedFrom
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] CIForwardedFrom -> [StyledString]
forwardedFrom Maybe CIForwardedFrom
itemForwarded)
              (CIDirection 'CTDirect d -> CIQuote 'CTDirect -> [StyledString]
forall (d' :: MsgDirection).
MsgDirectionI d' =>
CIDirection 'CTDirect d' -> CIQuote 'CTDirect -> [StyledString]
directQuote CIDirection c d
CIDirection 'CTDirect d
chatDir)
              Maybe (CIQuote c)
Maybe (CIQuote 'CTDirect)
quotedItem
      GroupChat GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo -> case CIDirection c d
chatDir of
        CIDirection c d
CIGroupSnd -> case CIContent d
content of
          CISndMsgContent MsgContent
mc -> CIMeta c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> [StyledString] -> [StyledString]
hideLive CIMeta c d
meta ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> [StyledString]
withSndFile StyledString
to ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> MsgContent -> [StyledString]
sndMsg StyledString
to [StyledString]
context MsgContent
mc
          CISndGroupInvitation {} -> StyledString -> [StyledString]
showSndItemProhibited StyledString
to
          CIContent d
_ -> StyledString -> [StyledString]
showSndItem StyledString
to
          where
            to :: StyledString
to = GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo
        CIGroupRcv GroupMember
m -> case CIContent d
content of
          CIRcvMsgContent MsgContent
mc -> StyledString -> [StyledString] -> [StyledString]
withRcvFile StyledString
from ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> MsgContent -> [StyledString]
rcvMsg StyledString
from [StyledString]
context MsgContent
mc
          CIRcvIntegrityError MsgErrorType
err -> StyledString
-> MsgErrorType
-> UTCTime
-> TimeZone
-> CIMeta c 'MDRcv
-> [StyledString]
forall (c :: ChatType).
StyledString
-> MsgErrorType
-> UTCTime
-> TimeZone
-> CIMeta c 'MDRcv
-> [StyledString]
viewRcvIntegrityError StyledString
from MsgErrorType
err UTCTime
ts TimeZone
tz CIMeta c d
CIMeta c 'MDRcv
meta
          CIRcvGroupInvitation {} -> StyledString -> [StyledString]
showRcvItemProhibited StyledString
from
          CIRcvModerated {} -> UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz (GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m) [StyledString]
context CIMeta c d
meta [CIContent d -> StyledString
forall {d :: MsgDirection}. CIContent d -> StyledString
plainContent CIContent d
content] Bool
False
          CIRcvBlocked {} -> UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz (GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m) [StyledString]
context CIMeta c d
meta [CIContent d -> StyledString
forall {d :: MsgDirection}. CIContent d -> StyledString
plainContent CIContent d
content] Bool
False
          CIContent d
_ -> StyledString -> [StyledString]
showRcvItem StyledString
from
          where
            from :: StyledString
from = GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> StyledString
ttyFromGroupAttention GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Bool
userMention
        where
          context :: [StyledString]
context =
            [StyledString]
-> (CIQuote 'CTGroup -> [StyledString])
-> Maybe (CIQuote 'CTGroup)
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
              ([StyledString]
-> (CIForwardedFrom -> [StyledString])
-> Maybe CIForwardedFrom
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] CIForwardedFrom -> [StyledString]
forwardedFrom Maybe CIForwardedFrom
itemForwarded)
              (GroupInfo -> CIQuote 'CTGroup -> [StyledString]
groupQuote GroupInfo
g)
              Maybe (CIQuote c)
Maybe (CIQuote 'CTGroup)
quotedItem
      LocalChat NoteFolder
_ -> case CIDirection c d
chatDir of
        CIDirection c d
CILocalSnd -> case CIContent d
content of
          CISndMsgContent MsgContent
mc -> CIMeta c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> [StyledString] -> [StyledString]
hideLive CIMeta c d
meta ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> [StyledString]
withLocalFile StyledString
to ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> MsgContent -> [StyledString]
sndMsg StyledString
to [StyledString]
context MsgContent
mc
          CISndGroupEvent {} -> StyledString -> [StyledString]
showSndItemProhibited StyledString
to
          CIContent d
_ -> StyledString -> [StyledString]
showSndItem StyledString
to
          where
            to :: StyledString
to = StyledString
"* "
        CIDirection c d
CILocalRcv -> case CIContent d
content of
          CIRcvMsgContent MsgContent
mc -> StyledString -> [StyledString] -> [StyledString]
withLocalFile StyledString
from ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString -> [StyledString] -> MsgContent -> [StyledString]
rcvMsg StyledString
from [StyledString]
context MsgContent
mc
          CIRcvIntegrityError MsgErrorType
err -> StyledString
-> MsgErrorType
-> UTCTime
-> TimeZone
-> CIMeta c 'MDRcv
-> [StyledString]
forall (c :: ChatType).
StyledString
-> MsgErrorType
-> UTCTime
-> TimeZone
-> CIMeta c 'MDRcv
-> [StyledString]
viewRcvIntegrityError StyledString
from MsgErrorType
err UTCTime
ts TimeZone
tz CIMeta c d
CIMeta c 'MDRcv
meta
          CIRcvGroupEvent {} -> StyledString -> [StyledString]
showRcvItemProhibited StyledString
from
          CIContent d
_ -> StyledString -> [StyledString]
showRcvItem StyledString
from
          where
            from :: StyledString
from = StyledString
"* "
        where
          context :: [StyledString]
context = [StyledString]
-> (CIForwardedFrom -> [StyledString])
-> Maybe CIForwardedFrom
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] CIForwardedFrom -> [StyledString]
forwardedFrom Maybe CIForwardedFrom
itemForwarded
      ContactRequest {} -> []
      ContactConnection {} -> []
      CInfoInvalidJSON {} -> [StyledString
"invalid chat info"]
    withItemDeleted :: StyledString -> StyledString
withItemDeleted StyledString
item = case ChatItem c d -> Maybe GroupMember -> Maybe ContactName
forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe GroupMember -> Maybe ContactName
chatItemDeletedText ChatItem c d
ci (ChatInfo c -> Maybe GroupMember
forall (c :: ChatType). ChatInfo c -> Maybe GroupMember
chatInfoMembership ChatInfo c
chat) of
      Maybe ContactName
Nothing -> StyledString
item
      Just ContactName
t -> StyledString
item StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Format -> ContactName -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Color -> Format
colored Color
Red) (ContactName
" [" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
t ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"]")
    withGroupMsgForwarded :: StyledString -> StyledString
withGroupMsgForwarded StyledString
item = case Maybe ContactId
forwardedByMember of
      Maybe ContactId
Nothing -> StyledString
item
      Just ContactId
_ -> StyledString
item StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Format -> String -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Color -> Format
colored Color
Yellow) (String
" [>>]" :: String)
    withSndFile :: StyledString -> [StyledString] -> [StyledString]
withSndFile = (StyledString
 -> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString])
-> StyledString -> [StyledString] -> [StyledString]
withFile StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
forall (d :: MsgDirection) (c :: ChatType).
StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
viewSentFileInvitation
    withRcvFile :: StyledString -> [StyledString] -> [StyledString]
withRcvFile = (StyledString
 -> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString])
-> StyledString -> [StyledString] -> [StyledString]
withFile StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
forall (d :: MsgDirection) (c :: ChatType).
StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
viewReceivedFileInvitation
    withLocalFile :: StyledString -> [StyledString] -> [StyledString]
withLocalFile = (StyledString
 -> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString])
-> StyledString -> [StyledString] -> [StyledString]
withFile StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
forall (d :: MsgDirection) (c :: ChatType).
StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
viewLocalFile
    withFile :: (StyledString
 -> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString])
-> StyledString -> [StyledString] -> [StyledString]
withFile StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
view StyledString
dir [StyledString]
l = [StyledString]
-> (CIFile d -> [StyledString])
-> Maybe (CIFile d)
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString]
l (\CIFile d
f -> [StyledString]
l [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
view StyledString
dir CIFile d
f UTCTime
ts TimeZone
tz CIMeta c d
meta) Maybe (CIFile d)
file
    sndMsg :: StyledString -> [StyledString] -> MsgContent -> [StyledString]
sndMsg = (StyledString
 -> [StyledString]
 -> MsgContent
 -> UTCTime
 -> TimeZone
 -> CIMeta c d
 -> [StyledString])
-> StyledString -> [StyledString] -> MsgContent -> [StyledString]
msg StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewSentMessage
    rcvMsg :: StyledString -> [StyledString] -> MsgContent -> [StyledString]
rcvMsg = (StyledString
 -> [StyledString]
 -> MsgContent
 -> UTCTime
 -> TimeZone
 -> CIMeta c d
 -> [StyledString])
-> StyledString -> [StyledString] -> MsgContent -> [StyledString]
msg StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedMessage
    msg :: (StyledString
 -> [StyledString]
 -> MsgContent
 -> UTCTime
 -> TimeZone
 -> CIMeta c d
 -> [StyledString])
-> StyledString -> [StyledString] -> MsgContent -> [StyledString]
msg StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
view StyledString
dir [StyledString]
context MsgContent
mc = case (MsgContent -> ContactName
msgContentText MsgContent
mc, Maybe (CIFile d)
file, [StyledString]
context) of
      (ContactName
"", Just CIFile d
_, []) -> []
      (ContactName
"", Just CIFile {String
fileName :: String
fileName :: forall (d :: MsgDirection). CIFile d -> String
fileName}, [StyledString]
_) -> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
view StyledString
dir [StyledString]
context (ContactName -> MsgContent
MCText (ContactName -> MsgContent) -> ContactName -> MsgContent
forall a b. (a -> b) -> a -> b
$ String -> ContactName
T.pack String
fileName) UTCTime
ts TimeZone
tz CIMeta c d
meta
      (ContactName, Maybe (CIFile d), [StyledString])
_ -> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
view StyledString
dir [StyledString]
context MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta
    showSndItem :: StyledString -> [StyledString]
showSndItem StyledString
to = [StyledString] -> [StyledString]
showItem ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
sentWithTime_ UTCTime
ts TimeZone
tz [StyledString
to StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CIContent d -> StyledString
forall {d :: MsgDirection}. CIContent d -> StyledString
plainContent CIContent d
content] CIMeta c d
meta
    showRcvItem :: StyledString -> [StyledString]
showRcvItem StyledString
from = [StyledString] -> [StyledString]
showItem ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz StyledString
from [] CIMeta c d
meta [CIContent d -> StyledString
forall {d :: MsgDirection}. CIContent d -> StyledString
plainContent CIContent d
content] Bool
False
    showSndItemProhibited :: StyledString -> [StyledString]
showSndItemProhibited StyledString
to = [StyledString] -> [StyledString]
showItem ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
sentWithTime_ UTCTime
ts TimeZone
tz [StyledString
to StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CIContent d -> StyledString
forall {d :: MsgDirection}. CIContent d -> StyledString
plainContent CIContent d
content StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
prohibited] CIMeta c d
meta
    showRcvItemProhibited :: StyledString -> [StyledString]
showRcvItemProhibited StyledString
from = [StyledString] -> [StyledString]
showItem ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz StyledString
from [] CIMeta c d
meta [CIContent d -> StyledString
forall {d :: MsgDirection}. CIContent d -> StyledString
plainContent CIContent d
content StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
prohibited] Bool
False
    showItem :: [StyledString] -> [StyledString]
showItem [StyledString]
ss = if Bool
doShow then [StyledString]
ss else []
    plainContent :: CIContent d -> StyledString
plainContent = ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (CIContent d -> ContactName) -> CIContent d -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CIContent d -> ContactName
forall {d :: MsgDirection}. CIContent d -> ContactName
ciContentToText
    prohibited :: StyledString
prohibited = Format -> String -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Color -> Format
colored Color
Red) (String
"[unexpected chat item created, please report to developers]" :: String)

viewChatItemInfo :: AChatItem -> ChatItemInfo -> TimeZone -> [StyledString]
viewChatItemInfo :: AChatItem -> ChatItemInfo -> TimeZone -> [StyledString]
viewChatItemInfo (AChatItem SChatType c
_ SMsgDirection d
msgDir ChatInfo c
_ ChatItem {meta :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIMeta c d
meta = CIMeta {UTCTime
itemTs :: UTCTime
itemTs :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> UTCTime
itemTs, Maybe CITimed
itemTimed :: Maybe CITimed
itemTimed :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe CITimed
itemTimed, UTCTime
createdAt :: UTCTime
createdAt :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> UTCTime
createdAt}}) ChatItemInfo {[ChatItemVersion]
itemVersions :: [ChatItemVersion]
itemVersions :: ChatItemInfo -> [ChatItemVersion]
itemVersions, Maybe AChatItem
forwardedFromChatItem :: Maybe AChatItem
forwardedFromChatItem :: ChatItemInfo -> Maybe AChatItem
forwardedFromChatItem} TimeZone
tz =
  [StyledString
"sent at: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> UTCTime -> StyledString
ts UTCTime
itemTs]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
receivedAt
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
toBeDeletedAt
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
versions
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
forwardedFrom'
  where
    ts :: UTCTime -> StyledString
ts = String -> StyledString
styleTime (String -> StyledString)
-> (UTCTime -> String) -> UTCTime -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TimeZone -> UTCTime -> String
localTs TimeZone
tz
    receivedAt :: [StyledString]
receivedAt = case SMsgDirection d
msgDir of
      SMsgDirection d
SMDRcv -> [StyledString
"received at: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> UTCTime -> StyledString
ts UTCTime
createdAt]
      SMsgDirection d
SMDSnd -> []
    toBeDeletedAt :: [StyledString]
toBeDeletedAt = case Maybe CITimed
itemTimed Maybe CITimed -> (CITimed -> Maybe UTCTime) -> Maybe UTCTime
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CITimed -> Maybe UTCTime
timedDeleteAt' of
      Just UTCTime
d -> [StyledString
"to be deleted at: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> UTCTime -> StyledString
ts UTCTime
d]
      Maybe UTCTime
Nothing -> []
    versions :: [StyledString]
versions =
      if [ChatItemVersion] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ChatItemVersion]
itemVersions
        then []
        else [StyledString
"message history:"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (ChatItemVersion -> [StyledString])
-> [ChatItemVersion] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ChatItemVersion -> [StyledString]
version [ChatItemVersion]
itemVersions
      where
        version :: ChatItemVersion -> [StyledString]
version ChatItemVersion {MsgContent
msgContent :: MsgContent
msgContent :: ChatItemVersion -> MsgContent
msgContent, UTCTime
itemVersionTs :: UTCTime
itemVersionTs :: ChatItemVersion -> UTCTime
itemVersionTs} = StyledString -> [StyledString] -> [StyledString]
prependFirst (UTCTime -> StyledString
ts UTCTime
itemVersionTs StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
styleTime String
": ") ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ MsgContent -> [StyledString]
ttyMsgContent MsgContent
msgContent
    forwardedFrom' :: [StyledString]
forwardedFrom' =
      case Maybe AChatItem
forwardedFromChatItem of
        Just fwdACI :: AChatItem
fwdACI@(AChatItem SChatType c
_ SMsgDirection d
fwdMsgDir ChatInfo c
fwdChatInfo ChatItem c d
_) ->
          [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"forwarded from: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (ContactName -> ContactName) -> Maybe ContactName -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
", ") Maybe ContactName
fwdDir_ ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
fwdItemId]
          where
            fwdDir_ :: Maybe ContactName
fwdDir_ = case (SMsgDirection d
fwdMsgDir, ChatInfo c
fwdChatInfo) of
              (SMsgDirection d
SMDSnd, DirectChat Contact
ct) -> ContactName -> Maybe ContactName
forall a. a -> Maybe a
Just (ContactName -> Maybe ContactName)
-> ContactName -> Maybe ContactName
forall a b. (a -> b) -> a -> b
$ ContactName
"you @" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
ct
              (SMsgDirection d
SMDRcv, DirectChat Contact
ct) -> ContactName -> Maybe ContactName
forall a. a -> Maybe a
Just (ContactName -> Maybe ContactName)
-> ContactName -> Maybe ContactName
forall a b. (a -> b) -> a -> b
$ ContactName
"@" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
ct
              (SMsgDirection d
SMDSnd, GroupChat GroupInfo
gInfo Maybe GroupChatScopeInfo
_scopeInfo) -> ContactName -> Maybe ContactName
forall a. a -> Maybe a
Just (ContactName -> Maybe ContactName)
-> ContactName -> Maybe ContactName
forall a b. (a -> b) -> a -> b
$ ContactName
"you #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
gInfo
              (SMsgDirection d
SMDRcv, GroupChat GroupInfo
gInfo Maybe GroupChatScopeInfo
_scopeInfo) -> ContactName -> Maybe ContactName
forall a. a -> Maybe a
Just (ContactName -> Maybe ContactName)
-> ContactName -> Maybe ContactName
forall a b. (a -> b) -> a -> b
$ ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
gInfo
              (SMsgDirection d, ChatInfo c)
_ -> Maybe ContactName
forall a. Maybe a
Nothing
            fwdItemId :: ContactName
fwdItemId = ContactName
"chat item id: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> (String -> ContactName
T.pack (String -> ContactName)
-> (ContactId -> String) -> ContactId -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactId -> String
forall a. Show a => a -> String
show (ContactId -> ContactName) -> ContactId -> ContactName
forall a b. (a -> b) -> a -> b
$ AChatItem -> ContactId
aChatItemId AChatItem
fwdACI)
        Maybe AChatItem
_ -> []

localTs :: TimeZone -> UTCTime -> String
localTs :: TimeZone -> UTCTime -> String
localTs TimeZone
tz UTCTime
ts = do
  let localTime :: LocalTime
localTime = TimeZone -> UTCTime -> LocalTime
utcToLocalTime TimeZone
tz UTCTime
ts
      formattedTime :: String
formattedTime = TimeLocale -> String -> LocalTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%Y-%m-%d %H:%M:%S" LocalTime
localTime
  String
formattedTime

viewChatItemStatusUpdated :: AChatItem -> CurrentTime -> TimeZone -> Bool -> Bool -> [StyledString]
viewChatItemStatusUpdated :: AChatItem -> UTCTime -> TimeZone -> Bool -> Bool -> [StyledString]
viewChatItemStatusUpdated (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat item :: ChatItem c d
item@ChatItem {meta :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIMeta c d
meta = CIMeta {CIStatus d
itemStatus :: CIStatus d
itemStatus :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> CIStatus d
itemStatus}}) UTCTime
ts TimeZone
tz Bool
testView Bool
showReceipts =
  case CIStatus d
itemStatus of
    CISSndRcvd MsgReceiptStatus
rcptStatus SndCIStatusProgress
SSPPartial | Bool
testView Bool -> Bool -> Bool
&& Bool
showReceipts ->
      StyledString -> [StyledString] -> [StyledString]
prependFirst (MsgReceiptStatus -> StyledString
viewDeliveryReceiptPartial MsgReceiptStatus
rcptStatus StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ") ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewChatItem ChatInfo c
chat ChatItem c d
item Bool
False UTCTime
ts TimeZone
tz
    CISSndRcvd MsgReceiptStatus
rcptStatus SndCIStatusProgress
SSPComplete | Bool
testView Bool -> Bool -> Bool
&& Bool
showReceipts ->
      StyledString -> [StyledString] -> [StyledString]
prependFirst (MsgReceiptStatus -> StyledString
viewDeliveryReceipt MsgReceiptStatus
rcptStatus StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ") ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewChatItem ChatInfo c
chat ChatItem c d
item Bool
False UTCTime
ts TimeZone
tz
    CIStatus d
_ -> []

viewDeliveryReceiptPartial :: MsgReceiptStatus -> StyledString
viewDeliveryReceiptPartial :: MsgReceiptStatus -> StyledString
viewDeliveryReceiptPartial = \case
  MsgReceiptStatus
MROk -> StyledString
"%"
  MsgReceiptStatus
MRBadMsgHash -> String -> StyledString
ttyError' String
"%!"

viewDeliveryReceipt :: MsgReceiptStatus -> StyledString
viewDeliveryReceipt :: MsgReceiptStatus -> StyledString
viewDeliveryReceipt = \case
  MsgReceiptStatus
MROk -> StyledString
"⩗"
  MsgReceiptStatus
MRBadMsgHash -> String -> StyledString
ttyError' String
"⩗!"

viewItemUpdate :: MsgDirectionI d => ChatInfo c -> ChatItem c d -> Bool -> CurrentTime -> TimeZone -> [StyledString]
viewItemUpdate :: forall (d :: MsgDirection) (c :: ChatType).
MsgDirectionI d =>
ChatInfo c
-> ChatItem c d -> Bool -> UTCTime -> TimeZone -> [StyledString]
viewItemUpdate ChatInfo c
chat ChatItem {CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir, meta :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIMeta c d
meta = meta :: CIMeta c d
meta@CIMeta {Maybe CIForwardedFrom
itemForwarded :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe CIForwardedFrom
itemForwarded :: Maybe CIForwardedFrom
itemForwarded, Bool
itemEdited :: Bool
itemEdited :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> Bool
itemEdited, Maybe Bool
itemLive :: Maybe Bool
itemLive :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe Bool
itemLive}, CIContent d
content :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIContent d
content :: CIContent d
content, Maybe (CIQuote c)
quotedItem :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIQuote c)
quotedItem :: Maybe (CIQuote c)
quotedItem} Bool
liveItems UTCTime
ts TimeZone
tz = case ChatInfo c
chat of
  DirectChat Contact
c -> case CIDirection c d
chatDir of
    CIDirection c d
CIDirectRcv -> case CIContent d
content of
      CIRcvMsgContent MsgContent
mc
        | Maybe Bool
itemLive Maybe Bool -> Maybe Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
liveItems -> []
        | Bool
otherwise -> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedUpdatedMessage StyledString
from [StyledString]
context MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta
      CIContent d
_ -> []
      where
        from :: StyledString
from = if Bool
itemEdited then Contact -> StyledString
ttyFromContactEdited Contact
c else Contact -> StyledString
ttyFromContact Contact
c
    CIDirection c d
CIDirectSnd -> case CIContent d
content of
      CISndMsgContent MsgContent
mc -> CIMeta c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> [StyledString] -> [StyledString]
hideLive CIMeta c d
meta ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewSentMessage StyledString
to [StyledString]
context MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta
      CIContent d
_ -> []
      where
        to :: StyledString
to = if Bool
itemEdited then Contact -> StyledString
ttyToContactEdited' Contact
c else Contact -> StyledString
ttyToContact' Contact
c
    where
      context :: [StyledString]
context =
        [StyledString]
-> (CIQuote 'CTDirect -> [StyledString])
-> Maybe (CIQuote 'CTDirect)
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
          ([StyledString]
-> (CIForwardedFrom -> [StyledString])
-> Maybe CIForwardedFrom
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] CIForwardedFrom -> [StyledString]
forwardedFrom Maybe CIForwardedFrom
itemForwarded)
          (CIDirection 'CTDirect d -> CIQuote 'CTDirect -> [StyledString]
forall (d' :: MsgDirection).
MsgDirectionI d' =>
CIDirection 'CTDirect d' -> CIQuote 'CTDirect -> [StyledString]
directQuote CIDirection c d
CIDirection 'CTDirect d
chatDir)
          Maybe (CIQuote c)
Maybe (CIQuote 'CTDirect)
quotedItem
  GroupChat GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo -> case CIDirection c d
chatDir of
    CIGroupRcv GroupMember
m -> case CIContent d
content of
      CIRcvMsgContent MsgContent
mc
        | Maybe Bool
itemLive Maybe Bool -> Maybe Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
liveItems -> []
        | Bool
otherwise -> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedUpdatedMessage StyledString
from [StyledString]
context MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta
      CIContent d
_ -> []
      where
        from :: StyledString
from = if Bool
itemEdited then GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroupEdited GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m else GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m
    CIDirection c d
CIGroupSnd -> case CIContent d
content of
      CISndMsgContent MsgContent
mc -> CIMeta c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> [StyledString] -> [StyledString]
hideLive CIMeta c d
meta ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewSentMessage StyledString
to [StyledString]
context MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta
      CIContent d
_ -> []
      where
        to :: StyledString
to = if Bool
itemEdited then GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroupEdited GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo else GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo
    where
      context :: [StyledString]
context =
        [StyledString]
-> (CIQuote 'CTGroup -> [StyledString])
-> Maybe (CIQuote 'CTGroup)
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
          ([StyledString]
-> (CIForwardedFrom -> [StyledString])
-> Maybe CIForwardedFrom
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] CIForwardedFrom -> [StyledString]
forwardedFrom Maybe CIForwardedFrom
itemForwarded)
          (GroupInfo -> CIQuote 'CTGroup -> [StyledString]
groupQuote GroupInfo
g)
          Maybe (CIQuote c)
Maybe (CIQuote 'CTGroup)
quotedItem
  ChatInfo c
_ -> []

hideLive :: CIMeta c d -> [StyledString] -> [StyledString]
hideLive :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> [StyledString] -> [StyledString]
hideLive CIMeta {itemLive :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe Bool
itemLive = Just Bool
True} [StyledString]
_ = []
hideLive CIMeta c d
_ [StyledString]
s = [StyledString]
s

viewItemNotChanged :: AChatItem -> [StyledString]
viewItemNotChanged :: AChatItem -> [StyledString]
viewItemNotChanged (AChatItem SChatType c
_ SMsgDirection d
msgDir ChatInfo c
_ ChatItem c d
_) = case SMsgDirection d
msgDir of
  SMsgDirection d
SMDSnd -> [StyledString
"message didn't change"]
  SMsgDirection d
SMDRcv -> []

viewChatItemsDeleted ::
  (forall c d. ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]) ->
  [ChatItemDeletion] ->
  Bool ->
  Bool ->
  UTCTime ->
  TimeZone ->
  Bool ->
  [StyledString]
viewChatItemsDeleted :: (forall (c :: ChatType) (d :: MsgDirection).
 ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString])
-> [ChatItemDeletion]
-> Bool
-> Bool
-> UTCTime
-> TimeZone
-> Bool
-> [StyledString]
viewChatItemsDeleted forall (c :: ChatType) (d :: MsgDirection).
ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted [ChatItemDeletion]
deletions Bool
byUser Bool
timed UTCTime
ts TimeZone
tz Bool
testView = case [ChatItemDeletion]
deletions of
  [ChatItemDeletion (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat ChatItem c d
deletedItem) Maybe AChatItem
toItem] ->
    ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
ChatInfo c -> ChatItem c d -> [StyledString] -> [StyledString]
unmuted ChatInfo c
chat ChatItem c d
deletedItem ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ChatInfo c
-> ChatItem c d
-> Maybe AChatItem
-> Bool
-> Bool
-> UTCTime
-> TimeZone
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
ChatInfo c
-> ChatItem c d
-> Maybe AChatItem
-> Bool
-> Bool
-> UTCTime
-> TimeZone
-> Bool
-> [StyledString]
viewItemDelete ChatInfo c
chat ChatItem c d
deletedItem Maybe AChatItem
toItem Bool
byUser Bool
timed UTCTime
ts TimeZone
tz Bool
testView
  [ChatItemDeletion]
deletions' -> [Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([ChatItemDeletion] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ChatItemDeletion]
deletions') StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" messages deleted"]

viewGroupChatItemsDeleted :: GroupInfo -> [ChatItemId] -> Bool -> Maybe GroupMember -> [StyledString]
viewGroupChatItemsDeleted :: GroupInfo
-> [ContactId] -> Bool -> Maybe GroupMember -> [StyledString]
viewGroupChatItemsDeleted GroupInfo
g [ContactId]
ciIds Bool
byUser Maybe GroupMember
member_ = [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([ContactId] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ContactId]
ciIds) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" messages deleted by " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if Bool
byUser then StyledString
"user" else StyledString
"member" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (GroupMember -> StyledString)
-> Maybe GroupMember
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"" (\GroupMember
m -> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m) Maybe GroupMember
member_]

viewItemDelete :: ChatInfo c -> ChatItem c d -> Maybe AChatItem -> Bool -> Bool -> CurrentTime -> TimeZone -> Bool -> [StyledString]
viewItemDelete :: forall (c :: ChatType) (d :: MsgDirection).
ChatInfo c
-> ChatItem c d
-> Maybe AChatItem
-> Bool
-> Bool
-> UTCTime
-> TimeZone
-> Bool
-> [StyledString]
viewItemDelete ChatInfo c
chat ci :: ChatItem c d
ci@ChatItem {CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir, CIMeta c d
meta :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIMeta c d
meta :: CIMeta c d
meta, content :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIContent d
content = CIContent d
deletedContent} Maybe AChatItem
toItem Bool
byUser Bool
timed UTCTime
ts TimeZone
tz Bool
testView
  | Bool
timed = [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String
"timed message deleted: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactName -> String
T.unpack (CIContent d -> ContactName
forall {d :: MsgDirection}. CIContent d -> ContactName
ciContentToText CIContent d
deletedContent)) | Bool
testView]
  | Bool
byUser = [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"message " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactName -> String
T.unpack (ContactName -> Maybe ContactName -> ContactName
forall a. a -> Maybe a -> a
fromMaybe ContactName
"deleted" Maybe ContactName
deletedText_)] -- deletedText_ Nothing should be impossible here
  | Bool
otherwise = case ChatInfo c
chat of
      DirectChat Contact
c -> case (CIDirection c d
chatDir, CIContent d
deletedContent) of
        (CIDirection c d
CIDirectRcv, CIRcvMsgContent MsgContent
mc) -> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedMessage (Contact -> Maybe ContactName -> StyledString
ttyFromContactDeleted Contact
c Maybe ContactName
deletedText_) [] MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta
        (CIDirection c d, CIContent d)
_ -> [StyledString]
prohibited
      GroupChat GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo -> case CIContent d -> Maybe MsgContent
forall (d :: MsgDirection). CIContent d -> Maybe MsgContent
ciMsgContent CIContent d
deletedContent of
        Just MsgContent
mc ->
          let m :: GroupMember
m = GroupInfo -> ChatItem 'CTGroup d -> GroupMember
forall (d :: MsgDirection).
GroupInfo -> ChatItem 'CTGroup d -> GroupMember
chatItemMember GroupInfo
g ChatItem c d
ChatItem 'CTGroup d
ci
           in StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedMessage (GroupInfo
-> Maybe GroupChatScopeInfo
-> GroupMember
-> Maybe ContactName
-> StyledString
ttyFromGroupDeleted GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Maybe ContactName
deletedText_) [] MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta
        Maybe MsgContent
_ -> [StyledString]
prohibited
      ChatInfo c
_ -> [StyledString]
prohibited
  where
    deletedText_ :: Maybe Text
    deletedText_ :: Maybe ContactName
deletedText_ = case Maybe AChatItem
toItem of
      Maybe AChatItem
Nothing -> ContactName -> Maybe ContactName
forall a. a -> Maybe a
Just ContactName
"deleted"
      Just (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
_ ChatItem c d
ci') -> ChatItem c d -> Maybe GroupMember -> Maybe ContactName
forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe GroupMember -> Maybe ContactName
chatItemDeletedText ChatItem c d
ci' (Maybe GroupMember -> Maybe ContactName)
-> Maybe GroupMember -> Maybe ContactName
forall a b. (a -> b) -> a -> b
$ ChatInfo c -> Maybe GroupMember
forall (c :: ChatType). ChatInfo c -> Maybe GroupMember
chatInfoMembership ChatInfo c
chat
    prohibited :: [StyledString]
prohibited = [Format -> String -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Color -> Format
colored Color
Red) (String
"[unexpected message deletion, please report to developers]" :: String)]

viewItemReaction :: forall c d. Bool -> ChatInfo c -> CIReaction c d -> Bool -> CurrentTime -> TimeZone -> [StyledString]
viewItemReaction :: forall (c :: ChatType) (d :: MsgDirection).
Bool
-> ChatInfo c
-> CIReaction c d
-> Bool
-> UTCTime
-> TimeZone
-> [StyledString]
viewItemReaction Bool
showReactions ChatInfo c
chat CIReaction {CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
CIReaction c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir, chatItem :: forall (c :: ChatType) (d :: MsgDirection).
CIReaction c d -> CChatItem c
chatItem = CChatItem SMsgDirection d
md ChatItem {chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir = CIDirection c d
itemDir, CIContent d
content :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIContent d
content :: CIContent d
content}, UTCTime
sentAt :: UTCTime
sentAt :: forall (c :: ChatType) (d :: MsgDirection).
CIReaction c d -> UTCTime
sentAt, MsgReaction
reaction :: MsgReaction
reaction :: forall (c :: ChatType) (d :: MsgDirection).
CIReaction c d -> MsgReaction
reaction} Bool
added UTCTime
ts TimeZone
tz =
  case (ChatInfo c
chat, CIDirection c d
chatDir) of
    (DirectChat Contact
c, CIDirection c d
CIDirectRcv) -> case CIContent d -> Maybe MsgContent
forall (d :: MsgDirection). CIContent d -> Maybe MsgContent
ciMsgContent CIContent d
content of
      Just MsgContent
mc -> StyledString -> [StyledString] -> [StyledString]
view StyledString
from ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ MsgContent -> [StyledString]
reactionMsg MsgContent
mc
      Maybe MsgContent
_ -> []
      where
        from :: StyledString
from = Contact -> StyledString
ttyFromContact Contact
c
        reactionMsg :: MsgContent -> [StyledString]
reactionMsg MsgContent
mc = MsgContent -> StyledString -> [StyledString]
quoteText MsgContent
mc (StyledString -> [StyledString]) -> StyledString -> [StyledString]
forall a b. (a -> b) -> a -> b
$ if SMsgDirection d -> MsgDirection
forall (d :: MsgDirection). SMsgDirection d -> MsgDirection
toMsgDirection SMsgDirection d
md MsgDirection -> MsgDirection -> Bool
forall a. Eq a => a -> a -> Bool
== MsgDirection
MDSnd then StyledString
">>" else StyledString
">"
    (GroupChat GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo, CIGroupRcv GroupMember
m) -> case CIContent d -> Maybe MsgContent
forall (d :: MsgDirection). CIContent d -> Maybe MsgContent
ciMsgContent CIContent d
content of
      Just MsgContent
mc -> StyledString -> [StyledString] -> [StyledString]
view StyledString
from ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ MsgContent -> [StyledString]
reactionMsg MsgContent
mc
      Maybe MsgContent
_ -> []
      where
        from :: StyledString
from = GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m
        reactionMsg :: MsgContent -> [StyledString]
reactionMsg MsgContent
mc = MsgContent -> StyledString -> [StyledString]
quoteText MsgContent
mc (StyledString -> [StyledString])
-> (GroupMember -> StyledString) -> GroupMember -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe GroupMember -> StyledString
ttyQuotedMember (Maybe GroupMember -> StyledString)
-> (GroupMember -> Maybe GroupMember)
-> GroupMember
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMember -> Maybe GroupMember
forall a. a -> Maybe a
Just (GroupMember -> [StyledString]) -> GroupMember -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> CIDirection 'CTGroup d -> GroupMember
forall (d :: MsgDirection).
GroupInfo -> CIDirection 'CTGroup d -> GroupMember
sentByMember' GroupInfo
g CIDirection c d
CIDirection 'CTGroup d
itemDir
    (LocalChat NoteFolder
_, CIDirection c d
CILocalRcv) -> case CIContent d -> Maybe MsgContent
forall (d :: MsgDirection). CIContent d -> Maybe MsgContent
ciMsgContent CIContent d
content of
      Just MsgContent
mc -> StyledString -> [StyledString] -> [StyledString]
view StyledString
from ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ MsgContent -> [StyledString]
reactionMsg MsgContent
mc
      Maybe MsgContent
_ -> []
      where
        from :: StyledString
from = StyledString
"* "
        reactionMsg :: MsgContent -> [StyledString]
reactionMsg MsgContent
mc = MsgContent -> StyledString -> [StyledString]
quoteText MsgContent
mc (StyledString -> [StyledString]) -> StyledString -> [StyledString]
forall a b. (a -> b) -> a -> b
$ if SMsgDirection d -> MsgDirection
forall (d :: MsgDirection). SMsgDirection d -> MsgDirection
toMsgDirection SMsgDirection d
md MsgDirection -> MsgDirection -> Bool
forall a. Eq a => a -> a -> Bool
== MsgDirection
MDSnd then StyledString
">>" else StyledString
">"
    (ChatInfo c
_, CIDirection c d
CIDirectSnd) -> [StyledString
sentText]
    (ChatInfo c
_, CIDirection c d
CIGroupSnd) -> [StyledString
sentText]
    (ChatInfo c
_, CIDirection c d
CILocalSnd) -> [StyledString
sentText]
    (CInfoInvalidJSON {}, CIDirection c d
_) -> []
  where
    view :: StyledString -> [StyledString] -> [StyledString]
view StyledString
from [StyledString]
msg
      | Bool
showReactions = StyledString
-> [StyledString]
-> StyledString
-> UTCTime
-> TimeZone
-> UTCTime
-> [StyledString]
viewReceivedReaction StyledString
from [StyledString]
msg StyledString
reactionText UTCTime
ts TimeZone
tz UTCTime
sentAt
      | Bool
otherwise = []
    reactionText :: StyledString
reactionText = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ (if Bool
added then String
"+ " else String
"- ") String -> String -> String
forall a. Semigroup a => a -> a -> a
<> [Char
emoji]
    emoji :: Char
emoji = case MsgReaction
reaction of
      MREmoji (MREmojiChar Char
c) -> Char
c
      MsgReaction
_ -> Char
'?'
    sentText :: StyledString
sentText = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ (if Bool
added then String
"added " else String
"removed ") String -> String -> String
forall a. Semigroup a => a -> a -> a
<> [Char
emoji]

viewItemReactions :: ChatItem c d -> [StyledString]
viewItemReactions :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> [StyledString]
viewItemReactions ChatItem {[CIReactionCount]
reactions :: [CIReactionCount]
reactions :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> [CIReactionCount]
reactions} = [StyledString
"      " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [CIReactionCount] -> StyledString
viewReactions [CIReactionCount]
reactions | Bool -> Bool
not ([CIReactionCount] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [CIReactionCount]
reactions)]
  where
    viewReactions :: [CIReactionCount] -> StyledString
viewReactions = [StyledString] -> StyledString
forall a. Monoid a => [a] -> a
mconcat ([StyledString] -> StyledString)
-> ([CIReactionCount] -> [StyledString])
-> [CIReactionCount]
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
intersperse StyledString
" " ([StyledString] -> [StyledString])
-> ([CIReactionCount] -> [StyledString])
-> [CIReactionCount]
-> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CIReactionCount -> StyledString)
-> [CIReactionCount] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map CIReactionCount -> StyledString
viewReaction
    viewReaction :: CIReactionCount -> StyledString
viewReaction CIReactionCount {reaction :: CIReactionCount -> MsgReaction
reaction = MRUnknown {}} = StyledString
"?"
    viewReaction CIReactionCount {reaction :: CIReactionCount -> MsgReaction
reaction = MREmoji (MREmojiChar Char
emoji), Bool
userReacted :: Bool
userReacted :: CIReactionCount -> Bool
userReacted, Int
totalReacted :: Int
totalReacted :: CIReactionCount -> Int
totalReacted} =
      String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain [Char
emoji, Char
' '] StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (if Bool
userReacted then Format -> String -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled Format
Italic else String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain) (Int -> String
forall a. Show a => a -> String
show Int
totalReacted)

viewReactionMembers :: [MemberReaction] -> [StyledString]
viewReactionMembers :: [MemberReaction] -> [StyledString]
viewReactionMembers [MemberReaction]
memberReactions = [Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([MemberReaction] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [MemberReaction]
memberReactions) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" member(s) reacted"]

directQuote :: forall d'. MsgDirectionI d' => CIDirection 'CTDirect d' -> CIQuote 'CTDirect -> [StyledString]
directQuote :: forall (d' :: MsgDirection).
MsgDirectionI d' =>
CIDirection 'CTDirect d' -> CIQuote 'CTDirect -> [StyledString]
directQuote CIDirection 'CTDirect d'
_ CIQuote {content :: forall (c :: ChatType). CIQuote c -> MsgContent
content = MsgContent
qmc, chatDir :: forall (c :: ChatType). CIQuote c -> CIQDirection c
chatDir = CIQDirection 'CTDirect
quoteDir} =
  MsgContent -> StyledString -> [StyledString]
quoteText MsgContent
qmc (StyledString -> [StyledString]) -> StyledString -> [StyledString]
forall a b. (a -> b) -> a -> b
$ if SMsgDirection d' -> MsgDirection
forall (d :: MsgDirection). SMsgDirection d -> MsgDirection
toMsgDirection (forall (d :: MsgDirection). MsgDirectionI d => SMsgDirection d
msgDirection @d') MsgDirection -> MsgDirection -> Bool
forall a. Eq a => a -> a -> Bool
== CIQDirection 'CTDirect -> MsgDirection
forall (c :: ChatType). CIQDirection c -> MsgDirection
quoteMsgDirection CIQDirection 'CTDirect
quoteDir then StyledString
">>" else StyledString
">"

groupQuote :: GroupInfo -> CIQuote 'CTGroup -> [StyledString]
groupQuote :: GroupInfo -> CIQuote 'CTGroup -> [StyledString]
groupQuote GroupInfo
g CIQuote {content :: forall (c :: ChatType). CIQuote c -> MsgContent
content = MsgContent
qmc, chatDir :: forall (c :: ChatType). CIQuote c -> CIQDirection c
chatDir = CIQDirection 'CTGroup
quoteDir} = MsgContent -> StyledString -> [StyledString]
quoteText MsgContent
qmc (StyledString -> [StyledString])
-> (Maybe GroupMember -> StyledString)
-> Maybe GroupMember
-> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe GroupMember -> StyledString
ttyQuotedMember (Maybe GroupMember -> [StyledString])
-> Maybe GroupMember -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupInfo -> CIQDirection 'CTGroup -> Maybe GroupMember
sentByMember GroupInfo
g CIQDirection 'CTGroup
quoteDir

forwardedFrom :: CIForwardedFrom -> [StyledString]
forwardedFrom :: CIForwardedFrom -> [StyledString]
forwardedFrom = \case
  CIForwardedFrom
CIFFUnknown -> [StyledString
"-> forwarded"]
  CIFFContact ContactName
c MsgDirection
MDSnd Maybe ContactId
_ Maybe ContactId
_ -> [StyledString
"<- you @" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (ContactName -> ContactName) -> ContactName -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> ContactName
viewName) ContactName
c]
  CIFFContact ContactName
c MsgDirection
MDRcv Maybe ContactId
_ Maybe ContactId
_ -> [StyledString
"<- @" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (ContactName -> ContactName) -> ContactName -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> ContactName
viewName) ContactName
c]
  CIFFGroup ContactName
g MsgDirection
MDSnd Maybe ContactId
_ Maybe ContactId
_ -> [StyledString
"<- you #" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (ContactName -> ContactName) -> ContactName -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> ContactName
viewName) ContactName
g]
  CIFFGroup ContactName
g MsgDirection
MDRcv Maybe ContactId
_ Maybe ContactId
_ -> [StyledString
"<- #" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (ContactName -> ContactName) -> ContactName -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> ContactName
viewName) ContactName
g]

sentByMember :: GroupInfo -> CIQDirection 'CTGroup -> Maybe GroupMember
sentByMember :: GroupInfo -> CIQDirection 'CTGroup -> Maybe GroupMember
sentByMember GroupInfo {GroupMember
membership :: GroupInfo -> GroupMember
membership :: GroupMember
membership} = \case
  CIQDirection 'CTGroup
CIQGroupSnd -> GroupMember -> Maybe GroupMember
forall a. a -> Maybe a
Just GroupMember
membership
  CIQGroupRcv Maybe GroupMember
m -> Maybe GroupMember
m

sentByMember' :: GroupInfo -> CIDirection 'CTGroup d -> GroupMember
sentByMember' :: forall (d :: MsgDirection).
GroupInfo -> CIDirection 'CTGroup d -> GroupMember
sentByMember' GroupInfo {GroupMember
membership :: GroupInfo -> GroupMember
membership :: GroupMember
membership} = \case
  CIDirection 'CTGroup d
CIGroupSnd -> GroupMember
membership
  CIGroupRcv GroupMember
m -> GroupMember
m

quoteText :: MsgContent -> StyledString -> [StyledString]
quoteText :: MsgContent -> StyledString -> [StyledString]
quoteText MsgContent
qmc StyledString
sentBy = StyledString -> [StyledString] -> [StyledString]
prependFirst (StyledString
sentBy StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ") ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ MsgContent -> [StyledString]
msgPreview MsgContent
qmc

msgPreview :: MsgContent -> [StyledString]
msgPreview :: MsgContent -> [StyledString]
msgPreview = ContactName -> [StyledString]
msgPlain (ContactName -> [StyledString])
-> (MsgContent -> ContactName) -> MsgContent -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> ContactName
preview (ContactName -> ContactName)
-> (MsgContent -> ContactName) -> MsgContent -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MsgContent -> ContactName
msgContentText
  where
    preview :: ContactName -> ContactName
preview ContactName
t
      | ContactName -> Int
T.length ContactName
t Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
120 = ContactName
t
      | Bool
otherwise = Int -> ContactName -> ContactName
T.take Int
120 ContactName
t ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"..."

viewRcvIntegrityError :: StyledString -> MsgErrorType -> CurrentTime -> TimeZone -> CIMeta c 'MDRcv -> [StyledString]
viewRcvIntegrityError :: forall (c :: ChatType).
StyledString
-> MsgErrorType
-> UTCTime
-> TimeZone
-> CIMeta c 'MDRcv
-> [StyledString]
viewRcvIntegrityError StyledString
from MsgErrorType
msgErr UTCTime
ts TimeZone
tz CIMeta c 'MDRcv
meta = UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c 'MDRcv
-> [StyledString]
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz StyledString
from [] CIMeta c 'MDRcv
meta (MsgErrorType -> [StyledString]
viewMsgIntegrityError MsgErrorType
msgErr) Bool
False

viewMsgIntegrityError :: MsgErrorType -> [StyledString]
viewMsgIntegrityError :: MsgErrorType -> [StyledString]
viewMsgIntegrityError MsgErrorType
err = [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
ttyError (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ MsgErrorType -> ContactName
msgIntegrityError MsgErrorType
err]

viewInvalidConnReq :: [StyledString]
viewInvalidConnReq :: [StyledString]
viewInvalidConnReq =
  [ StyledString
"",
    StyledString
"Connection link is invalid, possibly it was created in a previous version.",
    StyledString
"Please ask your contact to check " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/version" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" and update if needed."
  ]

viewConnReqInvitation :: CreatedLinkInvitation -> [StyledString]
viewConnReqInvitation :: CreatedLinkInvitation -> [StyledString]
viewConnReqInvitation (CCLink ConnReqInvitation
cReq Maybe (ConnShortLink 'CMInvitation)
shortLink) =
  [ StyledString
"pass this invitation link to your contact (via another channel): ",
    StyledString
"",
    ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ ByteString
-> (ConnShortLink 'CMInvitation -> ByteString)
-> Maybe (ConnShortLink 'CMInvitation)
-> ByteString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ByteString
cReqStr ConnShortLink 'CMInvitation -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode Maybe (ConnShortLink 'CMInvitation)
shortLink,
    StyledString
"",
    StyledString
"and ask them to connect: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/c <invitation_link_above>"
  ]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<>
      if Maybe (ConnShortLink 'CMInvitation) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (ConnShortLink 'CMInvitation)
shortLink
        then
          [ StyledString
"The invitation link for old clients:",
            ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ByteString
cReqStr
          ]
        else []
  where
    cReqStr :: ByteString
cReqStr = ConnReqInvitation -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode (ConnReqInvitation -> ByteString)
-> ConnReqInvitation -> ByteString
forall a b. (a -> b) -> a -> b
$ ConnReqInvitation -> ConnReqInvitation
simplexChatInvitation ConnReqInvitation
cReq

simplexChatInvitation :: ConnReqInvitation -> ConnReqInvitation
simplexChatInvitation :: ConnReqInvitation -> ConnReqInvitation
simplexChatInvitation (CRInvitationUri ConnReqUriData
crData RcvE2ERatchetParamsUri 'X448
e2e) = ConnReqUriData -> RcvE2ERatchetParamsUri 'X448 -> ConnReqInvitation
CRInvitationUri ConnReqUriData
crData {crScheme = simplexChat} RcvE2ERatchetParamsUri 'X448
e2e

viewContactNotFound :: ContactName -> Maybe (GroupInfo, GroupMember) -> [StyledString]
viewContactNotFound :: ContactName -> Maybe (GroupInfo, GroupMember) -> [StyledString]
viewContactNotFound ContactName
cName Maybe (GroupInfo, GroupMember)
suspectedMember =
  [StyledString
"no contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
cName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
useMessageMember]
  where
    useMessageMember :: StyledString
useMessageMember = case Maybe (GroupInfo, GroupMember)
suspectedMember of
      Just (GroupInfo
g, GroupMember
m) -> StyledString
", use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"@#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
viewMemberName GroupMember
m ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" <your message>")
      Maybe (GroupInfo, GroupMember)
_ -> StyledString
""

viewChatCleared :: AChatInfo -> [StyledString]
viewChatCleared :: AChatInfo -> [StyledString]
viewChatCleared (AChatInfo SChatType c
_ ChatInfo c
chatInfo) = case ChatInfo c
chatInfo of
  DirectChat Contact
ct -> [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": all messages are removed locally ONLY"]
  GroupChat GroupInfo
gi Maybe GroupChatScopeInfo
_scopeInfo -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
gi StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": all messages are removed locally ONLY"]
  LocalChat NoteFolder
_ -> [StyledString
"notes: all messages are removed"]
  ContactRequest UserContactRequest
_ -> []
  ContactConnection PendingContactConnection
_ -> []
  CInfoInvalidJSON {} -> []

viewContactsList :: [Contact] -> [StyledString]
viewContactsList :: [Contact] -> [StyledString]
viewContactsList =
  let getLDN :: Contact -> ContactName
      getLDN :: Contact -> ContactName
getLDN Contact {ContactName
localDisplayName :: Contact -> ContactName
localDisplayName :: ContactName
localDisplayName} = ContactName
localDisplayName
      ldn :: Contact -> ContactName
ldn = ContactName -> ContactName
T.toLower (ContactName -> ContactName)
-> (Contact -> ContactName) -> Contact -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Contact -> ContactName
getLDN
   in (Contact -> StyledString) -> [Contact] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (\Contact
ct -> Contact -> StyledString
ctIncognito Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyFullContact Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
muted' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
alias Contact
ct) ([Contact] -> [StyledString])
-> ([Contact] -> [Contact]) -> [Contact] -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Contact -> ContactName) -> [Contact] -> [Contact]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn Contact -> ContactName
ldn
  where
    muted' :: Contact -> StyledString
muted' Contact {ChatSettings
chatSettings :: Contact -> ChatSettings
chatSettings :: ChatSettings
chatSettings, localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
ldn}
      | ChatSettings -> Bool
chatHasNtfs ChatSettings
chatSettings = StyledString
""
      | Bool
otherwise = StyledString
" (muted, you can " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/unmute @" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
ldn) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"
    alias :: Contact -> StyledString
alias Contact {profile :: Contact -> LocalProfile
profile = LocalProfile {ContactName
localAlias :: ContactName
localAlias :: LocalProfile -> ContactName
localAlias}}
      | ContactName
localAlias ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
"" = StyledString
""
      | Bool
otherwise = StyledString
" (alias: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
localAlias StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"

viewUserContactLinkDeleted :: [StyledString]
viewUserContactLinkDeleted :: [StyledString]
viewUserContactLinkDeleted =
  [ StyledString
"Your chat address is deleted - accepted contacts will remain connected.",
    StyledString
"To create a new chat address use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/ad"
  ]

viewForwardPlan :: Int -> [ChatItemId] -> Maybe ForwardConfirmation -> [StyledString]
viewForwardPlan :: Int -> [ContactId] -> Maybe ForwardConfirmation -> [StyledString]
viewForwardPlan Int
count [ContactId]
itemIds = [StyledString]
-> (ForwardConfirmation -> [StyledString])
-> Maybe ForwardConfirmation
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString
forwardCount] ((ForwardConfirmation -> [StyledString])
 -> Maybe ForwardConfirmation -> [StyledString])
-> (ForwardConfirmation -> [StyledString])
-> Maybe ForwardConfirmation
-> [StyledString]
forall a b. (a -> b) -> a -> b
$ \ForwardConfirmation
fc -> [ForwardConfirmation -> StyledString
confirmation ForwardConfirmation
fc, StyledString
forwardCount]
  where
    confirmation :: ForwardConfirmation -> StyledString
confirmation = \case
      FCFilesNotAccepted [ContactId]
fileIds -> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"Files can be received: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " ((ContactId -> String) -> [ContactId] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ContactId -> String
forall a. Show a => a -> String
show [ContactId]
fileIds)
      FCFilesInProgress Int
cnt -> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"Still receiving " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
cnt String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" file(s)"
      FCFilesMissing Int
cnt -> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show Int
cnt String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" file(s) are missing"
      FCFilesFailed Int
cnt -> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"Receiving " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
cnt String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" file(s) failed"
    forwardCount :: StyledString
forwardCount
      | Int
count Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
len = StyledString
"all messages can be forwarded"
      | Int
len Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = StyledString
"nothing to forward"
      | Bool
otherwise = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show Int
len String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" message(s) out of " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
count String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" can be forwarded"
    len :: Int
len = [ContactId] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ContactId]
itemIds

connReqContact_ :: StyledString -> CreatedLinkContact -> [StyledString]
connReqContact_ :: StyledString -> CreatedLinkContact -> [StyledString]
connReqContact_ StyledString
intro (CCLink ConnReqContact
cReq Maybe (ConnShortLink 'CMContact)
shortLink) =
  [ StyledString
intro,
    StyledString
"",
    ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ ByteString
-> (ConnShortLink 'CMContact -> ByteString)
-> Maybe (ConnShortLink 'CMContact)
-> ByteString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ByteString
cReqStr ConnShortLink 'CMContact -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode Maybe (ConnShortLink 'CMContact)
shortLink,
    StyledString
"",
    StyledString
"Anybody can send you contact requests with: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/c <contact_link_above>",
    StyledString
"to show it again: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/sa",
    StyledString
"to share with your contacts: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/profile_address on",
    StyledString
"to delete it: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/da" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (accepted contacts will remain connected)"
  ]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"The contact link for old clients: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ByteString
cReqStr | Maybe (ConnShortLink 'CMContact) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (ConnShortLink 'CMContact)
shortLink]
  where
    cReqStr :: ByteString
cReqStr = ConnReqContact -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode (ConnReqContact -> ByteString) -> ConnReqContact -> ByteString
forall a b. (a -> b) -> a -> b
$ ConnReqContact -> ConnReqContact
simplexChatContact ConnReqContact
cReq

simplexChatContact :: ConnReqContact -> ConnReqContact
simplexChatContact :: ConnReqContact -> ConnReqContact
simplexChatContact (CRContactUri ConnReqUriData
crData) = ConnReqUriData -> ConnReqContact
CRContactUri ConnReqUriData
crData {crScheme = simplexChat}

simplexChatContact' :: ConnLinkContact -> ConnLinkContact
simplexChatContact' :: ConnLinkContact -> ConnLinkContact
simplexChatContact' = \case
  CLFull (CRContactUri ConnReqUriData
crData) -> ConnReqContact -> ConnLinkContact
forall (m :: ConnectionMode).
ConnectionRequestUri m -> ConnectionLink m
CLFull (ConnReqContact -> ConnLinkContact)
-> ConnReqContact -> ConnLinkContact
forall a b. (a -> b) -> a -> b
$ ConnReqUriData -> ConnReqContact
CRContactUri ConnReqUriData
crData {crScheme = simplexChat}
  l :: ConnLinkContact
l@(CLShort ConnShortLink 'CMContact
_) -> ConnLinkContact
l

-- TODO [short links] show all settings
viewAddressSettings :: AddressSettings -> [StyledString]
viewAddressSettings :: AddressSettings -> [StyledString]
viewAddressSettings AddressSettings {Bool
businessAddress :: Bool
businessAddress :: AddressSettings -> Bool
businessAddress, Maybe AutoAccept
autoAccept :: Maybe AutoAccept
autoAccept :: AddressSettings -> Maybe AutoAccept
autoAccept, Maybe MsgContent
autoReply :: Maybe MsgContent
autoReply :: AddressSettings -> Maybe MsgContent
autoReply} = case Maybe AutoAccept
autoAccept of
  Just AutoAccept {Bool
acceptIncognito :: Bool
acceptIncognito :: AutoAccept -> Bool
acceptIncognito} ->
    (StyledString
"auto_accept on" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
aaInfo)
      StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
-> (MsgContent -> [StyledString])
-> Maybe MsgContent
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (([StyledString
"auto reply:"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<>) ([StyledString] -> [StyledString])
-> (MsgContent -> [StyledString]) -> MsgContent -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MsgContent -> [StyledString]
ttyMsgContent) Maybe MsgContent
autoReply
    where
      aaInfo :: StyledString
aaInfo
        | Bool
businessAddress = StyledString
", business"
        | Bool
acceptIncognito = StyledString
", incognito"
        | Bool
otherwise = StyledString
""
  Maybe AutoAccept
_ -> [StyledString
"auto_accept off"]

groupLink_ :: StyledString -> GroupInfo -> GroupLink -> [StyledString]
groupLink_ :: StyledString -> GroupInfo -> GroupLink -> [StyledString]
groupLink_ StyledString
intro GroupInfo
g GroupLink {connLinkContact :: GroupLink -> CreatedLinkContact
connLinkContact = CCLink ConnReqContact
cReq Maybe (ConnShortLink 'CMContact)
shortLink, GroupMemberRole
acceptMemberRole :: GroupMemberRole
acceptMemberRole :: GroupLink -> GroupMemberRole
acceptMemberRole} =
  [ StyledString
intro,
    StyledString
"",
    ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ ByteString
-> (ConnShortLink 'CMContact -> ByteString)
-> Maybe (ConnShortLink 'CMContact)
-> ByteString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ByteString
cReqStr ConnShortLink 'CMContact -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode Maybe (ConnShortLink 'CMContact)
shortLink,
    StyledString
"",
    StyledString
"Anybody can connect to you and join group as " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMemberRole -> StyledString
showRole GroupMemberRole
acceptMemberRole StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" with: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/c <group_link_above>",
    StyledString
"to show it again: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/show link #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g),
    StyledString
"to delete it: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/delete link #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (joined members will remain connected to you)"
  ]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"The group link for old clients: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ByteString
cReqStr | Maybe (ConnShortLink 'CMContact) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (ConnShortLink 'CMContact)
shortLink]
  where
    cReqStr :: ByteString
cReqStr = ConnReqContact -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode (ConnReqContact -> ByteString) -> ConnReqContact -> ByteString
forall a b. (a -> b) -> a -> b
$ ConnReqContact -> ConnReqContact
simplexChatContact ConnReqContact
cReq

viewGroupLinkDeleted :: GroupInfo -> [StyledString]
viewGroupLinkDeleted :: GroupInfo -> [StyledString]
viewGroupLinkDeleted GroupInfo
g =
  [ StyledString
"Group link is deleted - joined members will remain connected.",
    StyledString
"To create a new group link use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/create link #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g)
  ]

viewSentInvitation :: Maybe Profile -> Bool -> [StyledString]
viewSentInvitation :: Maybe Profile -> Bool -> [StyledString]
viewSentInvitation Maybe Profile
incognitoProfile Bool
testView =
  case Maybe Profile
incognitoProfile of
    Just Profile
profile ->
      if Bool
testView
        then Profile -> StyledString
incognitoProfile' Profile
profile StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
message
        else [StyledString]
message
      where
        message :: [StyledString]
message = [StyledString
"connection request sent incognito!"]
    Maybe Profile
Nothing -> [StyledString
"connection request sent!"]

viewStartedConnectionToContact :: Contact -> Maybe Profile -> Bool -> [StyledString]
viewStartedConnectionToContact :: Contact -> Maybe Profile -> Bool -> [StyledString]
viewStartedConnectionToContact Contact
ct Maybe Profile
incognitoProfile Bool
testView =
  case Maybe Profile
incognitoProfile of
    Just Profile
profile ->
      if Bool
testView
        then Profile -> StyledString
incognitoProfile' Profile
profile StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
message
        else [StyledString]
message
      where
        message :: [StyledString]
message = [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": connection started incognito"]
    Maybe Profile
Nothing -> [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": connection started"]

viewStartedConnectionToGroup :: GroupInfo -> Maybe Profile -> Bool -> [StyledString]
viewStartedConnectionToGroup :: GroupInfo -> Maybe Profile -> Bool -> [StyledString]
viewStartedConnectionToGroup GroupInfo
g Maybe Profile
incognitoProfile Bool
testView =
  case Maybe Profile
incognitoProfile of
    Just Profile
profile ->
      if Bool
testView
        then Profile -> StyledString
incognitoProfile' Profile
profile StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
message
        else [StyledString]
message
      where
        message :: [StyledString]
message = [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": connection started incognito"]
    Maybe Profile
Nothing -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": connection started"]

viewAcceptingContactRequest :: Contact -> [StyledString]
viewAcceptingContactRequest :: Contact -> [StyledString]
viewAcceptingContactRequest Contact
ct
  | Contact -> Bool
contactReady Contact
ct = [Contact -> StyledString
ttyFullContact Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": accepting contact request, you can send messages to contact"]
  | Bool
otherwise = [Contact -> StyledString
ttyFullContact Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": accepting contact request..."]

viewAcceptingBusinessRequest :: GroupInfo -> [StyledString]
viewAcceptingBusinessRequest :: GroupInfo -> [StyledString]
viewAcceptingBusinessRequest GroupInfo
g = [GroupInfo -> StyledString
ttyFullGroup GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": accepting business address request..."]

viewReceivedContactRequest :: ContactName -> Profile -> [StyledString]
viewReceivedContactRequest :: ContactName -> Profile -> [StyledString]
viewReceivedContactRequest ContactName
c Profile {ContactName
fullName :: ContactName
fullName :: Profile -> ContactName
fullName, Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr :: Profile -> Maybe ContactName
shortDescr} =
  [ ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
c ContactName
fullName Maybe ContactName
shortDescr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" wants to connect to you!",
    StyledString
"to accept: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/ac " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
c),
    StyledString
"to reject: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/rc " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
c) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (the sender will NOT be notified)"
  ]

viewGroupCreated :: GroupInfo -> Bool -> [StyledString]
viewGroupCreated :: GroupInfo -> Bool -> [StyledString]
viewGroupCreated GroupInfo
g Bool
testView =
  case GroupInfo -> Maybe LocalProfile
incognitoMembershipProfile GroupInfo
g of
    Just LocalProfile
localProfile
      | Bool
testView -> Profile -> StyledString
incognitoProfile' Profile
profile StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
message
      | Bool
otherwise -> [StyledString]
message
      where
        profile :: Profile
profile = LocalProfile -> Profile
fromLocalProfile LocalProfile
localProfile
        message :: [StyledString]
message =
          [ StyledString
"group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyFullGroup GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is created, your incognito profile for this group is " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Profile -> StyledString
incognitoProfile' Profile
profile,
            StyledString
"to add members use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/create link #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g)
          ]
    Maybe LocalProfile
Nothing ->
      [ StyledString
"group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyFullGroup GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is created",
        StyledString
"to add members use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/a " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" <name>") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" or " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/create link #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g)
      ]

viewCannotResendInvitation :: GroupInfo -> ContactName -> [StyledString]
viewCannotResendInvitation :: GroupInfo -> ContactName -> [StyledString]
viewCannotResendInvitation GroupInfo
g ContactName
c =
  [ ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is already invited to group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g,
    StyledString
"to re-send invitation: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/rm " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
c) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/a " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
c)
  ]

viewDirectMessagesProhibited :: MsgDirection -> Contact -> [StyledString]
viewDirectMessagesProhibited :: MsgDirection -> Contact -> [StyledString]
viewDirectMessagesProhibited MsgDirection
MDSnd Contact
c = [StyledString
"direct messages to indirect contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" are prohibited"]
viewDirectMessagesProhibited MsgDirection
MDRcv Contact
c = [StyledString
"received prohibited direct message from indirect contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (discarded)"]

viewUserJoinedGroup :: GroupInfo -> [StyledString]
viewUserJoinedGroup :: GroupInfo -> [StyledString]
viewUserJoinedGroup g :: GroupInfo
g@GroupInfo {GroupMember
membership :: GroupInfo -> GroupMember
membership :: GroupMember
membership} =
  case GroupInfo -> Maybe LocalProfile
incognitoMembershipProfile GroupInfo
g of
    Just LocalProfile
mp -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you joined the group incognito as " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Profile -> StyledString
incognitoProfile' (LocalProfile -> Profile
fromLocalProfile LocalProfile
mp) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
pendingApproval_]
    Maybe LocalProfile
Nothing -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you joined the group" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
pendingApproval_]
  where
    pendingApproval_ :: StyledString
pendingApproval_ = case GroupMember -> GroupMemberStatus
memberStatus GroupMember
membership of
      GroupMemberStatus
GSMemPendingApproval -> StyledString
", pending approval"
      GroupMemberStatus
GSMemPendingReview -> StyledString
", connecting to group moderators for admission to group"
      GroupMemberStatus
_ -> StyledString
""

viewJoinedGroupMember :: GroupInfo -> GroupMember -> [StyledString]
viewJoinedGroupMember :: GroupInfo -> GroupMember -> [StyledString]
viewJoinedGroupMember g :: GroupInfo
g@GroupInfo {ContactId
groupId :: ContactId
groupId :: GroupInfo -> ContactId
groupId} m :: GroupMember
m@GroupMember {ContactId
groupMemberId :: GroupMember -> ContactId
groupMemberId :: ContactId
groupMemberId, GroupMemberStatus
memberStatus :: GroupMember -> GroupMemberStatus
memberStatus :: GroupMemberStatus
memberStatus} = case GroupMemberStatus
memberStatus of
  GroupMemberStatus
GSMemPendingApproval ->
    [ (GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" connected and pending approval, ")
      StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/_accept member #" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
groupId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
groupMemberId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" <role>") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to accept member")
    ]
  GroupMemberStatus
GSMemPendingReview -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" connected and pending review"]
  GroupMemberStatus
_ -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" joined the group"]

viewMemberAccepted :: GroupInfo -> GroupMember -> [StyledString]
viewMemberAccepted :: GroupInfo -> GroupMember -> [StyledString]
viewMemberAccepted GroupInfo
g m :: GroupMember
m@GroupMember {GroupMemberStatus
memberStatus :: GroupMember -> GroupMemberStatus
memberStatus :: GroupMemberStatus
memberStatus} = case GroupMemberStatus
memberStatus of
  GroupMemberStatus
GSMemPendingReview -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" accepted and pending review (will introduce moderators)"]
  GroupMemberStatus
_ -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" accepted"]

viewSupportChatRead :: GroupInfo -> GroupMember -> [StyledString]
viewSupportChatRead :: GroupInfo -> GroupMember -> [StyledString]
viewSupportChatRead g :: GroupInfo
g@GroupInfo {membership :: GroupInfo -> GroupMember
membership = GroupMember {groupMemberId :: GroupMember -> ContactId
groupMemberId = ContactId
membershipId}} GroupMember
m
  | GroupMember -> ContactId
groupMemberId' GroupMember
m ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
membershipId = [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": support chat read"]
  | Bool
otherwise = [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" support chat read"]

viewMemberAcceptedByOther :: GroupInfo -> GroupMember -> GroupMember -> [StyledString]
viewMemberAcceptedByOther :: GroupInfo -> GroupMember -> GroupMember -> [StyledString]
viewMemberAcceptedByOther GroupInfo
g GroupMember
acceptingMember m :: GroupMember
m@GroupMember {GroupMemberCategory
memberCategory :: GroupMemberCategory
memberCategory :: GroupMember -> GroupMemberCategory
memberCategory, GroupMemberStatus
memberStatus :: GroupMember -> GroupMemberStatus
memberStatus :: GroupMemberStatus
memberStatus} = case GroupMemberCategory
memberCategory of
  GroupMemberCategory
GCUserMember -> case GroupMemberStatus
memberStatus of
    GroupMemberStatus
GSMemPendingReview -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
acceptingMember StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" accepted you to the group, pending review"]
    GroupMemberStatus
_ -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
acceptingMember StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" accepted you to the group [warning - unexpected]"]
  GroupMemberCategory
GCInviteeMember -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
acceptingMember StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" accepted " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to the group (will introduce remaining members)"]
  GroupMemberCategory
_ -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
acceptingMember StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" accepted " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to the group"]

viewJoinedGroupMemberConnecting :: GroupInfo -> GroupMember -> GroupMember -> [StyledString]
viewJoinedGroupMemberConnecting :: GroupInfo -> GroupMember -> GroupMember -> [StyledString]
viewJoinedGroupMemberConnecting g :: GroupInfo
g@GroupInfo {ContactId
groupId :: GroupInfo -> ContactId
groupId :: ContactId
groupId} GroupMember
host m :: GroupMember
m@GroupMember {ContactId
groupMemberId :: GroupMember -> ContactId
groupMemberId :: ContactId
groupMemberId, GroupMemberStatus
memberStatus :: GroupMember -> GroupMemberStatus
memberStatus :: GroupMemberStatus
memberStatus} = case GroupMemberStatus
memberStatus of
  GroupMemberStatus
GSMemPendingReview ->
    [ (GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
host StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" added " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyFullMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to the group (connecting and pending review...), ")
      StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/_accept member #" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
groupId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
groupMemberId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" <role>") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to accept member")
    ]
  GroupMemberStatus
_ -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
host StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" added " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyFullMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to the group (connecting...)"]

viewConnectedToGroupMember :: GroupInfo -> GroupMember -> [StyledString]
viewConnectedToGroupMember :: GroupInfo -> GroupMember -> [StyledString]
viewConnectedToGroupMember g :: GroupInfo
g@GroupInfo {ContactId
groupId :: GroupInfo -> ContactId
groupId :: ContactId
groupId} m :: GroupMember
m@GroupMember {ContactId
groupMemberId :: GroupMember -> ContactId
groupMemberId :: ContactId
groupMemberId, GroupMemberStatus
memberStatus :: GroupMember -> GroupMemberStatus
memberStatus :: GroupMemberStatus
memberStatus} = case GroupMemberStatus
memberStatus of
  GroupMemberStatus
GSMemPendingReview ->
    [ (GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
connectedMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is connected and pending review, ")
      StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/_accept member #" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
groupId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
groupMemberId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" <role>") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to accept member")
    ]
  GroupMemberStatus
_ -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
connectedMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is connected"]

viewReceivedGroupInvitation :: GroupInfo -> Contact -> GroupMemberRole -> [StyledString]
viewReceivedGroupInvitation :: GroupInfo -> Contact -> GroupMemberRole -> [StyledString]
viewReceivedGroupInvitation GroupInfo
g Contact
c GroupMemberRole
role =
  GroupInfo -> StyledString
ttyFullGroup GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" invites you to join the group as " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (GroupMemberRole -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode GroupMemberRole
role)
    StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: case GroupInfo -> Maybe LocalProfile
incognitoMembershipProfile GroupInfo
g of
      Just LocalProfile
mp -> [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/j " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to join incognito as " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Profile -> StyledString
incognitoProfile' (LocalProfile -> Profile
fromLocalProfile LocalProfile
mp)]
      Maybe LocalProfile
Nothing -> [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/j " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to accept"]

groupPreserved :: GroupInfo -> [StyledString]
groupPreserved :: GroupInfo -> [StyledString]
groupPreserved GroupInfo
g = [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/d #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to delete the group"]

connectedMember :: GroupMember -> StyledString
connectedMember :: GroupMember -> StyledString
connectedMember GroupMember
m = case GroupMember -> GroupMemberCategory
memberCategory GroupMember
m of
  GroupMemberCategory
GCPreMember -> StyledString
"member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyFullMember GroupMember
m
  GroupMemberCategory
GCPostMember -> StyledString
"new member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m -- without fullName as as it was shown in joinedGroupMemberConnecting
  GroupMemberCategory
_ -> StyledString
"member " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m -- these case is not used

viewMemberRoleChanged :: GroupInfo -> GroupMember -> GroupMember -> GroupMemberRole -> GroupMemberRole -> [StyledString]
viewMemberRoleChanged :: GroupInfo
-> GroupMember
-> GroupMember
-> GroupMemberRole
-> GroupMemberRole
-> [StyledString]
viewMemberRoleChanged g :: GroupInfo
g@GroupInfo {GroupMember
membership :: GroupInfo -> GroupMember
membership :: GroupMember
membership} GroupMember
by GroupMember
m GroupMemberRole
r GroupMemberRole
r'
  | GroupMemberRole
r GroupMemberRole -> GroupMemberRole -> Bool
forall a. Eq a => a -> a -> Bool
== GroupMemberRole
r' = [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": member role did not change"]
  | GroupMember -> ContactId
groupMemberId' GroupMember
membership ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
memId = StyledString -> [StyledString]
view StyledString
"your role"
  | GroupMember -> ContactId
groupMemberId' GroupMember
by ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
memId = StyledString -> [StyledString]
view StyledString
"the role"
  | Bool
otherwise = StyledString -> [StyledString]
view (StyledString -> [StyledString]) -> StyledString -> [StyledString]
forall a b. (a -> b) -> a -> b
$ StyledString
"the role of " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m
  where
    memId :: ContactId
memId = GroupMember -> ContactId
groupMemberId' GroupMember
m
    view :: StyledString -> [StyledString]
view StyledString
s = [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
by StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" changed " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
s StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" from " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMemberRole -> StyledString
showRole GroupMemberRole
r StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMemberRole -> StyledString
showRole GroupMemberRole
r']

viewMemberRoleUserChanged :: GroupInfo -> [GroupMember] -> GroupMemberRole -> [StyledString]
viewMemberRoleUserChanged :: GroupInfo -> [GroupMember] -> GroupMemberRole -> [StyledString]
viewMemberRoleUserChanged GroupInfo
g [GroupMember]
members GroupMemberRole
r = case [GroupMember]
members of
  [GroupMember
m] -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you changed the role of " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMemberRole -> StyledString
showRole GroupMemberRole
r]
  [GroupMember]
mems' -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you changed the role of " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([GroupMember] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [GroupMember]
mems') StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" members to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMemberRole -> StyledString
showRole GroupMemberRole
r]

viewMemberBlockedForAll :: GroupInfo -> GroupMember -> GroupMember -> Bool -> [StyledString]
viewMemberBlockedForAll :: GroupInfo -> GroupMember -> GroupMember -> Bool -> [StyledString]
viewMemberBlockedForAll GroupInfo
g GroupMember
by GroupMember
m Bool
blocked =
  [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
by StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (if Bool
blocked then StyledString
"blocked" else StyledString
"unblocked") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m]

viewMembersBlockedForAllUser :: GroupInfo -> [GroupMember] -> Bool -> [StyledString]
viewMembersBlockedForAllUser :: GroupInfo -> [GroupMember] -> Bool -> [StyledString]
viewMembersBlockedForAllUser GroupInfo
g [GroupMember]
members Bool
blocked = case [GroupMember]
members of
  [GroupMember
m] -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (if Bool
blocked then StyledString
"blocked" else StyledString
"unblocked") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m]
  [GroupMember]
mems' -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (if Bool
blocked then StyledString
"blocked" else StyledString
"unblocked") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([GroupMember] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [GroupMember]
mems') StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" members"]

showRole :: GroupMemberRole -> StyledString
showRole :: GroupMemberRole -> StyledString
showRole = ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString)
-> (GroupMemberRole -> ByteString)
-> GroupMemberRole
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberRole -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode

viewGroupMembers :: Group -> [StyledString]
viewGroupMembers :: Group -> [StyledString]
viewGroupMembers (Group GroupInfo {GroupMember
membership :: GroupInfo -> GroupMember
membership :: GroupMember
membership} [GroupMember]
members) = (GroupMember -> StyledString) -> [GroupMember] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map GroupMember -> StyledString
groupMember ([GroupMember] -> [StyledString])
-> ([GroupMember] -> [GroupMember])
-> [GroupMember]
-> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GroupMember -> Bool) -> [GroupMember] -> [GroupMember]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (GroupMember -> Bool) -> GroupMember -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMember -> Bool
removedOrLeft) ([GroupMember] -> [StyledString])
-> [GroupMember] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ GroupMember
membership GroupMember -> [GroupMember] -> [GroupMember]
forall a. a -> [a] -> [a]
: [GroupMember]
members
  where
    removedOrLeft :: GroupMember -> Bool
removedOrLeft GroupMember
m = let s :: GroupMemberStatus
s = GroupMember -> GroupMemberStatus
memberStatus GroupMember
m in GroupMemberStatus
s GroupMemberStatus -> GroupMemberStatus -> Bool
forall a. Eq a => a -> a -> Bool
== GroupMemberStatus
GSMemRejected Bool -> Bool -> Bool
|| GroupMemberStatus
s GroupMemberStatus -> GroupMemberStatus -> Bool
forall a. Eq a => a -> a -> Bool
== GroupMemberStatus
GSMemRemoved Bool -> Bool -> Bool
|| GroupMemberStatus
s GroupMemberStatus -> GroupMemberStatus -> Bool
forall a. Eq a => a -> a -> Bool
== GroupMemberStatus
GSMemLeft
    groupMember :: GroupMember -> StyledString
groupMember GroupMember
m = GroupMember -> StyledString
memIncognito GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyFullMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ [GroupMember -> String
role GroupMember
m] [String] -> [String] -> [String]
forall a. Semigroup a => a -> a -> a
<> GroupMember -> [String]
forall {a}. IsString a => GroupMember -> [a]
category GroupMember
m [String] -> [String] -> [String]
forall a. Semigroup a => a -> a -> a
<> GroupMember -> [String]
forall {a}. IsString a => GroupMember -> [a]
status GroupMember
m [String] -> [String] -> [String]
forall a. Semigroup a => a -> a -> a
<> GroupMember -> [String]
forall {a}. IsString a => GroupMember -> [a]
muted GroupMember
m)
    role :: GroupMember -> String
    role :: GroupMember -> String
role GroupMember {GroupMemberRole
memberRole :: GroupMemberRole
memberRole :: GroupMember -> GroupMemberRole
memberRole} = ByteString -> String
B.unpack (ByteString -> String) -> ByteString -> String
forall a b. (a -> b) -> a -> b
$ GroupMemberRole -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode GroupMemberRole
memberRole
    category :: GroupMember -> [a]
category GroupMember
m = case GroupMember -> GroupMemberCategory
memberCategory GroupMember
m of
      GroupMemberCategory
GCUserMember -> [a
"you"]
      GroupMemberCategory
GCInviteeMember -> [a
"invited"]
      GroupMemberCategory
GCHostMember -> [a
"host"]
      GroupMemberCategory
_ -> []
    status :: GroupMember -> [a]
status GroupMember
m = case GroupMember -> GroupMemberStatus
memberStatus GroupMember
m of
      GroupMemberStatus
GSMemRejected -> [a
"rejected"]
      GroupMemberStatus
GSMemRemoved -> [a
"removed"]
      GroupMemberStatus
GSMemLeft -> [a
"left"]
      GroupMemberStatus
GSMemUnknown -> [a
"status unknown"]
      GroupMemberStatus
GSMemInvited -> [a
"not yet joined"]
      GroupMemberStatus
GSMemConnected -> [a
"connected"]
      GroupMemberStatus
GSMemComplete -> [a
"connected"]
      GroupMemberStatus
GSMemCreator -> [a
"created group"]
      GroupMemberStatus
_ -> []
    muted :: GroupMember -> [a]
muted GroupMember
m
      | GroupMember -> Bool
blockedByAdmin GroupMember
m = [a
"blocked by admin"]
      | Bool -> Bool
not (GroupMemberSettings -> Bool
showMessages (GroupMemberSettings -> Bool) -> GroupMemberSettings -> Bool
forall a b. (a -> b) -> a -> b
$ GroupMember -> GroupMemberSettings
memberSettings GroupMember
m) = [a
"blocked"]
      | Bool
otherwise = []

viewMemberSupportChats :: GroupInfo -> [GroupMember] -> [StyledString]
viewMemberSupportChats :: GroupInfo -> [GroupMember] -> [StyledString]
viewMemberSupportChats GroupInfo {membership :: GroupInfo -> GroupMember
membership = membership :: GroupMember
membership@GroupMember {memberRole :: GroupMember -> GroupMemberRole
memberRole = GroupMemberRole
membershipRole}, Int
membersRequireAttention :: Int
membersRequireAttention :: GroupInfo -> Int
membersRequireAttention} [GroupMember]
ms =
  [StyledString]
memsAttention [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
support [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (GroupMember -> StyledString) -> [GroupMember] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map GroupMember -> StyledString
groupMember [GroupMember]
ms
  where
    memsAttention :: [StyledString]
memsAttention
      | GroupMemberRole
membershipRole GroupMemberRole -> GroupMemberRole -> Bool
forall a. Ord a => a -> a -> Bool
>= GroupMemberRole
GRModerator = [StyledString
"members require attention: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow Int
membersRequireAttention]
      | Bool
otherwise = []
    support :: [StyledString]
support = case GroupMember -> Maybe GroupSupportChat
supportChat GroupMember
membership of
      Just GroupSupportChat
sc -> [StyledString
"support: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupSupportChat -> StyledString
chatStats GroupSupportChat
sc]
      Maybe GroupSupportChat
Nothing -> []
    groupMember :: GroupMember -> StyledString
groupMember m :: GroupMember
m@GroupMember {Maybe GroupSupportChat
supportChat :: GroupMember -> Maybe GroupSupportChat
supportChat :: Maybe GroupSupportChat
supportChat} = case Maybe GroupSupportChat
supportChat of
      Just GroupSupportChat
sc -> GroupMember -> StyledString
memIncognito GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyFullMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
" (id " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow (GroupMember -> ContactId
groupMemberId' GroupMember
m) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"): ") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupSupportChat -> StyledString
chatStats GroupSupportChat
sc
      Maybe GroupSupportChat
Nothing -> StyledString
""
    chatStats :: GroupSupportChat -> StyledString
chatStats GroupSupportChat {ContactId
unread :: ContactId
unread :: GroupSupportChat -> ContactId
unread, ContactId
memberAttention :: ContactId
memberAttention :: GroupSupportChat -> ContactId
memberAttention, ContactId
mentions :: ContactId
mentions :: GroupSupportChat -> ContactId
mentions} =
      StyledString
"unread: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
unread StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", require attention: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
memberAttention StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", mentions: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
mentions

viewContactConnected :: Contact -> Maybe Profile -> Bool -> [StyledString]
viewContactConnected :: Contact -> Maybe Profile -> Bool -> [StyledString]
viewContactConnected Contact
ct Maybe Profile
userIncognitoProfile Bool
testView =
  case Maybe Profile
userIncognitoProfile of
    Just Profile
profile ->
      if Bool
testView
        then Profile -> StyledString
incognitoProfile' Profile
profile StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
message
        else [StyledString]
message
      where
        message :: [StyledString]
message =
          [ Contact -> StyledString
ttyFullContact Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": contact is connected, your incognito profile for this contact is " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Profile -> StyledString
incognitoProfile' Profile
profile,
            StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/i " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
ct) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to print out this incognito profile again"
          ]
    Maybe Profile
Nothing ->
      [Contact -> StyledString
ttyFullContact Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": contact is connected"]

viewGroupsList :: [GroupInfo] -> [StyledString]
viewGroupsList :: [GroupInfo] -> [StyledString]
viewGroupsList [] = [StyledString
"you have no groups!", StyledString
"to create: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/g <name>"]
viewGroupsList [GroupInfo]
gs = (GroupInfo -> StyledString) -> [GroupInfo] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map GroupInfo -> StyledString
groupSS ([GroupInfo] -> [StyledString]) -> [GroupInfo] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (GroupInfo -> ContactName) -> [GroupInfo] -> [GroupInfo]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn GroupInfo -> ContactName
ldn_ [GroupInfo]
gs
  where
    ldn_ :: GroupInfo -> Text
    ldn_ :: GroupInfo -> ContactName
ldn_ GroupInfo {ContactName
localDisplayName :: GroupInfo -> ContactName
localDisplayName :: ContactName
localDisplayName} = ContactName -> ContactName
T.toLower ContactName
localDisplayName
    groupSS :: GroupInfo -> StyledString
groupSS g :: GroupInfo
g@GroupInfo {GroupMember
membership :: GroupInfo -> GroupMember
membership :: GroupMember
membership, chatSettings :: GroupInfo -> ChatSettings
chatSettings = ChatSettings {MsgFilter
enableNtfs :: ChatSettings -> MsgFilter
enableNtfs :: MsgFilter
enableNtfs}, groupSummary :: GroupInfo -> GroupSummary
groupSummary = GroupSummary {ContactId
currentMembers :: ContactId
currentMembers :: GroupSummary -> ContactId
currentMembers}} =
      case GroupMember -> GroupMemberStatus
memberStatus GroupMember
membership of
        GroupMemberStatus
GSMemInvited -> GroupInfo -> StyledString
groupInvitation' GroupInfo
g
        GroupMemberStatus
s -> GroupInfo -> StyledString
membershipIncognito GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyFullGroup GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMemberStatus -> StyledString
viewMemberStatus GroupMemberStatus
s StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
alias GroupInfo
g
      where
        viewMemberStatus :: GroupMemberStatus -> StyledString
viewMemberStatus = \case
          GroupMemberStatus
GSMemRejected -> StyledString -> StyledString
delete StyledString
"you are rejected"
          GroupMemberStatus
GSMemRemoved -> StyledString -> StyledString
delete StyledString
"you are removed"
          GroupMemberStatus
GSMemLeft -> StyledString -> StyledString
delete StyledString
"you left"
          GroupMemberStatus
GSMemGroupDeleted -> StyledString -> StyledString
delete StyledString
"group deleted"
          GroupMemberStatus
_ -> StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
memberCount StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
viewNtf StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"
            where
              viewNtf :: StyledString
viewNtf = case MsgFilter
enableNtfs of
                MsgFilter
MFAll -> StyledString
""
                MsgFilter
MFNone -> StyledString
", muted, " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
unmute
                MsgFilter
MFMentions -> StyledString
", mentions only, " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
unmute
              unmute :: StyledString
unmute = StyledString
"you can " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/unmute #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g)
        delete :: StyledString -> StyledString
delete StyledString
reason = StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
reason StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", delete local copy: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/d #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"
        memberCount :: StyledString
memberCount = ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
currentMembers StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" member" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if ContactId
currentMembers ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
1 then StyledString
"" else StyledString
"s"
        alias :: GroupInfo -> StyledString
alias GroupInfo {ContactName
localAlias :: ContactName
localAlias :: GroupInfo -> ContactName
localAlias}
          | ContactName
localAlias ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
"" = StyledString
""
          | Bool
otherwise = StyledString
" (alias: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
localAlias StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"

viewSentGroupInvitation :: GroupInfo -> Contact -> [StyledString]
viewSentGroupInvitation :: GroupInfo -> Contact -> [StyledString]
viewSentGroupInvitation GroupInfo
g Contact
c = case Contact -> Maybe Connection
contactConn Contact
c of
  Just Connection {Bool
viaGroupLink :: Bool
viaGroupLink :: Connection -> Bool
viaGroupLink}
    | Bool
viaGroupLink -> [Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" invited to group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" via your group link"]
    | Bool
otherwise -> [StyledString
"invitation to join the group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" sent to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
c]
  Maybe Connection
Nothing -> []

groupInvitation' :: GroupInfo -> StyledString
groupInvitation' :: GroupInfo -> StyledString
groupInvitation' g :: GroupInfo
g@GroupInfo {localDisplayName :: GroupInfo -> ContactName
localDisplayName = ContactName
ldn, groupProfile :: GroupInfo -> GroupProfile
groupProfile = GroupProfile {ContactName
fullName :: ContactName
fullName :: GroupProfile -> ContactName
fullName, Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr :: GroupProfile -> Maybe ContactName
shortDescr}} =
  ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
ldn)
    StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName -> Maybe ContactName -> StyledString
optFullName ContactName
ldn ContactName
fullName Maybe ContactName
shortDescr
    StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" - you are invited ("
    StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/j " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
ldn)
    StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
joinText
    StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/d #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
ldn)
    StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to delete invitation)"
  where
    joinText :: StyledString
joinText = case GroupInfo -> Maybe LocalProfile
incognitoMembershipProfile GroupInfo
g of
      Just LocalProfile
mp -> StyledString
" to join as " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Profile -> StyledString
incognitoProfile' (LocalProfile -> Profile
fromLocalProfile LocalProfile
mp) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", "
      Maybe LocalProfile
Nothing -> StyledString
" to join, "

viewNewMemberContactReceivedInv :: User -> Contact -> GroupInfo -> GroupMember -> [StyledString]
viewNewMemberContactReceivedInv :: User -> Contact -> GroupInfo -> GroupMember -> [StyledString]
viewNewMemberContactReceivedInv User
user ct :: Contact
ct@Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} GroupInfo
g GroupMember
m
  | BoolDef -> Bool
isTrue (User -> BoolDef
autoAcceptMemberContacts User
user) =
      [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is creating direct contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" with you"]
  | Bool
otherwise =
      [ GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" requests to create direct contact with you",
        StyledString
"to accept: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/accept_member_contact @" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
c),
        StyledString
"to reject: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/delete @" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
c) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (the sender will NOT be notified)"
      ]

viewContactAndMemberAssociated :: Contact -> GroupInfo -> GroupMember -> Contact -> [StyledString]
viewContactAndMemberAssociated :: Contact -> GroupInfo -> GroupMember -> Contact -> [StyledString]
viewContactAndMemberAssociated Contact
ct GroupInfo
g GroupMember
m Contact
ct' =
  [ StyledString
"contact and member are merged: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m,
    StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyToContact' Contact
ct' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"<message>" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to send messages"
  ]

viewUserProfile :: Profile -> [StyledString]
viewUserProfile :: Profile -> [StyledString]
viewUserProfile Profile {ContactName
displayName :: ContactName
displayName :: Profile -> ContactName
displayName, ContactName
fullName :: Profile -> ContactName
fullName :: ContactName
fullName, Maybe ContactName
shortDescr :: Profile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr, Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType :: Profile -> Maybe ChatPeerType
peerType, Maybe Preferences
preferences :: Maybe Preferences
preferences :: Profile -> Maybe Preferences
preferences} =
  [ StyledString
"user profile: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
displayName ContactName
fullName Maybe ContactName
shortDescr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
bot,
    StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/p <name> [<bio>]" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to change it"
  ]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. [a] -> [a] -> [a]
++ [StyledString]
viewCommands
  where
    viewCommands :: [StyledString]
viewCommands = case Maybe Preferences
preferences of
      Just Preferences {commands :: Preferences -> Maybe [ChatBotCommand]
commands = Just [ChatBotCommand]
cmds} | Maybe ChatPeerType
peerType Maybe ChatPeerType -> Maybe ChatPeerType -> Bool
forall a. Eq a => a -> a -> Bool
== ChatPeerType -> Maybe ChatPeerType
forall a. a -> Maybe a
Just ChatPeerType
CPTBot Bool -> Bool -> Bool
&& Bool -> Bool
not ([ChatBotCommand] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ChatBotCommand]
cmds) ->
        (StyledString
"Bot commands:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (ChatBotCommand -> [StyledString])
-> [ChatBotCommand] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ContactName -> ChatBotCommand -> [StyledString]
viewCommand ContactName
"") [ChatBotCommand]
cmds)
          [StyledString] -> [StyledString] -> [StyledString]
forall a. [a] -> [a] -> [a]
++ [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/set bot commands ..." StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" or " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/delete bot commands"]
      Maybe Preferences
_ -> []
    viewCommand :: ContactName -> ChatBotCommand -> [StyledString]
viewCommand ContactName
indent = \case
      CBCCommand {ContactName
label :: ContactName
label :: ChatBotCommand -> ContactName
label, ContactName
keyword :: ContactName
keyword :: ChatBotCommand -> ContactName
keyword, Maybe ContactName
params :: Maybe ContactName
params :: ChatBotCommand -> Maybe ContactName
params} ->
        [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
indent ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
quoted ContactName
label ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
":/" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
quoted (ContactName
keyword ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (ContactName -> ContactName) -> Maybe ContactName -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<>) Maybe ContactName
params)]
      CBCMenu {ContactName
label :: ChatBotCommand -> ContactName
label :: ContactName
label, [ChatBotCommand]
commands :: [ChatBotCommand]
commands :: ChatBotCommand -> [ChatBotCommand]
commands} ->
        (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName
indent ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
quoted ContactName
label ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
":{") StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (ChatBotCommand -> [StyledString])
-> [ChatBotCommand] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (ContactName -> ChatBotCommand -> [StyledString]
viewCommand (ContactName -> ChatBotCommand -> [StyledString])
-> ContactName -> ChatBotCommand -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ContactName
"  " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
indent) [ChatBotCommand]
commands) [StyledString] -> [StyledString] -> [StyledString]
forall a. [a] -> [a] -> [a]
++ [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
indent ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"}"]
    quoted :: ContactName -> ContactName
quoted ContactName
s = if (Char -> Bool) -> ContactName -> Bool
T.any Char -> Bool
isSpace ContactName
s then ContactName
"'" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
s ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"'" else ContactName
s
    bot :: StyledString
bot = if Maybe ChatPeerType
peerType Maybe ChatPeerType -> Maybe ChatPeerType -> Bool
forall a. Eq a => a -> a -> Bool
== ChatPeerType -> Maybe ChatPeerType
forall a. a -> Maybe a
Just ChatPeerType
CPTBot then StyledString
" (bot)" else StyledString
""

viewUserPrivacy :: User -> User -> [StyledString]
viewUserPrivacy :: User -> User -> [StyledString]
viewUserPrivacy User {ContactId
userId :: User -> ContactId
userId :: ContactId
userId} User {userId :: User -> ContactId
userId = ContactId
userId', localDisplayName :: User -> ContactName
localDisplayName = ContactName
n', Bool
showNtfs :: User -> Bool
showNtfs :: Bool
showNtfs, Maybe UserPwdHash
viewPwdHash :: User -> Maybe UserPwdHash
viewPwdHash :: Maybe UserPwdHash
viewPwdHash} =
  [ ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ (if ContactId
userId ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
userId' then ContactName
"current " else ContactName
"") ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"user " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
n' ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
":",
    StyledString
"messages are " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if Bool
showNtfs then StyledString
"shown" else StyledString
"hidden (use /tail to view)",
    StyledString
"profile is " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if Maybe UserPwdHash -> Bool
forall a. Maybe a -> Bool
isJust Maybe UserPwdHash
viewPwdHash then StyledString
"hidden" else StyledString
"visible"
  ]

viewConnDiffSync :: DatabaseDiff AgentUserId -> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSync :: DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSync DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
  | DatabaseDiff AgentUserId -> Bool
forall {a}. DatabaseDiff a -> Bool
noDiff DatabaseDiff AgentUserId
userDiff Bool -> Bool -> Bool
&& DatabaseDiff AgentConnId -> Bool
forall {a}. DatabaseDiff a -> Bool
noDiff DatabaseDiff AgentConnId
connDiff = []
  | Bool
otherwise =
      DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSummary' DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
        [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"removed extra users in agent" | Bool -> Bool
not ([AgentUserId] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([AgentUserId] -> Bool) -> [AgentUserId] -> Bool
forall a b. (a -> b) -> a -> b
$ DatabaseDiff AgentUserId -> [AgentUserId]
forall a. DatabaseDiff a -> [a]
extraIds DatabaseDiff AgentUserId
userDiff)]
        [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"removed extra connections in agent" | Bool -> Bool
not ([AgentConnId] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([AgentConnId] -> Bool) -> [AgentConnId] -> Bool
forall a b. (a -> b) -> a -> b
$ DatabaseDiff AgentConnId -> [AgentConnId]
forall a. DatabaseDiff a -> [a]
extraIds DatabaseDiff AgentConnId
connDiff)]
  where
    noDiff :: DatabaseDiff a -> Bool
noDiff DatabaseDiff {[a]
missingIds :: [a]
missingIds :: forall a. DatabaseDiff a -> [a]
missingIds, [a]
extraIds :: forall a. DatabaseDiff a -> [a]
extraIds :: [a]
extraIds} = [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
missingIds Bool -> Bool -> Bool
&& [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
extraIds

viewConnDiffSummary :: DatabaseDiff AgentUserId -> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSummary :: DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSummary DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
  | DatabaseDiff AgentUserId -> Bool
forall {a}. DatabaseDiff a -> Bool
noDiff DatabaseDiff AgentUserId
userDiff Bool -> Bool -> Bool
&& DatabaseDiff AgentConnId -> Bool
forall {a}. DatabaseDiff a -> Bool
noDiff DatabaseDiff AgentConnId
connDiff =
      [StyledString
"no difference between agent and chat connections"]
  | Bool
otherwise =
      DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSummary' DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
  where
    noDiff :: DatabaseDiff a -> Bool
noDiff DatabaseDiff {[a]
missingIds :: forall a. DatabaseDiff a -> [a]
missingIds :: [a]
missingIds, [a]
extraIds :: forall a. DatabaseDiff a -> [a]
extraIds :: [a]
extraIds} = [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
missingIds Bool -> Bool -> Bool
&& [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
extraIds

viewConnDiffSummary' :: DatabaseDiff AgentUserId -> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSummary' :: DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffSummary' DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff =
  [StyledString
"connections difference summary:"]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> StyledString -> DatabaseDiff AgentUserId -> [StyledString]
forall {a}. StyledString -> DatabaseDiff a -> [StyledString]
showDatabaseDiff StyledString
"users" DatabaseDiff AgentUserId
userDiff
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> StyledString -> DatabaseDiff AgentConnId -> [StyledString]
forall {a}. StyledString -> DatabaseDiff a -> [StyledString]
showDatabaseDiff StyledString
"connections" DatabaseDiff AgentConnId
connDiff
  where
    showDatabaseDiff :: StyledString -> DatabaseDiff a -> [StyledString]
showDatabaseDiff StyledString
name DatabaseDiff {[a]
missingIds :: forall a. DatabaseDiff a -> [a]
missingIds :: [a]
missingIds, [a]
extraIds :: forall a. DatabaseDiff a -> [a]
extraIds :: [a]
extraIds} =
      [StyledString
"number of missing " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
name StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" in agent: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
missingIds) | Bool -> Bool
not ([a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
missingIds)]
        [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"number of extra " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
name StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" in agent: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow ([a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
extraIds) | Bool -> Bool
not ([a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
extraIds)]

viewConnDiffIds :: DatabaseDiff AgentUserId -> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffIds :: DatabaseDiff AgentUserId
-> DatabaseDiff AgentConnId -> [StyledString]
viewConnDiffIds DatabaseDiff AgentUserId
userDiff DatabaseDiff AgentConnId
connDiff
  | DatabaseDiff AgentUserId -> Bool
forall {a}. DatabaseDiff a -> Bool
noDiff DatabaseDiff AgentUserId
userDiff Bool -> Bool -> Bool
&& DatabaseDiff AgentConnId -> Bool
forall {a}. DatabaseDiff a -> Bool
noDiff DatabaseDiff AgentConnId
connDiff =
      [StyledString
"no difference between agent and chat connections"]
  | Bool
otherwise =
      [StyledString
"connections difference:"]
        [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (AgentUserId -> ContactId)
-> DatabaseDiff AgentUserId
-> [StyledString]
forall {b} {a}.
Show b =>
StyledString -> (a -> b) -> DatabaseDiff a -> [StyledString]
showDatabaseDiff StyledString
"users" (\(AgentUserId ContactId
uId) -> ContactId
uId) DatabaseDiff AgentUserId
userDiff
        [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (AgentConnId -> ByteString)
-> DatabaseDiff AgentConnId
-> [StyledString]
forall {b} {a}.
Show b =>
StyledString -> (a -> b) -> DatabaseDiff a -> [StyledString]
showDatabaseDiff StyledString
"connections" (\(AgentConnId ByteString
cId) -> ByteString
cId) DatabaseDiff AgentConnId
connDiff
  where
    noDiff :: DatabaseDiff a -> Bool
noDiff DatabaseDiff {[a]
missingIds :: forall a. DatabaseDiff a -> [a]
missingIds :: [a]
missingIds, [a]
extraIds :: forall a. DatabaseDiff a -> [a]
extraIds :: [a]
extraIds} = [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
missingIds Bool -> Bool -> Bool
&& [a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
extraIds
    showDatabaseDiff :: StyledString -> (a -> b) -> DatabaseDiff a -> [StyledString]
showDatabaseDiff StyledString
name a -> b
unwrapId DatabaseDiff {[a]
missingIds :: forall a. DatabaseDiff a -> [a]
missingIds :: [a]
missingIds, [a]
extraIds :: forall a. DatabaseDiff a -> [a]
extraIds :: [a]
extraIds} =
      [StyledString
"missing " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
name StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" in agent (agent IDs): " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [a] -> StyledString
showIds [a]
missingIds | Bool -> Bool
not ([a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
missingIds)]
        [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"extra " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
name StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" in agent (agent IDs): " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [a] -> StyledString
showIds [a]
extraIds | Bool -> Bool
not ([a] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
extraIds)]
      where
        showIds :: [a] -> StyledString
showIds = ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> ([a] -> ContactName) -> [a] -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> [ContactName] -> ContactName
T.intercalate ContactName
", " ([ContactName] -> ContactName)
-> ([a] -> [ContactName]) -> [a] -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> ContactName) -> [a] -> [ContactName]
forall a b. (a -> b) -> [a] -> [b]
map (b -> ContactName
forall a. Show a => a -> ContactName
tshow (b -> ContactName) -> (a -> b) -> a -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
unwrapId)

subStatusStr :: SubscriptionStatus -> String
subStatusStr :: SubscriptionStatus -> String
subStatusStr = \case
  SubscriptionStatus
SSActive -> String
"subscribed"
  SubscriptionStatus
SSPending -> String
"disconnected"
  SSRemoved String
e -> String
"removed: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
e
  SubscriptionStatus
SSNoSub -> String
"no subscription"

viewUserServers :: UserOperatorServers -> [StyledString]
viewUserServers :: UserOperatorServers -> [StyledString]
viewUserServers (UserOperatorServers Maybe ServerOperator
_ [] []) = []
viewUserServers UserOperatorServers {Maybe ServerOperator
operator :: Maybe ServerOperator
operator :: UserOperatorServers -> Maybe ServerOperator
operator, [UserServer 'PSMP]
smpServers :: [UserServer 'PSMP]
smpServers :: UserOperatorServers -> [UserServer 'PSMP]
smpServers, [UserServer 'PXFTP]
xftpServers :: [UserServer 'PXFTP]
xftpServers :: UserOperatorServers -> [UserServer 'PXFTP]
xftpServers} =
  [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
-> (ServerOperator -> ContactName)
-> Maybe ServerOperator
-> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"Your servers" ServerOperator -> ContactName
shortViewOperator Maybe ServerOperator
operator]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> SProtocolType 'PSMP -> [UserServer 'PSMP] -> [StyledString]
forall (p :: ProtocolType).
(ProtocolTypeI p, UserProtocol p) =>
SProtocolType p -> [UserServer p] -> [StyledString]
viewServers SProtocolType 'PSMP
SPSMP [UserServer 'PSMP]
smpServers
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> SProtocolType 'PXFTP -> [UserServer 'PXFTP] -> [StyledString]
forall (p :: ProtocolType).
(ProtocolTypeI p, UserProtocol p) =>
SProtocolType p -> [UserServer p] -> [StyledString]
viewServers SProtocolType 'PXFTP
SPXFTP [UserServer 'PXFTP]
xftpServers
  where
    viewServers :: (ProtocolTypeI p, UserProtocol p) => SProtocolType p -> [UserServer p] -> [StyledString]
    viewServers :: forall (p :: ProtocolType).
(ProtocolTypeI p, UserProtocol p) =>
SProtocolType p -> [UserServer p] -> [StyledString]
viewServers SProtocolType p
_ [] = []
    viewServers SProtocolType p
p [UserServer p]
srvs
      | Bool -> (ServerOperator -> Bool) -> Maybe ServerOperator -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True (\ServerOperator {Bool
enabled :: Bool
enabled :: forall (s :: DBStored). ServerOperator' s -> Bool
enabled} -> Bool
enabled) Maybe ServerOperator
operator =
          [StyledString
"  " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SProtocolType p -> StyledString
forall (p :: ProtocolType).
ProtocolTypeI p =>
SProtocolType p -> StyledString
protocolName SProtocolType p
p StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" servers" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (ServerOperator -> StyledString)
-> Maybe ServerOperator
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"" ((StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>) (StyledString -> StyledString)
-> (ServerOperator -> StyledString)
-> ServerOperator
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ServerOperator -> StyledString
viewRoles) Maybe ServerOperator
operator]
            [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (UserServer p -> StyledString) -> [UserServer p] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (UserServer p -> ContactName) -> UserServer p -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ContactName
"    " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<>) (ContactName -> ContactName)
-> (UserServer p -> ContactName) -> UserServer p -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserServer p -> ContactName
forall {p :: ProtocolType} {s :: DBStored}.
ProtocolTypeI p =>
UserServer' s p -> ContactName
viewServer) [UserServer p]
srvs
      | Bool
otherwise = []
      where
        viewServer :: UserServer' s p -> ContactName
viewServer UserServer {ProtoServerWithAuth p
server :: ProtoServerWithAuth p
server :: forall (s :: DBStored) (p :: ProtocolType).
UserServer' s p -> ProtoServerWithAuth p
server, Bool
preset :: Bool
preset :: forall (s :: DBStored) (p :: ProtocolType). UserServer' s p -> Bool
preset, Maybe Bool
tested :: Maybe Bool
tested :: forall (s :: DBStored) (p :: ProtocolType).
UserServer' s p -> Maybe Bool
tested, Bool
enabled :: Bool
enabled :: forall (s :: DBStored) (p :: ProtocolType). UserServer' s p -> Bool
enabled} = ByteString -> ContactName
safeDecodeUtf8 (ProtoServerWithAuth p -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ProtoServerWithAuth p
server) ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
serverInfo
          where
            serverInfo :: ContactName
serverInfo = if [ContactName] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ContactName]
serverInfo_ then ContactName
"" else ContactName -> ContactName
forall a. (IsString a, Semigroup a) => a -> a
parens (ContactName -> ContactName) -> ContactName -> ContactName
forall a b. (a -> b) -> a -> b
$ ContactName -> [ContactName] -> ContactName
T.intercalate ContactName
", " [ContactName]
serverInfo_
            serverInfo_ :: [ContactName]
serverInfo_ = [ContactName
"preset" | Bool
preset] [ContactName] -> [ContactName] -> [ContactName]
forall a. Semigroup a => a -> a -> a
<> [ContactName]
testedInfo [ContactName] -> [ContactName] -> [ContactName]
forall a. Semigroup a => a -> a -> a
<> [ContactName
"disabled" | Bool -> Bool
not Bool
enabled]
            testedInfo :: [ContactName]
testedInfo = [ContactName]
-> (Bool -> [ContactName]) -> Maybe Bool -> [ContactName]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Bool
t -> [ContactName
"test: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> if Bool
t then ContactName
"passed" else ContactName
"failed"]) Maybe Bool
tested
        viewRoles :: ServerOperator -> StyledString
viewRoles op :: ServerOperator
op@ServerOperator {Bool
enabled :: forall (s :: DBStored). ServerOperator' s -> Bool
enabled :: Bool
enabled}
          | Bool -> Bool
not Bool
enabled = StyledString
"disabled"
          | ServerRoles -> Bool
storage ServerRoles
rs Bool -> Bool -> Bool
&& ServerRoles -> Bool
proxy ServerRoles
rs = StyledString
"enabled"
          | ServerRoles -> Bool
storage ServerRoles
rs = StyledString
"enabled storage"
          | ServerRoles -> Bool
proxy ServerRoles
rs = StyledString
"enabled proxy"
          | Bool
otherwise = StyledString
"disabled (servers known)"
          where
            rs :: ServerRoles
rs = SProtocolType p -> ServerOperator -> ServerRoles
forall (p :: ProtocolType).
UserProtocol p =>
SProtocolType p -> ServerOperator -> ServerRoles
operatorRoles SProtocolType p
p ServerOperator
op

serversUserHelp :: [StyledString]
serversUserHelp :: [StyledString]
serversUserHelp =
  [ StyledString
"",
    StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/smp test <srv>" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to test SMP server connection",
    StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/smp <srv1[,srv2,...]>" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to configure SMP servers",
    StyledString
"or the same commands starting from /xftp for XFTP servers",
    StyledString
"chat options " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"-s" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"--server" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
") and " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"--xftp-servers" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" have precedence over preset servers for new user profiles"
  ]

protocolName :: ProtocolTypeI p => SProtocolType p -> StyledString
protocolName :: forall (p :: ProtocolType).
ProtocolTypeI p =>
SProtocolType p -> StyledString
protocolName = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString)
-> (SProtocolType p -> String) -> SProtocolType p -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper (String -> String)
-> (SProtocolType p -> String) -> SProtocolType p -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> String
T.unpack (ContactName -> String)
-> (SProtocolType p -> ContactName) -> SProtocolType p -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ContactName
decodeLatin1 (ByteString -> ContactName)
-> (SProtocolType p -> ByteString)
-> SProtocolType p
-> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SProtocolType p -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode

viewServerTestResult :: AProtoServerWithAuth -> Maybe ProtocolTestFailure -> [StyledString]
viewServerTestResult :: AProtoServerWithAuth -> Maybe ProtocolTestFailure -> [StyledString]
viewServerTestResult (AProtoServerWithAuth SProtocolType p
p ProtoServerWithAuth p
_) = \case
  Just ProtocolTestFailure {ProtocolTestStep
testStep :: ProtocolTestStep
testStep :: ProtocolTestFailure -> ProtocolTestStep
testStep, AgentErrorType
testError :: AgentErrorType
testError :: ProtocolTestFailure -> AgentErrorType
testError} ->
    [StyledString]
result
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
pName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" server requires authorization to create queues, check password" | ProtocolTestStep
testStep ProtocolTestStep -> ProtocolTestStep -> Bool
forall a. Eq a => a -> a -> Bool
== ProtocolTestStep
TSCreateQueue Bool -> Bool -> Bool
&& (case AgentErrorType
testError of SMP String
_ ErrorType
SMP.AUTH -> Bool
True; AgentErrorType
_ -> Bool
False)]
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
pName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" server requires authorization to upload files, check password" | ProtocolTestStep
testStep ProtocolTestStep -> ProtocolTestStep -> Bool
forall a. Eq a => a -> a -> Bool
== ProtocolTestStep
TSCreateFile Bool -> Bool -> Bool
&& (case AgentErrorType
testError of XFTP String
_ XFTPErrorType
XFTP.AUTH -> Bool
True; AgentErrorType
_ -> Bool
False)]
      [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"Certificate fingerprint in " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
pName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" server address does not match server certificate" | ProtocolTestStep
testStep ProtocolTestStep -> ProtocolTestStep -> Bool
forall a. Eq a => a -> a -> Bool
== ProtocolTestStep
TSConnect Bool -> Bool -> Bool
&& Bool
unknownCA]
    where
      result :: [StyledString]
result = [StyledString
pName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" server test failed at " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (Int -> String -> String
forall a. Int -> [a] -> [a]
drop Int
2 (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ ProtocolTestStep -> String
forall a. Show a => a -> String
show ProtocolTestStep
testStep) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentErrorType -> StyledString
forall a. Show a => a -> StyledString
sShow AgentErrorType
testError]
      unknownCA :: Bool
unknownCA = case AgentErrorType
testError of
        BROKER String
_ (NETWORK NetworkError
NEUnknownCAError) -> Bool
True
        AgentErrorType
_ -> Bool
False
  Maybe ProtocolTestFailure
_ -> [StyledString
pName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" server test passed"]
  where
    pName :: StyledString
pName = SProtocolType p -> StyledString
forall (p :: ProtocolType).
ProtocolTypeI p =>
SProtocolType p -> StyledString
protocolName SProtocolType p
p

viewServerOperators :: [ServerOperator] -> Maybe UsageConditionsAction -> [StyledString]
viewServerOperators :: [ServerOperator] -> Maybe UsageConditionsAction -> [StyledString]
viewServerOperators [ServerOperator]
ops Maybe UsageConditionsAction
ca = (ServerOperator -> StyledString)
-> [ServerOperator] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (ServerOperator -> ContactName)
-> ServerOperator
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ServerOperator -> ContactName
forall (s :: DBStored). ServerOperator' s -> ContactName
viewOperator) [ServerOperator]
ops [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (UsageConditionsAction -> [StyledString])
-> Maybe UsageConditionsAction
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] UsageConditionsAction -> [StyledString]
viewConditionsAction Maybe UsageConditionsAction
ca

viewOperator :: ServerOperator' s -> Text
viewOperator :: forall (s :: DBStored). ServerOperator' s -> ContactName
viewOperator op :: ServerOperator' s
op@ServerOperator {ContactName
tradeName :: ContactName
tradeName :: forall (s :: DBStored). ServerOperator' s -> ContactName
tradeName, Maybe ContactName
legalName :: Maybe ContactName
legalName :: forall (s :: DBStored). ServerOperator' s -> Maybe ContactName
legalName, [ContactName]
serverDomains :: [ContactName]
serverDomains :: forall (s :: DBStored). ServerOperator' s -> [ContactName]
serverDomains, ConditionsAcceptance
conditionsAcceptance :: ConditionsAcceptance
conditionsAcceptance :: forall (s :: DBStored). ServerOperator' s -> ConditionsAcceptance
conditionsAcceptance} =
  ServerOperator' s -> ContactName
forall (s :: DBStored). ServerOperator' s -> ContactName
viewOpIdTag ServerOperator' s
op
    ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
tradeName
    ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (ContactName -> ContactName) -> Maybe ContactName -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" ContactName -> ContactName
forall a. (IsString a, Semigroup a) => a -> a
parens Maybe ContactName
legalName
    ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> (ContactName
", domains: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> [ContactName] -> ContactName
T.intercalate ContactName
", " [ContactName]
serverDomains)
    ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> (ContactName
", servers: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ServerOperator' s -> ContactName
forall (s :: DBStored). ServerOperator' s -> ContactName
viewOpEnabled ServerOperator' s
op)
    ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> (ContactName
", conditions: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ConditionsAcceptance -> ContactName
viewOpConditions ConditionsAcceptance
conditionsAcceptance)

shortViewOperator :: ServerOperator -> Text
shortViewOperator :: ServerOperator -> ContactName
shortViewOperator ServerOperator {operatorId :: forall (s :: DBStored). ServerOperator' s -> DBEntityId' s
operatorId = DBEntityId ContactId
opId, ContactName
tradeName :: forall (s :: DBStored). ServerOperator' s -> ContactName
tradeName :: ContactName
tradeName, Bool
enabled :: forall (s :: DBStored). ServerOperator' s -> Bool
enabled :: Bool
enabled} =
  ContactId -> ContactName
forall a. Show a => a -> ContactName
tshow ContactId
opId ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
". " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
tradeName ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
forall a. (IsString a, Semigroup a) => a -> a
parens (if Bool
enabled then ContactName
"enabled" else ContactName
"disabled")

viewOpIdTag :: ServerOperator' s -> Text
viewOpIdTag :: forall (s :: DBStored). ServerOperator' s -> ContactName
viewOpIdTag ServerOperator {DBEntityId' s
operatorId :: forall (s :: DBStored). ServerOperator' s -> DBEntityId' s
operatorId :: DBEntityId' s
operatorId, Maybe OperatorTag
operatorTag :: Maybe OperatorTag
operatorTag :: forall (s :: DBStored). ServerOperator' s -> Maybe OperatorTag
operatorTag} = case DBEntityId' s
operatorId of
  DBEntityId ContactId
i -> ContactId -> ContactName
forall a. Show a => a -> ContactName
tshow ContactId
i ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
tag
  DBEntityId' s
DBNewEntity -> ContactName
tag
  where
    tag :: ContactName
tag = ContactName
-> (OperatorTag -> ContactName) -> Maybe OperatorTag -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (ContactName -> ContactName
forall a. (IsString a, Semigroup a) => a -> a
parens (ContactName -> ContactName)
-> (OperatorTag -> ContactName) -> OperatorTag -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OperatorTag -> ContactName
forall a. TextEncoding a => a -> ContactName
textEncode) Maybe OperatorTag
operatorTag ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
". "

viewOpConditions :: ConditionsAcceptance -> Text
viewOpConditions :: ConditionsAcceptance -> ContactName
viewOpConditions = \case
  CAAccepted Maybe UTCTime
ts Bool
_ -> ContactName -> Maybe UTCTime -> ContactName
forall {a}. Show a => ContactName -> Maybe a -> ContactName
viewCond ContactName
"accepted" Maybe UTCTime
ts
  CARequired Maybe UTCTime
ts -> ContactName -> Maybe UTCTime -> ContactName
forall {a}. Show a => ContactName -> Maybe a -> ContactName
viewCond ContactName
"required" Maybe UTCTime
ts
  where
    viewCond :: ContactName -> Maybe a -> ContactName
viewCond ContactName
w Maybe a
ts = ContactName
w ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> (a -> ContactName) -> Maybe a -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (ContactName -> ContactName
forall a. (IsString a, Semigroup a) => a -> a
parens (ContactName -> ContactName)
-> (a -> ContactName) -> a -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ContactName
forall a. Show a => a -> ContactName
tshow) Maybe a
ts

viewOpEnabled :: ServerOperator' s -> Text
viewOpEnabled :: forall (s :: DBStored). ServerOperator' s -> ContactName
viewOpEnabled ServerOperator {Bool
enabled :: forall (s :: DBStored). ServerOperator' s -> Bool
enabled :: Bool
enabled, ServerRoles
smpRoles :: ServerRoles
smpRoles :: forall (s :: DBStored). ServerOperator' s -> ServerRoles
smpRoles, ServerRoles
xftpRoles :: ServerRoles
xftpRoles :: forall (s :: DBStored). ServerOperator' s -> ServerRoles
xftpRoles}
  | Bool -> Bool
not Bool
enabled = ContactName
"disabled"
  | ServerRoles -> Bool
no ServerRoles
smpRoles Bool -> Bool -> Bool
&& ServerRoles -> Bool
no ServerRoles
xftpRoles = ContactName
"disabled (servers known)"
  | ServerRoles -> Bool
both ServerRoles
smpRoles Bool -> Bool -> Bool
&& ServerRoles -> Bool
both ServerRoles
xftpRoles = ContactName
"enabled"
  | Bool
otherwise = ContactName
"SMP " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ServerRoles -> ContactName
forall {a}. IsString a => ServerRoles -> a
viewRoles ServerRoles
smpRoles ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
", XFTP " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ServerRoles -> ContactName
forall {a}. IsString a => ServerRoles -> a
viewRoles ServerRoles
xftpRoles
  where
    no :: ServerRoles -> Bool
no ServerRoles
rs = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ ServerRoles -> Bool
storage ServerRoles
rs Bool -> Bool -> Bool
|| ServerRoles -> Bool
proxy ServerRoles
rs
    both :: ServerRoles -> Bool
both ServerRoles
rs = ServerRoles -> Bool
storage ServerRoles
rs Bool -> Bool -> Bool
&& ServerRoles -> Bool
proxy ServerRoles
rs
    viewRoles :: ServerRoles -> a
viewRoles ServerRoles
rs
      | ServerRoles -> Bool
both ServerRoles
rs = a
"enabled"
      | ServerRoles -> Bool
storage ServerRoles
rs = a
"enabled storage"
      | ServerRoles -> Bool
proxy ServerRoles
rs = a
"enabled proxy"
      | Bool
otherwise = a
"disabled (servers known)"

viewConditionsAction :: UsageConditionsAction -> [StyledString]
viewConditionsAction :: UsageConditionsAction -> [StyledString]
viewConditionsAction = \case
  UCAReview {[ServerOperator]
operators :: [ServerOperator]
operators :: UsageConditionsAction -> [ServerOperator]
operators, Maybe UTCTime
deadline :: Maybe UTCTime
deadline :: UsageConditionsAction -> Maybe UTCTime
deadline, Bool
showNotice :: Bool
showNotice :: UsageConditionsAction -> Bool
showNotice} | Bool
showNotice -> case Maybe UTCTime
deadline of
    Just UTCTime
ts -> [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"The new conditions will be accepted for " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
ops ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" at " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> UTCTime -> ContactName
forall a. Show a => a -> ContactName
tshow UTCTime
ts]
    Maybe UTCTime
Nothing -> [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"The new conditions have to be accepted for " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
ops]
    where
      ops :: ContactName
ops = ContactName -> [ContactName] -> ContactName
T.intercalate ContactName
", " ([ContactName] -> ContactName) -> [ContactName] -> ContactName
forall a b. (a -> b) -> a -> b
$ (ServerOperator -> ContactName)
-> [ServerOperator] -> [ContactName]
forall a b. (a -> b) -> [a] -> [b]
map ServerOperator -> ContactName
forall (s :: DBStored). ServerOperator' s -> ContactName
legalName_ [ServerOperator]
operators
      legalName_ :: ServerOperator' s -> ContactName
legalName_ ServerOperator {ContactName
tradeName :: forall (s :: DBStored). ServerOperator' s -> ContactName
tradeName :: ContactName
tradeName, Maybe ContactName
legalName :: forall (s :: DBStored). ServerOperator' s -> Maybe ContactName
legalName :: Maybe ContactName
legalName} = ContactName -> Maybe ContactName -> ContactName
forall a. a -> Maybe a -> a
fromMaybe ContactName
tradeName Maybe ContactName
legalName
  UsageConditionsAction
_ -> []

viewUsageConditions :: UsageConditions -> Maybe UsageConditions -> [StyledString]
viewUsageConditions :: UsageConditions -> Maybe UsageConditions -> [StyledString]
viewUsageConditions UsageConditions
current Maybe UsageConditions
accepted_ =
  [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"Current conditions: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> UsageConditions -> ContactName
viewConds UsageConditions
current ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (UsageConditions -> ContactName)
-> Maybe UsageConditions
-> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (\UsageConditions
ac -> ContactName
", accepted conditions: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> UsageConditions -> ContactName
viewConds UsageConditions
ac) Maybe UsageConditions
accepted_]
  where
    viewConds :: UsageConditions -> ContactName
viewConds UsageConditions {ContactId
conditionsId :: ContactId
conditionsId :: UsageConditions -> ContactId
conditionsId, ContactName
conditionsCommit :: ContactName
conditionsCommit :: UsageConditions -> ContactName
conditionsCommit, Maybe UTCTime
notifiedAt :: Maybe UTCTime
notifiedAt :: UsageConditions -> Maybe UTCTime
notifiedAt} =
      ContactId -> ContactName
forall a. Show a => a -> ContactName
tshow ContactId
conditionsId ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (UTCTime -> ContactName) -> Maybe UTCTime -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (ContactName -> UTCTime -> ContactName
forall a b. a -> b -> a
const ContactName
" (notified)") Maybe UTCTime
notifiedAt ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
". " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
conditionsCommit

viewChatItemTTL :: Maybe Int64 -> [StyledString]
viewChatItemTTL :: Maybe ContactId -> [StyledString]
viewChatItemTTL = \case
  Maybe ContactId
Nothing -> [StyledString
"old messages are set to delete according to default user config"]
  Just ContactId
ttl
    | ContactId
ttl ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
0 -> [StyledString
"old messages are not being deleted"]
    | ContactId
ttl ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
86400 -> StyledString -> [StyledString]
forall {a}. (Semigroup a, IsString a) => a -> [a]
deletedAfter StyledString
"one day"
    | ContactId
ttl ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
7 ContactId -> ContactId -> ContactId
forall a. Num a => a -> a -> a
* ContactId
86400 -> StyledString -> [StyledString]
forall {a}. (Semigroup a, IsString a) => a -> [a]
deletedAfter StyledString
"one week"
    | ContactId
ttl ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
30 ContactId -> ContactId -> ContactId
forall a. Num a => a -> a -> a
* ContactId
86400 -> StyledString -> [StyledString]
forall {a}. (Semigroup a, IsString a) => a -> [a]
deletedAfter StyledString
"one month"
    | ContactId
ttl ContactId -> ContactId -> Bool
forall a. Eq a => a -> a -> Bool
== ContactId
365 ContactId -> ContactId -> ContactId
forall a. Num a => a -> a -> a
* ContactId
86400 -> StyledString -> [StyledString]
forall {a}. (Semigroup a, IsString a) => a -> [a]
deletedAfter StyledString
"one year"
    | Bool
otherwise -> StyledString -> [StyledString]
forall {a}. (Semigroup a, IsString a) => a -> [a]
deletedAfter (StyledString -> [StyledString]) -> StyledString -> [StyledString]
forall a b. (a -> b) -> a -> b
$ ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
ttl StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" second(s)"
  where
    deletedAfter :: a -> [a]
deletedAfter a
ttlStr = [a
"old messages are set to be deleted after: " a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
ttlStr]

viewNetworkConfig :: NetworkConfig -> [StyledString]
viewNetworkConfig :: NetworkConfig -> [StyledString]
viewNetworkConfig NetworkConfig {Maybe SocksProxyWithAuth
socksProxy :: Maybe SocksProxyWithAuth
socksProxy :: NetworkConfig -> Maybe SocksProxyWithAuth
socksProxy, SocksMode
socksMode :: SocksMode
socksMode :: NetworkConfig -> SocksMode
socksMode, NetworkTimeout
tcpTimeout :: NetworkTimeout
tcpTimeout :: NetworkConfig -> NetworkTimeout
tcpTimeout, SMPProxyMode
smpProxyMode :: SMPProxyMode
smpProxyMode :: NetworkConfig -> SMPProxyMode
smpProxyMode, SMPProxyFallback
smpProxyFallback :: SMPProxyFallback
smpProxyFallback :: NetworkConfig -> SMPProxyFallback
smpProxyFallback} =
  [ String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
-> (SocksProxyWithAuth -> String)
-> Maybe SocksProxyWithAuth
-> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"direct network connection" ((\String
sp -> String
"using SOCKS5 proxy " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
sp String -> String -> String
forall a. Semigroup a => a -> a -> a
<> if SocksMode
socksMode SocksMode -> SocksMode -> Bool
forall a. Eq a => a -> a -> Bool
== SocksMode
SMOnion then String
" for onion servers ONLY." else String
" for ALL servers.") (String -> String)
-> (SocksProxyWithAuth -> String) -> SocksProxyWithAuth -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SocksProxyWithAuth -> String
forall a. Show a => a -> String
show) Maybe SocksProxyWithAuth
socksProxy,
    StyledString
"TCP timeout: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> NetworkTimeout -> StyledString
forall a. Show a => a -> StyledString
sShow NetworkTimeout
tcpTimeout,
    String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ SMPProxyMode -> SMPProxyFallback -> String
smpProxyModeStr SMPProxyMode
smpProxyMode SMPProxyFallback
smpProxyFallback,
    StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/network socks=<on/off/[ipv4]:port>[ socks-mode=always/onion][ smp-proxy=always/unknown/unprotected/never][ smp-proxy-fallback=no/protected/yes][ timeout=<seconds>]" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to change settings"
  ]

smpProxyModeStr :: SMPProxyMode -> SMPProxyFallback -> String
smpProxyModeStr :: SMPProxyMode -> SMPProxyFallback -> String
smpProxyModeStr SMPProxyMode
SPMNever SMPProxyFallback
_ = String
"private message routing disabled."
smpProxyModeStr SMPProxyMode
mode SMPProxyFallback
fallback = ContactName -> String
T.unpack (ContactName -> String) -> ContactName -> String
forall a b. (a -> b) -> a -> b
$ ByteString -> ContactName
safeDecodeUtf8 (ByteString -> ContactName) -> ByteString -> ContactName
forall a b. (a -> b) -> a -> b
$ ByteString
"private message routing mode: " ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> SMPProxyMode -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode SMPProxyMode
mode ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
", fallback: " ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> SMPProxyFallback -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode SMPProxyFallback
fallback

viewContactInfo :: Contact -> Maybe ConnectionStats -> Maybe Profile -> [StyledString]
viewContactInfo :: Contact -> Maybe ConnectionStats -> Maybe Profile -> [StyledString]
viewContactInfo ct :: Contact
ct@Contact {ContactId
contactId :: ContactId
contactId :: Contact -> ContactId
contactId, profile :: Contact -> LocalProfile
profile = LocalProfile {ContactName
localAlias :: LocalProfile -> ContactName
localAlias :: ContactName
localAlias, Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink :: LocalProfile -> Maybe ConnLinkContact
contactLink}, Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn, Maybe UIThemeEntityOverrides
uiThemes :: Maybe UIThemeEntityOverrides
uiThemes :: Contact -> Maybe UIThemeEntityOverrides
uiThemes, Maybe CustomData
customData :: Maybe CustomData
customData :: Contact -> Maybe CustomData
customData} Maybe ConnectionStats
stats Maybe Profile
incognitoProfile =
  [StyledString
"contact ID: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
contactId]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (ConnectionStats -> [StyledString])
-> Maybe ConnectionStats
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ConnectionStats -> [StyledString]
viewConnectionStats Maybe ConnectionStats
stats
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (ConnLinkContact -> [StyledString])
-> Maybe ConnLinkContact
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ConnLinkContact
l -> [StyledString
"contact address: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString)
-> (ConnLinkContact -> ByteString)
-> ConnLinkContact
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnLinkContact -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode) (ConnLinkContact -> ConnLinkContact
simplexChatContact' ConnLinkContact
l)]) Maybe ConnLinkContact
contactLink
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (Profile -> [StyledString]) -> Maybe Profile -> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
      [StyledString
"you've shared main profile with this contact"]
      (\Profile
p -> [StyledString
"you've shared incognito profile with this contact: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Profile -> StyledString
incognitoProfile' Profile
p])
      Maybe Profile
incognitoProfile
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"alias: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
localAlias | ContactName
localAlias ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
/= ContactName
""]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [Maybe SecurityCode -> StyledString
viewConnectionVerified (Contact -> Maybe SecurityCode
contactSecurityCode Contact
ct)]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"quantum resistant end-to-end encryption" | Contact -> PQEncryption
contactPQEnabled Contact
ct PQEncryption -> PQEncryption -> Bool
forall a. Eq a => a -> a -> Bool
== PQEncryption
CR.PQEncOn]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (Connection -> [StyledString])
-> Maybe Connection
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Connection
ac -> [VersionRangeChat -> StyledString
viewPeerChatVRange (Connection -> VersionRangeChat
peerChatVRange Connection
ac)]) Maybe Connection
activeConn
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> Maybe UIThemeEntityOverrides -> [StyledString]
viewUITheme Maybe UIThemeEntityOverrides
uiThemes
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> Maybe CustomData -> [StyledString]
viewCustomData Maybe CustomData
customData

viewGroupInfo :: GroupInfo -> [StyledString]
viewGroupInfo :: GroupInfo -> [StyledString]
viewGroupInfo GroupInfo {ContactId
groupId :: GroupInfo -> ContactId
groupId :: ContactId
groupId, Maybe UIThemeEntityOverrides
uiThemes :: Maybe UIThemeEntityOverrides
uiThemes :: GroupInfo -> Maybe UIThemeEntityOverrides
uiThemes, Maybe CustomData
customData :: Maybe CustomData
customData :: GroupInfo -> Maybe CustomData
customData, groupSummary :: GroupInfo -> GroupSummary
groupSummary = GroupSummary
s} =
  [ StyledString
"group ID: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
groupId,
    StyledString
"current members: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow (GroupSummary -> ContactId
currentMembers GroupSummary
s)
  ]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> Maybe UIThemeEntityOverrides -> [StyledString]
viewUITheme Maybe UIThemeEntityOverrides
uiThemes
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> Maybe CustomData -> [StyledString]
viewCustomData Maybe CustomData
customData

viewUITheme :: Maybe UIThemeEntityOverrides -> [StyledString]
viewUITheme :: Maybe UIThemeEntityOverrides -> [StyledString]
viewUITheme = [StyledString]
-> (UIThemeEntityOverrides -> [StyledString])
-> Maybe UIThemeEntityOverrides
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\UIThemeEntityOverrides
uiThemes -> [StyledString
"UI themes: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> UIThemeEntityOverrides -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON UIThemeEntityOverrides
uiThemes])

viewCustomData :: Maybe CustomData -> [StyledString]
viewCustomData :: Maybe CustomData -> [StyledString]
viewCustomData = [StyledString]
-> (CustomData -> [StyledString])
-> Maybe CustomData
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\(CustomData Object
v) -> [StyledString
"custom data: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Value -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON (Object -> Value
J.Object Object
v)])

viewGroupMemberInfo :: GroupInfo -> GroupMember -> Maybe ConnectionStats -> [StyledString]
viewGroupMemberInfo :: GroupInfo -> GroupMember -> Maybe ConnectionStats -> [StyledString]
viewGroupMemberInfo GroupInfo {ContactId
groupId :: GroupInfo -> ContactId
groupId :: ContactId
groupId} m :: GroupMember
m@GroupMember {ContactId
groupMemberId :: GroupMember -> ContactId
groupMemberId :: ContactId
groupMemberId, memberProfile :: GroupMember -> LocalProfile
memberProfile = LocalProfile {ContactName
localAlias :: LocalProfile -> ContactName
localAlias :: ContactName
localAlias, Maybe ConnLinkContact
contactLink :: LocalProfile -> Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink}, Maybe Connection
activeConn :: Maybe Connection
activeConn :: GroupMember -> Maybe Connection
activeConn} Maybe ConnectionStats
stats =
  [ StyledString
"group ID: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
groupId,
    StyledString
"member ID: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
groupMemberId
  ]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (ConnectionStats -> [StyledString])
-> Maybe ConnectionStats
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString
"member not connected"] ConnectionStats -> [StyledString]
viewConnectionStats Maybe ConnectionStats
stats
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (ConnLinkContact -> [StyledString])
-> Maybe ConnLinkContact
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ConnLinkContact
l -> [StyledString
"contact address: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString)
-> (ConnLinkContact -> ByteString)
-> ConnLinkContact
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnLinkContact -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode) (ConnLinkContact -> ConnLinkContact
simplexChatContact' ConnLinkContact
l)]) Maybe ConnLinkContact
contactLink
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"alias: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
localAlias | ContactName
localAlias ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
/= ContactName
""]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [Maybe SecurityCode -> StyledString
viewConnectionVerified (GroupMember -> Maybe SecurityCode
memberSecurityCode GroupMember
m) | Maybe ConnectionStats -> Bool
forall a. Maybe a -> Bool
isJust Maybe ConnectionStats
stats]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (Connection -> [StyledString])
-> Maybe Connection
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Connection
ac -> [VersionRangeChat -> StyledString
viewPeerChatVRange (Connection -> VersionRangeChat
peerChatVRange Connection
ac)]) Maybe Connection
activeConn

viewConnectionVerified :: Maybe SecurityCode -> StyledString
viewConnectionVerified :: Maybe SecurityCode -> StyledString
viewConnectionVerified (Just SecurityCode
_) = StyledString
"connection verified" -- TODO show verification time?
viewConnectionVerified Maybe SecurityCode
_ = StyledString
"connection not verified, use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/code" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" command to see security code"

viewPeerChatVRange :: VersionRangeChat -> StyledString
viewPeerChatVRange :: VersionRangeChat -> StyledString
viewPeerChatVRange (VersionRange Version ChatVersion
minVer Version ChatVersion
maxVer) = StyledString
"peer chat protocol version range: (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Version ChatVersion -> StyledString
forall a. Show a => a -> StyledString
sShow Version ChatVersion
minVer StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Version ChatVersion -> StyledString
forall a. Show a => a -> StyledString
sShow Version ChatVersion
maxVer StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"

viewConnectionStats :: ConnectionStats -> [StyledString]
viewConnectionStats :: ConnectionStats -> [StyledString]
viewConnectionStats ConnectionStats {[RcvQueueInfo]
rcvQueuesInfo :: [RcvQueueInfo]
rcvQueuesInfo :: ConnectionStats -> [RcvQueueInfo]
rcvQueuesInfo, [SndQueueInfo]
sndQueuesInfo :: [SndQueueInfo]
sndQueuesInfo :: ConnectionStats -> [SndQueueInfo]
sndQueuesInfo} =
  [StyledString
"receiving messages via: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [RcvQueueInfo] -> StyledString
viewRcvQueuesInfo [RcvQueueInfo]
rcvQueuesInfo | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [RcvQueueInfo] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [RcvQueueInfo]
rcvQueuesInfo]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"sending messages via: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [SndQueueInfo] -> StyledString
viewSndQueuesInfo [SndQueueInfo]
sndQueuesInfo | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ [SndQueueInfo] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [SndQueueInfo]
sndQueuesInfo]

viewRcvQueuesInfo :: [RcvQueueInfo] -> StyledString
viewRcvQueuesInfo :: [RcvQueueInfo] -> StyledString
viewRcvQueuesInfo = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString)
-> ([RcvQueueInfo] -> String) -> [RcvQueueInfo] -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " ([String] -> String)
-> ([RcvQueueInfo] -> [String]) -> [RcvQueueInfo] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RcvQueueInfo -> String) -> [RcvQueueInfo] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map RcvQueueInfo -> String
showQueueInfo
  where
    showQueueInfo :: RcvQueueInfo -> String
showQueueInfo RcvQueueInfo {SMPServer
rcvServer :: SMPServer
rcvServer :: RcvQueueInfo -> SMPServer
rcvServer, Maybe RcvSwitchStatus
rcvSwitchStatus :: Maybe RcvSwitchStatus
rcvSwitchStatus :: RcvQueueInfo -> Maybe RcvSwitchStatus
rcvSwitchStatus, Bool
canAbortSwitch :: Bool
canAbortSwitch :: RcvQueueInfo -> Bool
canAbortSwitch} =
      let switchCanBeAborted :: String
switchCanBeAborted = if Bool
canAbortSwitch then String
", can be aborted" else String
""
       in SMPServer -> String
showSMPServer SMPServer
rcvServer
            String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
-> (RcvSwitchStatus -> String) -> Maybe RcvSwitchStatus -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" (\RcvSwitchStatus
s -> String
" (" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> RcvSwitchStatus -> String
showSwitchStatus RcvSwitchStatus
s String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
switchCanBeAborted String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
")") Maybe RcvSwitchStatus
rcvSwitchStatus
    showSwitchStatus :: RcvSwitchStatus -> String
showSwitchStatus = \case
      RcvSwitchStatus
RSSwitchStarted -> String
"switch started"
      RcvSwitchStatus
RSSendingQADD -> String
"switch started"
      RcvSwitchStatus
RSSendingQUSE -> String
"switch confirmed"
      RcvSwitchStatus
RSReceivedMessage -> String
"switch secured"

viewSndQueuesInfo :: [SndQueueInfo] -> StyledString
viewSndQueuesInfo :: [SndQueueInfo] -> StyledString
viewSndQueuesInfo = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString)
-> ([SndQueueInfo] -> String) -> [SndQueueInfo] -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
", " ([String] -> String)
-> ([SndQueueInfo] -> [String]) -> [SndQueueInfo] -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SndQueueInfo -> String) -> [SndQueueInfo] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map SndQueueInfo -> String
showQueueInfo
  where
    showQueueInfo :: SndQueueInfo -> String
showQueueInfo SndQueueInfo {SMPServer
sndServer :: SMPServer
sndServer :: SndQueueInfo -> SMPServer
sndServer, Maybe SndSwitchStatus
sndSwitchStatus :: Maybe SndSwitchStatus
sndSwitchStatus :: SndQueueInfo -> Maybe SndSwitchStatus
sndSwitchStatus} =
      SMPServer -> String
showSMPServer SMPServer
sndServer
        String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
-> (SndSwitchStatus -> String) -> Maybe SndSwitchStatus -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" (\SndSwitchStatus
s -> String
" (" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> SndSwitchStatus -> String
showSwitchStatus SndSwitchStatus
s String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
")") Maybe SndSwitchStatus
sndSwitchStatus
    showSwitchStatus :: SndSwitchStatus -> String
showSwitchStatus = \case
      SndSwitchStatus
SSSendingQKEY -> String
"switch started"
      SndSwitchStatus
SSSendingQTEST -> String
"switch secured"

viewContactSwitch :: Contact -> SwitchProgress -> [StyledString]
viewContactSwitch :: Contact -> SwitchProgress -> [StyledString]
viewContactSwitch Contact
_ (SwitchProgress QueueDirection
_ SwitchPhase
SPConfirmed ConnectionStats
_) = []
viewContactSwitch Contact
_ (SwitchProgress QueueDirection
_ SwitchPhase
SPSecured ConnectionStats
_) = []
viewContactSwitch Contact
ct (SwitchProgress QueueDirection
qd SwitchPhase
phase ConnectionStats
_) = case QueueDirection
qd of
  QueueDirection
QDRcv -> [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SwitchPhase -> StyledString
viewSwitchPhase SwitchPhase
phase]
  QueueDirection
QDSnd -> [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SwitchPhase -> StyledString
viewSwitchPhase SwitchPhase
phase StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" for you"]

viewGroupMemberSwitch :: GroupInfo -> GroupMember -> SwitchProgress -> [StyledString]
viewGroupMemberSwitch :: GroupInfo -> GroupMember -> SwitchProgress -> [StyledString]
viewGroupMemberSwitch GroupInfo
_ GroupMember
_ (SwitchProgress QueueDirection
_ SwitchPhase
SPConfirmed ConnectionStats
_) = []
viewGroupMemberSwitch GroupInfo
_ GroupMember
_ (SwitchProgress QueueDirection
_ SwitchPhase
SPSecured ConnectionStats
_) = []
viewGroupMemberSwitch GroupInfo
g GroupMember
m (SwitchProgress QueueDirection
qd SwitchPhase
phase ConnectionStats
_) = case QueueDirection
qd of
  QueueDirection
QDRcv -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": you " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SwitchPhase -> StyledString
viewSwitchPhase SwitchPhase
phase StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" for " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m]
  QueueDirection
QDSnd -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SwitchPhase -> StyledString
viewSwitchPhase SwitchPhase
phase StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" for you"]

viewContactRatchetSync :: Contact -> RatchetSyncProgress -> [StyledString]
viewContactRatchetSync :: Contact -> RatchetSyncProgress -> [StyledString]
viewContactRatchetSync Contact
ct RatchetSyncProgress {ratchetSyncStatus :: RatchetSyncProgress -> RatchetSyncState
ratchetSyncStatus = RatchetSyncState
rss} =
  [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (RatchetSyncState -> ContactName)
-> RatchetSyncState
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RatchetSyncState -> ContactName
ratchetSyncStatusToText) RatchetSyncState
rss]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
help
  where
    help :: [StyledString]
help = [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/sync " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
ct) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to synchronize" | RatchetSyncState
rss RatchetSyncState -> [RatchetSyncState] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [RatchetSyncState
RSAllowed, RatchetSyncState
RSRequired]]

viewGroupMemberRatchetSync :: GroupInfo -> GroupMember -> RatchetSyncProgress -> [StyledString]
viewGroupMemberRatchetSync :: GroupInfo -> GroupMember -> RatchetSyncProgress -> [StyledString]
viewGroupMemberRatchetSync GroupInfo
g GroupMember
m RatchetSyncProgress {ratchetSyncStatus :: RatchetSyncProgress -> RatchetSyncState
ratchetSyncStatus = RatchetSyncState
rss} =
  [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString)
-> (RatchetSyncState -> ContactName)
-> RatchetSyncState
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RatchetSyncState -> ContactName
ratchetSyncStatusToText) RatchetSyncState
rss]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
help
  where
    help :: [StyledString]
help = [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/sync #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
viewMemberName GroupMember
m) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to synchronize" | RatchetSyncState
rss RatchetSyncState -> [RatchetSyncState] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [RatchetSyncState
RSAllowed, RatchetSyncState
RSRequired]]

viewContactVerificationReset :: Contact -> [StyledString]
viewContactVerificationReset :: Contact -> [StyledString]
viewContactVerificationReset Contact
ct =
  [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": security code changed"]

viewGroupMemberVerificationReset :: GroupInfo -> GroupMember -> [StyledString]
viewGroupMemberVerificationReset :: GroupInfo -> GroupMember -> [StyledString]
viewGroupMemberVerificationReset GroupInfo
g GroupMember
m =
  [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": security code changed"]

viewContactCode :: Contact -> Text -> Bool -> [StyledString]
viewContactCode :: Contact -> ContactName -> Bool -> [StyledString]
viewContactCode Contact
ct = StyledString
-> ContactName -> ContactName -> Bool -> [StyledString]
viewSecurityCode (Contact -> StyledString
ttyContact' Contact
ct) (ContactName
"/verify " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
ct ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" <code from your contact>")

viewGroupMemberCode :: GroupInfo -> GroupMember -> Text -> Bool -> [StyledString]
viewGroupMemberCode :: GroupInfo -> GroupMember -> ContactName -> Bool -> [StyledString]
viewGroupMemberCode GroupInfo
g GroupMember
m = StyledString
-> ContactName -> ContactName -> Bool -> [StyledString]
viewSecurityCode (GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m) (ContactName
"/verify #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
viewMemberName GroupMember
m ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" <code from your contact>")

viewSecurityCode :: StyledString -> Text -> Text -> Bool -> [StyledString]
viewSecurityCode :: StyledString
-> ContactName -> ContactName -> Bool -> [StyledString]
viewSecurityCode StyledString
name ContactName
cmd ContactName
code Bool
testView
  | Bool
testView = [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
code]
  | Bool
otherwise = [StyledString
name StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" security code:", ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
code, StyledString
"pass this code to your contact and use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight ContactName
cmd StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to verify"]

viewSwitchPhase :: SwitchPhase -> StyledString
viewSwitchPhase :: SwitchPhase -> StyledString
viewSwitchPhase = \case
  SwitchPhase
SPStarted -> StyledString
"started changing address"
  SwitchPhase
SPConfirmed -> StyledString
"confirmed changing address"
  SwitchPhase
SPSecured -> StyledString
"secured new address"
  SwitchPhase
SPCompleted -> StyledString
"changed address"

viewUserProfileUpdated :: Profile -> Profile -> UserProfileUpdateSummary -> [StyledString]
viewUserProfileUpdated :: Profile -> Profile -> UserProfileUpdateSummary -> [StyledString]
viewUserProfileUpdated Profile {displayName :: Profile -> ContactName
displayName = ContactName
n, ContactName
fullName :: Profile -> ContactName
fullName :: ContactName
fullName, Maybe ContactName
shortDescr :: Profile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr, Maybe ImageData
image :: Maybe ImageData
image :: Profile -> Maybe ImageData
image, Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink :: Profile -> Maybe ConnLinkContact
contactLink, Maybe Preferences
preferences :: Profile -> Maybe Preferences
preferences :: Maybe Preferences
preferences} Profile {displayName :: Profile -> ContactName
displayName = ContactName
n', fullName :: Profile -> ContactName
fullName = ContactName
fullName', shortDescr :: Profile -> Maybe ContactName
shortDescr = Maybe ContactName
shortDescr', image :: Profile -> Maybe ImageData
image = Maybe ImageData
image', contactLink :: Profile -> Maybe ConnLinkContact
contactLink = Maybe ConnLinkContact
contactLink', preferences :: Profile -> Maybe Preferences
preferences = Maybe Preferences
prefs'} UserProfileUpdateSummary
summary =
  [StyledString]
profileUpdated [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> Maybe Preferences -> Maybe Preferences -> [StyledString]
viewPrefsUpdated Maybe Preferences
preferences Maybe Preferences
prefs'
  where
    UserProfileUpdateSummary {updateSuccesses :: UserProfileUpdateSummary -> Int
updateSuccesses = Int
s, updateFailures :: UserProfileUpdateSummary -> Int
updateFailures = Int
f} = UserProfileUpdateSummary
summary
    profileUpdated :: [StyledString]
profileUpdated
      | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' Bool -> Bool -> Bool
&& Maybe ContactName
shortDescr Maybe ContactName -> Maybe ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ContactName
shortDescr' Bool -> Bool -> Bool
&& Maybe ImageData
image Maybe ImageData -> Maybe ImageData -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ImageData
image' Bool -> Bool -> Bool
&& Maybe ConnLinkContact
contactLink Maybe ConnLinkContact -> Maybe ConnLinkContact -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ConnLinkContact
contactLink' = []
      | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' Bool -> Bool -> Bool
&& Maybe ContactName
shortDescr Maybe ContactName -> Maybe ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ContactName
shortDescr' Bool -> Bool -> Bool
&& Maybe ImageData
image Maybe ImageData -> Maybe ImageData -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ImageData
image' = [if Maybe ConnLinkContact -> Bool
forall a. Maybe a -> Bool
isNothing Maybe ConnLinkContact
contactLink' then StyledString
"contact address removed" else StyledString
"new contact address set"]
      | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' Bool -> Bool -> Bool
&& Maybe ContactName
shortDescr Maybe ContactName -> Maybe ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ContactName
shortDescr' = [if Maybe ImageData -> Bool
forall a. Maybe a -> Bool
isNothing Maybe ImageData
image' then StyledString
"profile image removed" else StyledString
"profile image updated"]
      | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' = [StyledString
"user bio " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (if Bool -> (ContactName -> Bool) -> Maybe ContactName -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True ContactName -> Bool
T.null Maybe ContactName
shortDescr' then StyledString
"removed" else StyledString
"changed to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (ContactName -> StyledString)
-> Maybe ContactName
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"" ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain Maybe ContactName
shortDescr') StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
notified]
      | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' = [StyledString
"user full name " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (if ContactName -> Bool
T.null ContactName
fullName' Bool -> Bool -> Bool
|| ContactName
fullName' ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' then StyledString
"removed" else StyledString
"changed to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
fullName') StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
notified]
      | Bool
otherwise = [StyledString
"user profile is changed to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
n' ContactName
fullName' Maybe ContactName
shortDescr' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
notified]
    notified :: StyledString
notified = StyledString
" (your " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow Int
s StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" contacts are notified" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
failures StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"
    failures :: StyledString
failures
      | Int
f Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 = StyledString
", " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow Int
f StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" failures"
      | Bool
otherwise = StyledString
""

viewUserProfileImage :: Profile -> [StyledString]
viewUserProfileImage :: Profile -> [StyledString]
viewUserProfileImage Profile {Maybe ImageData
image :: Profile -> Maybe ImageData
image :: Maybe ImageData
image} = case Maybe ImageData
image of
  Just (ImageData ContactName
img) -> [StyledString
"Profile image:", ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
img]
  Maybe ImageData
_ -> [StyledString
"No profile image"]

viewUserContactPrefsUpdated :: User -> Contact -> Contact -> [StyledString]
viewUserContactPrefsUpdated :: User -> Contact -> Contact -> [StyledString]
viewUserContactPrefsUpdated User
user Contact
ct ct' :: Contact
ct'@Contact {mergedPreferences :: Contact -> ContactUserPreferences
mergedPreferences = ContactUserPreferences
cups}
  | [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
prefs = [StyledString
"your preferences for " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" did not change"]
  | Bool
otherwise = (StyledString
"you updated preferences for " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
":") StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
prefs
  where
    prefs :: [StyledString]
prefs = User
-> Contact -> Contact -> ContactUserPreferences -> [StyledString]
viewContactPreferences User
user Contact
ct Contact
ct' ContactUserPreferences
cups

viewContactPrefsUpdated :: User -> Contact -> Contact -> [StyledString]
viewContactPrefsUpdated :: User -> Contact -> Contact -> [StyledString]
viewContactPrefsUpdated User
user Contact
ct ct' :: Contact
ct'@Contact {mergedPreferences :: Contact -> ContactUserPreferences
mergedPreferences = ContactUserPreferences
cups}
  | [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
prefs = []
  | Bool
otherwise = (Contact -> StyledString
ttyContact' Contact
ct' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" updated preferences for you:") StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
prefs
  where
    prefs :: [StyledString]
prefs = User
-> Contact -> Contact -> ContactUserPreferences -> [StyledString]
viewContactPreferences User
user Contact
ct Contact
ct' ContactUserPreferences
cups

viewContactPreferences :: User -> Contact -> Contact -> ContactUserPreferences -> [StyledString]
viewContactPreferences :: User
-> Contact -> Contact -> ContactUserPreferences -> [StyledString]
viewContactPreferences User
user Contact
ct Contact
ct' ContactUserPreferences
cups =
  (AChatFeature -> Maybe StyledString)
-> [AChatFeature] -> [StyledString]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (FullPreferences
-> FullPreferences
-> Maybe Preferences
-> ContactUserPreferences
-> AChatFeature
-> Maybe StyledString
viewContactPref (User -> Contact -> FullPreferences
mergeUserChatPrefs User
user Contact
ct) (User -> Contact -> FullPreferences
mergeUserChatPrefs User
user Contact
ct') (Contact -> Maybe Preferences
forall a. IsContact a => a -> Maybe Preferences
preferences' Contact
ct) ContactUserPreferences
cups) [AChatFeature]
allChatFeatures

viewContactPref :: FullPreferences -> FullPreferences -> Maybe Preferences -> ContactUserPreferences -> AChatFeature -> Maybe StyledString
viewContactPref :: FullPreferences
-> FullPreferences
-> Maybe Preferences
-> ContactUserPreferences
-> AChatFeature
-> Maybe StyledString
viewContactPref FullPreferences
userPrefs FullPreferences
userPrefs' Maybe Preferences
ctPrefs ContactUserPreferences
cups (ACF SChatFeature f
f)
  | FeaturePreference f
userPref FeaturePreference f -> FeaturePreference f -> Bool
forall a. Eq a => a -> a -> Bool
== FeaturePreference f
userPref' Bool -> Bool -> Bool
&& FeaturePreference f
ctPref FeaturePreference f -> FeaturePreference f -> Bool
forall a. Eq a => a -> a -> Bool
== FeaturePreference f
contactPreference = Maybe StyledString
forall a. Maybe a
Nothing
  | Bool
otherwise = StyledString -> Maybe StyledString
forall a. a -> Maybe a
Just (StyledString -> Maybe StyledString)
-> (ContactName -> StyledString)
-> ContactName
-> Maybe StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> Maybe StyledString)
-> ContactName -> Maybe StyledString
forall a b. (a -> b) -> a -> b
$ SChatFeature f -> ContactName
forall (f :: ChatFeature). SChatFeature f -> ContactName
chatFeatureNameText' SChatFeature f
f ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
": " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ChatFeature -> PrefEnabled -> Maybe Int -> ContactName
prefEnabledToText (SChatFeature f -> ChatFeature
forall (f :: ChatFeature). SChatFeature f -> ChatFeature
chatFeature SChatFeature f
f) PrefEnabled
enabled (FeaturePreference f -> Maybe Int
forall (f :: ChatFeature).
FeatureI f =>
FeaturePreference f -> Maybe Int
prefParam FeaturePreference f
userPref') ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" (you allow: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactUserPref (FeaturePreference f) -> ContactName
forall (f :: ChatFeature).
FeatureI f =>
ContactUserPref (FeaturePreference f) -> ContactName
countactUserPrefText ContactUserPref (FeaturePreference f)
userPreference ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
", contact allows: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> FeaturePreference f -> ContactName
forall (f :: ChatFeature).
FeatureI f =>
FeaturePreference f -> ContactName
preferenceText FeaturePreference f
contactPreference ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
")"
  where
    userPref :: FeaturePreference f
userPref = SChatFeature f -> FullPreferences -> FeaturePreference f
forall p (f :: ChatFeature).
PreferenceI p =>
SChatFeature f -> p -> FeaturePreference f
forall (f :: ChatFeature).
SChatFeature f -> FullPreferences -> FeaturePreference f
getPreference SChatFeature f
f FullPreferences
userPrefs
    userPref' :: FeaturePreference f
userPref' = SChatFeature f -> FullPreferences -> FeaturePreference f
forall p (f :: ChatFeature).
PreferenceI p =>
SChatFeature f -> p -> FeaturePreference f
forall (f :: ChatFeature).
SChatFeature f -> FullPreferences -> FeaturePreference f
getPreference SChatFeature f
f FullPreferences
userPrefs'
    ctPref :: FeaturePreference f
ctPref = SChatFeature f -> Maybe Preferences -> FeaturePreference f
forall p (f :: ChatFeature).
PreferenceI p =>
SChatFeature f -> p -> FeaturePreference f
forall (f :: ChatFeature).
SChatFeature f -> Maybe Preferences -> FeaturePreference f
getPreference SChatFeature f
f Maybe Preferences
ctPrefs
    ContactUserPreference {PrefEnabled
enabled :: PrefEnabled
enabled :: forall p. ContactUserPreference p -> PrefEnabled
enabled, ContactUserPref (FeaturePreference f)
userPreference :: ContactUserPref (FeaturePreference f)
userPreference :: forall p. ContactUserPreference p -> ContactUserPref p
userPreference, FeaturePreference f
contactPreference :: FeaturePreference f
contactPreference :: forall p. ContactUserPreference p -> p
contactPreference} = SChatFeature f
-> ContactUserPreferences
-> ContactUserPreference (FeaturePreference f)
forall (f :: ChatFeature).
SChatFeature f
-> ContactUserPreferences
-> ContactUserPreference (FeaturePreference f)
getContactUserPreference SChatFeature f
f ContactUserPreferences
cups

viewPrefsUpdated :: Maybe Preferences -> Maybe Preferences -> [StyledString]
viewPrefsUpdated :: Maybe Preferences -> Maybe Preferences -> [StyledString]
viewPrefsUpdated Maybe Preferences
ps Maybe Preferences
ps'
  | [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
prefs = []
  | Bool
otherwise = StyledString
"updated preferences:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
prefs
  where
    prefs :: [StyledString]
prefs = (AChatFeature -> Maybe StyledString)
-> [AChatFeature] -> [StyledString]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe AChatFeature -> Maybe StyledString
viewPref [AChatFeature]
allChatFeatures
    viewPref :: AChatFeature -> Maybe StyledString
viewPref (ACF SChatFeature f
f)
      | Maybe Preferences -> FeaturePreference f
pref Maybe Preferences
ps FeaturePreference f -> FeaturePreference f -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe Preferences -> FeaturePreference f
pref Maybe Preferences
ps' = Maybe StyledString
forall a. Maybe a
Nothing
      | Bool
otherwise = StyledString -> Maybe StyledString
forall a. a -> Maybe a
Just (StyledString -> Maybe StyledString)
-> (ContactName -> StyledString)
-> ContactName
-> Maybe StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> Maybe StyledString)
-> ContactName -> Maybe StyledString
forall a b. (a -> b) -> a -> b
$ SChatFeature f -> ContactName
forall (f :: ChatFeature). SChatFeature f -> ContactName
chatFeatureNameText' SChatFeature f
f ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" allowed: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> FeaturePreference f -> ContactName
forall (f :: ChatFeature).
FeatureI f =>
FeaturePreference f -> ContactName
preferenceText (Maybe Preferences -> FeaturePreference f
pref Maybe Preferences
ps')
      where
        pref :: Maybe Preferences -> FeaturePreference f
pref Maybe Preferences
pss = SChatFeature f -> Maybe Preferences -> FeaturePreference f
forall p (f :: ChatFeature).
PreferenceI p =>
SChatFeature f -> p -> FeaturePreference f
forall (f :: ChatFeature).
SChatFeature f -> Maybe Preferences -> FeaturePreference f
getPreference SChatFeature f
f Maybe Preferences
pss

countactUserPrefText :: FeatureI f => ContactUserPref (FeaturePreference f) -> Text
countactUserPrefText :: forall (f :: ChatFeature).
FeatureI f =>
ContactUserPref (FeaturePreference f) -> ContactName
countactUserPrefText ContactUserPref (FeaturePreference f)
cup = case ContactUserPref (FeaturePreference f)
cup of
  CUPUser FeaturePreference f
p -> ContactName
"default (" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> FeaturePreference f -> ContactName
forall (f :: ChatFeature).
FeatureI f =>
FeaturePreference f -> ContactName
preferenceText FeaturePreference f
p ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
")"
  CUPContact FeaturePreference f
p -> FeaturePreference f -> ContactName
forall (f :: ChatFeature).
FeatureI f =>
FeaturePreference f -> ContactName
preferenceText FeaturePreference f
p

viewGroupUpdated :: GroupInfo -> GroupInfo -> Maybe GroupMember -> [StyledString]
viewGroupUpdated :: GroupInfo -> GroupInfo -> Maybe GroupMember -> [StyledString]
viewGroupUpdated
  GroupInfo {localDisplayName :: GroupInfo -> ContactName
localDisplayName = ContactName
n, groupProfile :: GroupInfo -> GroupProfile
groupProfile = GroupProfile {ContactName
fullName :: GroupProfile -> ContactName
fullName :: ContactName
fullName, Maybe ContactName
shortDescr :: GroupProfile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr, Maybe ContactName
description :: Maybe ContactName
description :: GroupProfile -> Maybe ContactName
description, Maybe ImageData
image :: Maybe ImageData
image :: GroupProfile -> Maybe ImageData
image, groupPreferences :: GroupProfile -> Maybe GroupPreferences
groupPreferences = Maybe GroupPreferences
gps, memberAdmission :: GroupProfile -> Maybe GroupMemberAdmission
memberAdmission = Maybe GroupMemberAdmission
ma}}
  g' :: GroupInfo
g'@GroupInfo {localDisplayName :: GroupInfo -> ContactName
localDisplayName = ContactName
n', groupProfile :: GroupInfo -> GroupProfile
groupProfile = GroupProfile {fullName :: GroupProfile -> ContactName
fullName = ContactName
fullName', shortDescr :: GroupProfile -> Maybe ContactName
shortDescr = Maybe ContactName
shortDescr', description :: GroupProfile -> Maybe ContactName
description = Maybe ContactName
description', image :: GroupProfile -> Maybe ImageData
image = Maybe ImageData
image', groupPreferences :: GroupProfile -> Maybe GroupPreferences
groupPreferences = Maybe GroupPreferences
gps', memberAdmission :: GroupProfile -> Maybe GroupMemberAdmission
memberAdmission = Maybe GroupMemberAdmission
ma'}}
  Maybe GroupMember
m = do
    let update :: [StyledString]
update = [StyledString]
groupProfileUpdated [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
groupPrefsUpdated [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
memberAdmissionUpdated
    if [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
update
      then []
      else [StyledString]
memberUpdated [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
update
    where
      memberUpdated :: [StyledString]
memberUpdated = [StyledString]
-> (GroupMember -> [StyledString])
-> Maybe GroupMember
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\GroupMember
m' -> [GroupMember -> StyledString
ttyMember GroupMember
m' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" updated group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyGroup ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
":"]) Maybe GroupMember
m
      groupProfileUpdated :: [StyledString]
groupProfileUpdated =
        [StyledString
"changed to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyFullGroup GroupInfo
g' | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
/= ContactName
n']
          [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"full name " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if ContactName -> Bool
T.null ContactName
fullName' Bool -> Bool -> Bool
|| ContactName
fullName' ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' then StyledString
"removed" else StyledString
"changed to: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
fullName' | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
/= ContactName
fullName']
          [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"description " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if Bool -> (ContactName -> Bool) -> Maybe ContactName -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True ContactName -> Bool
T.null Maybe ContactName
shortDescr' then StyledString
"removed" else StyledString
"changed to: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (ContactName -> StyledString)
-> Maybe ContactName
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"" ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain Maybe ContactName
shortDescr' | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' Bool -> Bool -> Bool
&& Maybe ContactName
shortDescr Maybe ContactName -> Maybe ContactName -> Bool
forall a. Eq a => a -> a -> Bool
/= Maybe ContactName
shortDescr']
          [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"profile image " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (ImageData -> StyledString) -> Maybe ImageData -> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"removed" (StyledString -> ImageData -> StyledString
forall a b. a -> b -> a
const StyledString
"updated") Maybe ImageData
image' | Maybe ImageData
image Maybe ImageData -> Maybe ImageData -> Bool
forall a. Eq a => a -> a -> Bool
/= Maybe ImageData
image']
          [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (if Maybe ContactName
description Maybe ContactName -> Maybe ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ContactName
description' then [] else [StyledString]
-> (ContactName -> [StyledString])
-> Maybe ContactName
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString
"welcome message removed"] ((String -> StyledString
bold' String
"welcome message changed to:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
:) ([StyledString] -> [StyledString])
-> (ContactName -> [StyledString]) -> ContactName -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ContactName] -> [StyledString])
-> (ContactName -> [ContactName]) -> ContactName -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> [ContactName]
T.lines) Maybe ContactName
description')
      groupPrefsUpdated :: [StyledString]
groupPrefsUpdated
        | [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
prefs = []
        | Bool
otherwise = String -> StyledString
bold' String
"updated group preferences:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
prefs
        where
          prefs :: [StyledString]
prefs = (AGroupFeature -> Maybe StyledString)
-> [AGroupFeature] -> [StyledString]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe AGroupFeature -> Maybe StyledString
viewPref [AGroupFeature]
allGroupFeatures
          viewPref :: AGroupFeature -> Maybe StyledString
viewPref (AGF SGroupFeature f
f)
            | Maybe GroupPreferences -> GroupFeaturePreference f
pref Maybe GroupPreferences
gps GroupFeaturePreference f -> GroupFeaturePreference f -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe GroupPreferences -> GroupFeaturePreference f
pref Maybe GroupPreferences
gps' = Maybe StyledString
forall a. Maybe a
Nothing
            | Bool
otherwise = StyledString -> Maybe StyledString
forall a. a -> Maybe a
Just (StyledString -> Maybe StyledString)
-> (ContactName -> StyledString)
-> ContactName
-> Maybe StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> Maybe StyledString)
-> ContactName -> Maybe StyledString
forall a b. (a -> b) -> a -> b
$ GroupFeaturePreference f -> ContactName
forall (f :: GroupFeature).
GroupFeatureI f =>
GroupFeaturePreference f -> ContactName
groupPreferenceText (Maybe GroupPreferences -> GroupFeaturePreference f
pref Maybe GroupPreferences
gps')
            where
              pref :: Maybe GroupPreferences -> GroupFeaturePreference f
pref = SGroupFeature f -> FullGroupPreferences -> GroupFeaturePreference f
forall p (f :: GroupFeature).
GroupPreferenceI p =>
SGroupFeature f -> p -> GroupFeaturePreference f
forall (f :: GroupFeature).
SGroupFeature f -> FullGroupPreferences -> GroupFeaturePreference f
getGroupPreference SGroupFeature f
f (FullGroupPreferences -> GroupFeaturePreference f)
-> (Maybe GroupPreferences -> FullGroupPreferences)
-> Maybe GroupPreferences
-> GroupFeaturePreference f
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe GroupPreferences -> FullGroupPreferences
mergeGroupPreferences
      memberAdmissionUpdated :: [StyledString]
memberAdmissionUpdated
        | Maybe GroupMemberAdmission
ma Maybe GroupMemberAdmission -> Maybe GroupMemberAdmission -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe GroupMemberAdmission
ma' = []
        | Bool
otherwise = [StyledString
"changed member admission rules"]

viewGroupProfile :: GroupInfo -> [StyledString]
viewGroupProfile :: GroupInfo -> [StyledString]
viewGroupProfile g :: GroupInfo
g@GroupInfo {groupProfile :: GroupInfo -> GroupProfile
groupProfile = GroupProfile {Maybe ContactName
shortDescr :: GroupProfile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr, Maybe ContactName
description :: GroupProfile -> Maybe ContactName
description :: Maybe ContactName
description, Maybe ImageData
image :: GroupProfile -> Maybe ImageData
image :: Maybe ImageData
image, groupPreferences :: GroupProfile -> Maybe GroupPreferences
groupPreferences = Maybe GroupPreferences
gps}} =
  [GroupInfo -> StyledString
ttyFullGroup GroupInfo
g]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (ContactName -> [StyledString])
-> Maybe ContactName
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ContactName
sd -> [StyledString
"description: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
sd]) Maybe ContactName
shortDescr
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (ImageData -> [StyledString])
-> Maybe ImageData
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ([StyledString] -> ImageData -> [StyledString]
forall a b. a -> b -> a
const [StyledString
"has profile image"]) Maybe ImageData
image
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
-> (ContactName -> [StyledString])
-> Maybe ContactName
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((String -> StyledString
bold' String
"welcome message:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
:) ([StyledString] -> [StyledString])
-> (ContactName -> [StyledString]) -> ContactName -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ContactName] -> [StyledString])
-> (ContactName -> [ContactName]) -> ContactName -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> [ContactName]
T.lines) Maybe ContactName
description
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (String -> StyledString
bold' String
"group preferences:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (AGroupFeature -> StyledString)
-> [AGroupFeature] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map AGroupFeature -> StyledString
viewPref [AGroupFeature]
allGroupFeatures)
  where
    viewPref :: AGroupFeature -> StyledString
viewPref (AGF SGroupFeature f
f) = ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ GroupFeaturePreference f -> ContactName
forall (f :: GroupFeature).
GroupFeatureI f =>
GroupFeaturePreference f -> ContactName
groupPreferenceText (Maybe GroupPreferences -> GroupFeaturePreference f
pref Maybe GroupPreferences
gps)
      where
        pref :: Maybe GroupPreferences -> GroupFeaturePreference f
pref = SGroupFeature f -> FullGroupPreferences -> GroupFeaturePreference f
forall p (f :: GroupFeature).
GroupPreferenceI p =>
SGroupFeature f -> p -> GroupFeaturePreference f
forall (f :: GroupFeature).
SGroupFeature f -> FullGroupPreferences -> GroupFeaturePreference f
getGroupPreference SGroupFeature f
f (FullGroupPreferences -> GroupFeaturePreference f)
-> (Maybe GroupPreferences -> FullGroupPreferences)
-> Maybe GroupPreferences
-> GroupFeaturePreference f
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe GroupPreferences -> FullGroupPreferences
mergeGroupPreferences

viewGroupDescription :: GroupInfo -> [StyledString]
viewGroupDescription :: GroupInfo -> [StyledString]
viewGroupDescription GroupInfo {groupProfile :: GroupInfo -> GroupProfile
groupProfile = GroupProfile {Maybe ContactName
description :: GroupProfile -> Maybe ContactName
description :: Maybe ContactName
description}} =
  [StyledString]
-> (ContactName -> [StyledString])
-> Maybe ContactName
-> [StyledString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [StyledString
"No welcome message!"] ((String -> StyledString
bold' String
"Welcome message:" StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
:) ([StyledString] -> [StyledString])
-> (ContactName -> [StyledString]) -> ContactName -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ContactName] -> [StyledString])
-> (ContactName -> [ContactName]) -> ContactName -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> [ContactName]
T.lines) Maybe ContactName
description

bold' :: String -> StyledString
bold' :: String -> StyledString
bold' = Format -> String -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled Format
Bold

viewContactAliasUpdated :: Contact -> [StyledString]
viewContactAliasUpdated :: Contact -> [StyledString]
viewContactAliasUpdated ct :: Contact
ct@Contact {profile :: Contact -> LocalProfile
profile = LocalProfile {ContactName
localAlias :: LocalProfile -> ContactName
localAlias :: ContactName
localAlias}}
  | ContactName
localAlias ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
"" = [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" alias removed"]
  | Bool
otherwise = [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" alias updated: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
localAlias]

viewGroupAliasUpdated :: GroupInfo -> [StyledString]
viewGroupAliasUpdated :: GroupInfo -> [StyledString]
viewGroupAliasUpdated g :: GroupInfo
g@GroupInfo {ContactName
localAlias :: GroupInfo -> ContactName
localAlias :: ContactName
localAlias}
  | ContactName
localAlias ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
"" = [StyledString
"group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" alias removed"]
  | Bool
otherwise = [StyledString
"group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" alias updated: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
localAlias]

viewConnectionAliasUpdated :: PendingContactConnection -> [StyledString]
viewConnectionAliasUpdated :: PendingContactConnection -> [StyledString]
viewConnectionAliasUpdated PendingContactConnection {ContactId
pccConnId :: PendingContactConnection -> ContactId
pccConnId :: ContactId
pccConnId, ContactName
localAlias :: ContactName
localAlias :: PendingContactConnection -> ContactName
localAlias}
  | ContactName
localAlias ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
"" = [StyledString
"connection " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
pccConnId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" alias removed"]
  | Bool
otherwise = [StyledString
"connection " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
pccConnId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" alias updated: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
localAlias]

viewConnectionIncognitoUpdated :: PendingContactConnection -> Maybe Profile -> Bool -> [StyledString]
viewConnectionIncognitoUpdated :: PendingContactConnection -> Maybe Profile -> Bool -> [StyledString]
viewConnectionIncognitoUpdated PendingContactConnection {ContactId
pccConnId :: PendingContactConnection -> ContactId
pccConnId :: ContactId
pccConnId, Maybe ContactId
customUserProfileId :: Maybe ContactId
customUserProfileId :: PendingContactConnection -> Maybe ContactId
customUserProfileId} Maybe Profile
incognitoProfile Bool
testView
  | Maybe ContactId -> Bool
forall a. Maybe a -> Bool
isJust Maybe ContactId
customUserProfileId =
      case Maybe Profile
incognitoProfile of
        Just Profile
profile
          | Bool
testView -> Profile -> StyledString
incognitoProfile' Profile
profile StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
message
          | Bool
otherwise -> [StyledString]
message
          where message :: [StyledString]
message = [StyledString
"connection " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
pccConnId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" changed to incognito"]
        Maybe Profile
Nothing -> [StyledString
"unexpected response when changing connection, please report to developers"]
  | Bool
otherwise = [StyledString
"connection " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
pccConnId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" changed to non incognito"]

viewConnectionUserChanged :: User -> PendingContactConnection -> User -> PendingContactConnection -> [StyledString]
viewConnectionUserChanged :: User
-> PendingContactConnection
-> User
-> PendingContactConnection
-> [StyledString]
viewConnectionUserChanged User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
n} PendingContactConnection {ContactId
pccConnId :: PendingContactConnection -> ContactId
pccConnId :: ContactId
pccConnId} User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
n'} PendingContactConnection {connLinkInv :: PendingContactConnection -> Maybe CreatedLinkInvitation
connLinkInv = Maybe CreatedLinkInvitation
connLinkInv'} =
  case Maybe CreatedLinkInvitation
connLinkInv' of
    Just CreatedLinkInvitation
ccLink' -> [StyledString
userChangedStr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", new link:"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> CreatedLinkInvitation -> [StyledString]
newLink CreatedLinkInvitation
ccLink'
    Maybe CreatedLinkInvitation
_ -> [StyledString
userChangedStr]
  where
    userChangedStr :: StyledString
userChangedStr = StyledString
"connection " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
pccConnId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" changed from user " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to user " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
n'
    newLink :: CreatedLinkInvitation -> [StyledString]
newLink (CCLink ConnReqInvitation
cReq Maybe (ConnShortLink 'CMInvitation)
shortLink) =
      [ StyledString
"",
        ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ ByteString
-> (ConnShortLink 'CMInvitation -> ByteString)
-> Maybe (ConnShortLink 'CMInvitation)
-> ByteString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ByteString
cReqStr ConnShortLink 'CMInvitation -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode Maybe (ConnShortLink 'CMInvitation)
shortLink,
        StyledString
""
      ]
        [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<>
          if Maybe (ConnShortLink 'CMInvitation) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (ConnShortLink 'CMInvitation)
shortLink
            then
              [ StyledString
"The invitation link for old clients:",
                ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ByteString
cReqStr
              ]
            else []
      where
        cReqStr :: ByteString
cReqStr = ConnReqInvitation -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode (ConnReqInvitation -> ByteString)
-> ConnReqInvitation -> ByteString
forall a b. (a -> b) -> a -> b
$ ConnReqInvitation -> ConnReqInvitation
simplexChatInvitation ConnReqInvitation
cReq

viewContactUserChanged :: User -> Contact -> User -> Contact -> [StyledString]
viewContactUserChanged :: User -> Contact -> User -> Contact -> [StyledString]
viewContactUserChanged
  User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
un}
  ct :: Contact
ct@Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
cn}
  User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
un'}
  Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
cn'}
    | ContactName
cn' ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
/= ContactName
cn = [StyledString
userChangedStr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", new local name: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
cn']
    | Bool
otherwise = [StyledString
userChangedStr]
  where
    userChangedStr :: StyledString
userChangedStr = StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" changed from user " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
un StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to user " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
un'

viewGroupUserChanged :: User -> GroupInfo -> User -> GroupInfo -> [StyledString]
viewGroupUserChanged :: User -> GroupInfo -> User -> GroupInfo -> [StyledString]
viewGroupUserChanged
  User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
un}
  g :: GroupInfo
g@GroupInfo {localDisplayName :: GroupInfo -> ContactName
localDisplayName = ContactName
gn}
  User {localDisplayName :: User -> ContactName
localDisplayName = ContactName
un'}
  GroupInfo {localDisplayName :: GroupInfo -> ContactName
localDisplayName = ContactName
gn'}
    | ContactName
gn' ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
/= ContactName
gn = [StyledString
userChangedStr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", new local name: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyGroup ContactName
gn']
    | Bool
otherwise = [StyledString
userChangedStr]
  where
    userChangedStr :: StyledString
userChangedStr = StyledString
"group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" changed from user " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
un StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to user " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
un'

viewConnectionPlan :: ChatConfig -> ACreatedConnLink -> ConnectionPlan -> [StyledString]
viewConnectionPlan :: ChatConfig -> ACreatedConnLink -> ConnectionPlan -> [StyledString]
viewConnectionPlan ChatConfig {ChatLogLevel
logLevel :: ChatConfig -> ChatLogLevel
logLevel :: ChatLogLevel
logLevel, Bool
testView :: ChatConfig -> Bool
testView :: Bool
testView} ACreatedConnLink
_connLink = \case
  CPInvitationLink InvitationLinkPlan
ilp -> case InvitationLinkPlan
ilp of
    ILPOk Maybe ContactShortLinkData
contactSLinkData -> [Maybe ContactShortLinkData -> StyledString -> StyledString
invOrBiz Maybe ContactShortLinkData
contactSLinkData StyledString
"ok to connect"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [Maybe ContactShortLinkData -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON Maybe ContactShortLinkData
contactSLinkData | Bool
testView]
    InvitationLinkPlan
ILPOwnLink -> [StyledString -> StyledString
invLink StyledString
"own link"]
    ILPConnecting Maybe Contact
Nothing -> [StyledString -> StyledString
invLink StyledString
"connecting"]
    ILPConnecting (Just Contact
ct) -> [StyledString -> StyledString
invLink (StyledString
"connecting to contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct)]
    ILPKnown Contact
ct
      | Contact -> Bool
nextConnectPrepared Contact
ct -> [StyledString -> StyledString
invLink (StyledString
"known prepared contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct)]
      | Contact -> Bool
contactDeleted Contact
ct -> [StyledString -> StyledString
invLink (StyledString
"known deleted contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct)]
      | Bool
otherwise ->
          [ StyledString -> StyledString
invLink (StyledString
"known contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct),
            StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyToContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"<message>" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to send messages"
          ]
    where
      invLink :: StyledString -> StyledString
invLink = (StyledString
"invitation link: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>)
      invOrBiz :: Maybe ContactShortLinkData -> StyledString -> StyledString
invOrBiz = \case
        Just ContactShortLinkData {Bool
business :: Bool
business :: ContactShortLinkData -> Bool
business}
          | Bool
business -> (StyledString
"business address: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>)
        Maybe ContactShortLinkData
_ -> (StyledString
"invitation link: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>)
  CPContactAddress ContactAddressPlan
cap -> case ContactAddressPlan
cap of
    CAPOk Maybe ContactShortLinkData
contactSLinkData -> [Maybe ContactShortLinkData -> StyledString -> StyledString
addrOrBiz Maybe ContactShortLinkData
contactSLinkData StyledString
"ok to connect"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [Maybe ContactShortLinkData -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON Maybe ContactShortLinkData
contactSLinkData | Bool
testView]
    ContactAddressPlan
CAPOwnLink -> [StyledString -> StyledString
ctAddr StyledString
"own address"]
    ContactAddressPlan
CAPConnectingConfirmReconnect -> [StyledString -> StyledString
ctAddr StyledString
"connecting, allowed to reconnect"]
    CAPConnectingProhibit Contact
ct -> [StyledString -> StyledString
ctAddr (StyledString
"connecting to contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct)]
    CAPKnown Contact
ct
      | Contact -> Bool
nextConnectPrepared Contact
ct -> [StyledString -> StyledString
ctAddr (StyledString
"known prepared contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct)]
      | Bool
otherwise ->
          [ StyledString -> StyledString
ctAddr (StyledString
"known contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct),
            StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyToContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"<message>" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to send messages"
          ]
    CAPContactViaAddress Contact
ct -> [StyledString -> StyledString
ctAddr (StyledString
"known contact without connection " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct)]
    where
      ctAddr :: StyledString -> StyledString
ctAddr = (StyledString
"contact address: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>)
      addrOrBiz :: Maybe ContactShortLinkData -> StyledString -> StyledString
addrOrBiz = \case
        Just ContactShortLinkData {Bool
business :: ContactShortLinkData -> Bool
business :: Bool
business}
          | Bool
business -> (StyledString
"business address: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>)
        Maybe ContactShortLinkData
_ -> (StyledString
"contact address: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>)
  CPGroupLink GroupLinkPlan
glp -> case GroupLinkPlan
glp of
    GLPOk Maybe GroupShortLinkData
groupSLinkData -> [StyledString -> StyledString
grpLink StyledString
"ok to connect"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [Maybe GroupShortLinkData -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON Maybe GroupShortLinkData
groupSLinkData | Bool
testView]
    GLPOwnLink GroupInfo
g -> [StyledString -> StyledString
grpLink StyledString
"own link for group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g]
    GroupLinkPlan
GLPConnectingConfirmReconnect -> [StyledString -> StyledString
grpLink StyledString
"connecting, allowed to reconnect"]
    GLPConnectingProhibit Maybe GroupInfo
Nothing -> [StyledString -> StyledString
grpLink StyledString
"connecting"]
    GLPConnectingProhibit (Just GroupInfo
g) -> GroupInfo -> [StyledString]
connecting GroupInfo
g
    GLPKnown g :: GroupInfo
g@GroupInfo {Maybe PreparedGroup
preparedGroup :: Maybe PreparedGroup
preparedGroup :: GroupInfo -> Maybe PreparedGroup
preparedGroup, membership :: GroupInfo -> GroupMember
membership = GroupMember
m} -> case Maybe PreparedGroup
preparedGroup of
      Just PreparedGroup {Bool
connLinkStartedConnection :: Bool
connLinkStartedConnection :: PreparedGroup -> Bool
connLinkStartedConnection} -> case GroupMember -> GroupMemberStatus
memberStatus GroupMember
m of
        GroupMemberStatus
GSMemUnknown
          | Bool
connLinkStartedConnection -> GroupInfo -> [StyledString]
connecting GroupInfo
g
          | Bool
otherwise -> [StyledString -> StyledString
knownGroup StyledString
"prepared "]
        GroupMemberStatus
GSMemAccepted -> GroupInfo -> [StyledString]
connecting GroupInfo
g
        GroupMemberStatus
_
          | GroupMember -> Bool
memberRemoved GroupMember
m -> [StyledString -> StyledString
knownGroup StyledString
"deleted "] -- it should not get here, as this plan is returned as GLPOk
          | Bool
otherwise -> [StyledString]
knownActive
      Maybe PreparedGroup
_ -> [StyledString]
knownActive
      where
        knownActive :: [StyledString]
knownActive =
          [ StyledString -> StyledString
knownGroup StyledString
"",
            StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroup GroupInfo
g Maybe GroupChatScopeInfo
forall a. Maybe a
Nothing StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"<message>" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to send messages"
          ]
        knownGroup :: StyledString -> StyledString
knownGroup StyledString
prepared = GroupInfo -> StyledString
forall {a}. IsString a => GroupInfo -> a
grpOrBizLink GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": known " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
prepared StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
forall {a}. IsString a => GroupInfo -> a
grpOrBiz GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g
    where
      connecting :: GroupInfo -> [StyledString]
connecting GroupInfo
g = [GroupInfo -> StyledString
forall {a}. IsString a => GroupInfo -> a
grpOrBizLink GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": connecting to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
forall {a}. IsString a => GroupInfo -> a
grpOrBiz GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g]
      grpLink :: StyledString -> StyledString
grpLink = (StyledString
"group link: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>)
      grpOrBizLink :: GroupInfo -> a
grpOrBizLink GroupInfo {Maybe BusinessChatInfo
businessChat :: Maybe BusinessChatInfo
businessChat :: GroupInfo -> Maybe BusinessChatInfo
businessChat} = case Maybe BusinessChatInfo
businessChat of
        Just BusinessChatInfo
_ -> a
"business address"
        Maybe BusinessChatInfo
Nothing -> a
"group link"
      grpOrBiz :: GroupInfo -> a
grpOrBiz GroupInfo {Maybe BusinessChatInfo
businessChat :: GroupInfo -> Maybe BusinessChatInfo
businessChat :: Maybe BusinessChatInfo
businessChat} = case Maybe BusinessChatInfo
businessChat of
        Just BusinessChatInfo
_ -> a
"business"
        Maybe BusinessChatInfo
Nothing -> a
"group"
  CPError ChatError
e -> Bool -> ChatLogLevel -> Bool -> ChatError -> [StyledString]
viewChatError Bool
False ChatLogLevel
logLevel Bool
testView ChatError
e
  where
    nextConnectPrepared :: Contact -> Bool
nextConnectPrepared Contact {Maybe PreparedContact
preparedContact :: Maybe PreparedContact
preparedContact :: Contact -> Maybe PreparedContact
preparedContact, Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = case Maybe PreparedContact
preparedContact of
      Just PreparedContact
_ -> Bool -> (Connection -> Bool) -> Maybe Connection -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True (\Connection
c -> Connection -> ConnStatus
connStatus Connection
c ConnStatus -> ConnStatus -> Bool
forall a. Eq a => a -> a -> Bool
== ConnStatus
ConnPrepared) Maybe Connection
activeConn
      Maybe PreparedContact
_ -> Bool
False

viewContactUpdated :: Contact -> Contact -> [StyledString]
viewContactUpdated :: Contact -> Contact -> [StyledString]
viewContactUpdated
  Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
n, profile :: Contact -> LocalProfile
profile = LocalProfile {ContactName
fullName :: LocalProfile -> ContactName
fullName :: ContactName
fullName, Maybe ContactName
shortDescr :: LocalProfile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr, Maybe ConnLinkContact
contactLink :: LocalProfile -> Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink}}
  Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
n', profile :: Contact -> LocalProfile
profile = LocalProfile {fullName :: LocalProfile -> ContactName
fullName = ContactName
fullName', shortDescr :: LocalProfile -> Maybe ContactName
shortDescr = Maybe ContactName
shortDescr', contactLink :: LocalProfile -> Maybe ConnLinkContact
contactLink = Maybe ConnLinkContact
contactLink'}}
    | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' Bool -> Bool -> Bool
&& Maybe ContactName
shortDescr Maybe ContactName -> Maybe ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ContactName
shortDescr' Bool -> Bool -> Bool
&& Maybe ConnLinkContact
contactLink Maybe ConnLinkContact -> Maybe ConnLinkContact -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ConnLinkContact
contactLink' = []
    | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' Bool -> Bool -> Bool
&& Maybe ContactName
shortDescr Maybe ContactName -> Maybe ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ContactName
shortDescr' =
        if Maybe ConnLinkContact -> Bool
forall a. Maybe a -> Bool
isNothing Maybe ConnLinkContact
contactLink'
          then [ContactName -> StyledString
ttyContact ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" removed contact address"]
          else [ContactName -> StyledString
ttyContact ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" set new contact address, use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/info " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
n) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to view"]
    | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' Bool -> Bool -> Bool
&& ContactName
fullName ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
fullName' =
        if Bool -> (ContactName -> Bool) -> Maybe ContactName -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True ContactName -> Bool
T.null Maybe ContactName
shortDescr'
          then [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" removed bio"]
          else [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" updated bio: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (ContactName -> StyledString)
-> Maybe ContactName
-> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"" ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain Maybe ContactName
shortDescr']
    | ContactName
n ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' = [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fullNameUpdate]
    | Bool
otherwise =
        [ StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
n StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" changed to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
n' ContactName
fullName' Maybe ContactName
shortDescr',
          StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyToContact ContactName
n' StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"<message>" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to send messages"
        ]
    where
      fullNameUpdate :: StyledString
fullNameUpdate = if ContactName -> Bool
T.null ContactName
fullName' Bool -> Bool -> Bool
|| ContactName
fullName' ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
n' then StyledString
" removed full name" else StyledString
" updated full name: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
fullName'

viewReceivedMessage :: StyledString -> [StyledString] -> MsgContent -> CurrentTime -> TimeZone -> CIMeta c d -> [StyledString]
viewReceivedMessage :: forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedMessage = Bool
-> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
Bool
-> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedMessage_ Bool
False

viewReceivedUpdatedMessage :: StyledString -> [StyledString] -> MsgContent -> CurrentTime -> TimeZone -> CIMeta c d -> [StyledString]
viewReceivedUpdatedMessage :: forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedUpdatedMessage = Bool
-> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
Bool
-> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedMessage_ Bool
True

viewReceivedMessage_ :: Bool -> StyledString -> [StyledString] -> MsgContent -> CurrentTime -> TimeZone -> CIMeta c d -> [StyledString]
viewReceivedMessage_ :: forall (c :: ChatType) (d :: MsgDirection).
Bool
-> StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewReceivedMessage_ Bool
updated StyledString
from [StyledString]
context MsgContent
mc UTCTime
ts TimeZone
tz CIMeta c d
meta = UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz StyledString
from [StyledString]
context CIMeta c d
meta (MsgContent -> [StyledString]
ttyMsgContent MsgContent
mc) Bool
updated

viewReceivedReaction :: StyledString -> [StyledString] -> StyledString -> CurrentTime -> TimeZone -> UTCTime -> [StyledString]
viewReceivedReaction :: StyledString
-> [StyledString]
-> StyledString
-> UTCTime
-> TimeZone
-> UTCTime
-> [StyledString]
viewReceivedReaction StyledString
from [StyledString]
styledMsg StyledString
reactionText UTCTime
ts TimeZone
tz UTCTime
reactionTs =
  StyledString -> [StyledString] -> [StyledString]
prependFirst (UTCTime -> TimeZone -> UTCTime -> StyledString
ttyMsgTime UTCTime
ts TimeZone
tz UTCTime
reactionTs StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
from) ([StyledString]
styledMsg [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"    " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
reactionText])

receivedWithTime_ :: CurrentTime -> TimeZone -> StyledString -> [StyledString] -> CIMeta c d -> [StyledString] -> Bool -> [StyledString]
receivedWithTime_ :: forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz StyledString
from [StyledString]
context CIMeta {ContactId
itemId :: ContactId
itemId :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> ContactId
itemId, UTCTime
itemTs :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> UTCTime
itemTs :: UTCTime
itemTs, Bool
itemEdited :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> Bool
itemEdited :: Bool
itemEdited, Maybe (CIDeleted c)
itemDeleted :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe (CIDeleted c)
itemDeleted :: Maybe (CIDeleted c)
itemDeleted, Maybe Bool
itemLive :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe Bool
itemLive :: Maybe Bool
itemLive} [StyledString]
styledMsg Bool
updated = do
  StyledString -> [StyledString] -> [StyledString]
prependFirst (UTCTime -> TimeZone -> UTCTime -> StyledString
ttyMsgTime UTCTime
ts TimeZone
tz UTCTime
itemTs StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
from) ([StyledString]
context [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> StyledString -> [StyledString] -> [StyledString]
prependFirst (StyledString
indent StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
live) [StyledString]
styledMsg)
  where
    indent :: StyledString
indent = if [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
context then StyledString
"" else StyledString
"      "
    live :: StyledString
live
      | Bool
itemEdited Bool -> Bool -> Bool
|| Maybe (CIDeleted c) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (CIDeleted c)
itemDeleted = StyledString
""
      | Bool
otherwise = case Maybe Bool
itemLive of
          Just Bool
True
            | Bool
updated -> ContactName -> StyledString
ttyFrom ContactName
"[LIVE] "
            | Bool
otherwise -> ContactName -> StyledString
ttyFrom ContactName
"[LIVE started]" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' (String
"/show [on/off/" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
itemId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"] ")
          Just Bool
False -> ContactName -> StyledString
ttyFrom ContactName
"[LIVE ended] "
          Maybe Bool
_ -> StyledString
""

ttyMsgTime :: CurrentTime -> TimeZone -> UTCTime -> StyledString
ttyMsgTime :: UTCTime -> TimeZone -> UTCTime -> StyledString
ttyMsgTime UTCTime
now TimeZone
tz UTCTime
time =
  let fmt :: String
fmt = if UTCTime -> TimeZone -> UTCTime -> Bool
recent UTCTime
now TimeZone
tz UTCTime
time then String
"%H:%M" else String
"%m-%d"
      localTime :: LocalTime
localTime = TimeZone -> UTCTime -> LocalTime
utcToLocalTime TimeZone
tz UTCTime
time
   in String -> StyledString
styleTime (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ TimeLocale -> String -> LocalTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
fmt LocalTime
localTime

recent :: CurrentTime -> TimeZone -> UTCTime -> Bool
recent :: UTCTime -> TimeZone -> UTCTime -> Bool
recent UTCTime
now TimeZone
tz UTCTime
time = do
  let localNow :: LocalTime
localNow = TimeZone -> UTCTime -> LocalTime
utcToLocalTime TimeZone
tz UTCTime
now
      localNowDay :: Day
localNowDay = LocalTime -> Day
localDay LocalTime
localNow
      localTime :: LocalTime
localTime = TimeZone -> UTCTime -> LocalTime
utcToLocalTime TimeZone
tz UTCTime
time
      localTimeDay :: Day
localTimeDay = LocalTime -> Day
localDay LocalTime
localTime
      previousDay18 :: LocalTime
previousDay18 = Day -> TimeOfDay -> LocalTime
LocalTime (Integer -> Day -> Day
addDays (-Integer
1) Day
localNowDay) (Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
18 Int
0 Pico
0)
      currentDay12 :: LocalTime
currentDay12 = Day -> TimeOfDay -> LocalTime
LocalTime Day
localNowDay (Int -> Int -> Pico -> TimeOfDay
TimeOfDay Int
12 Int
0 Pico
0)
  Day
localNowDay Day -> Day -> Bool
forall a. Eq a => a -> a -> Bool
== Day
localTimeDay
    Bool -> Bool -> Bool
|| (LocalTime
localNow LocalTime -> LocalTime -> Bool
forall a. Ord a => a -> a -> Bool
< LocalTime
currentDay12 Bool -> Bool -> Bool
&& LocalTime
localTime LocalTime -> LocalTime -> Bool
forall a. Ord a => a -> a -> Bool
>= LocalTime
previousDay18 Bool -> Bool -> Bool
&& Day
localTimeDay Day -> Day -> Bool
forall a. Ord a => a -> a -> Bool
< Day
localNowDay)

viewSentMessage :: StyledString -> [StyledString] -> MsgContent -> CurrentTime -> TimeZone -> CIMeta c d -> [StyledString]
viewSentMessage :: forall (c :: ChatType) (d :: MsgDirection).
StyledString
-> [StyledString]
-> MsgContent
-> UTCTime
-> TimeZone
-> CIMeta c d
-> [StyledString]
viewSentMessage StyledString
to [StyledString]
context MsgContent
mc UTCTime
ts TimeZone
tz meta :: CIMeta c d
meta@CIMeta {Bool
itemEdited :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> Bool
itemEdited :: Bool
itemEdited, Maybe (CIDeleted c)
itemDeleted :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe (CIDeleted c)
itemDeleted :: Maybe (CIDeleted c)
itemDeleted, Maybe Bool
itemLive :: forall (c :: ChatType) (d :: MsgDirection).
CIMeta c d -> Maybe Bool
itemLive :: Maybe Bool
itemLive} = UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
sentWithTime_ UTCTime
ts TimeZone
tz (StyledString -> [StyledString] -> [StyledString]
prependFirst StyledString
to ([StyledString] -> [StyledString])
-> [StyledString] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ [StyledString]
context [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> StyledString -> [StyledString] -> [StyledString]
prependFirst (StyledString
indent StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
live) (MsgContent -> [StyledString]
ttyMsgContent MsgContent
mc)) CIMeta c d
meta
  where
    indent :: StyledString
indent = if [StyledString] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [StyledString]
context then StyledString
"" else StyledString
"      "
    live :: StyledString
live
      | Bool
itemEdited Bool -> Bool -> Bool
|| Maybe (CIDeleted c) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (CIDeleted c)
itemDeleted = StyledString
""
      | Bool
otherwise = case Maybe Bool
itemLive of
          Just Bool
True -> ContactName -> StyledString
ttyTo ContactName
"[LIVE started] "
          Just Bool
False -> ContactName -> StyledString
ttyTo ContactName
"[LIVE] "
          Maybe Bool
_ -> StyledString
""

viewSentBroadcast :: MsgContent -> Int -> Int -> CurrentTime -> TimeZone -> UTCTime -> [StyledString]
viewSentBroadcast :: MsgContent
-> Int -> Int -> UTCTime -> TimeZone -> UTCTime -> [StyledString]
viewSentBroadcast MsgContent
mc Int
s Int
f UTCTime
ts TimeZone
tz UTCTime
time = StyledString -> [StyledString] -> [StyledString]
prependFirst (String -> StyledString
highlight' String
"/feed" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow Int
s StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
failures StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
") " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> UTCTime -> TimeZone -> UTCTime -> StyledString
ttyMsgTime UTCTime
ts TimeZone
tz UTCTime
time StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ") (MsgContent -> [StyledString]
ttyMsgContent MsgContent
mc)
  where
    failures :: StyledString
failures
      | Int
f Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 = StyledString
", " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Int -> StyledString
forall a. Show a => a -> StyledString
sShow Int
f StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" failures"
      | Bool
otherwise = StyledString
""

viewSentFileInvitation :: StyledString -> CIFile d -> CurrentTime -> TimeZone -> CIMeta c d -> [StyledString]
viewSentFileInvitation :: forall (d :: MsgDirection) (c :: ChatType).
StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
viewSentFileInvitation StyledString
to CIFile {ContactId
fileId :: ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId, Maybe CryptoFile
fileSource :: forall (d :: MsgDirection). CIFile d -> Maybe CryptoFile
fileSource :: Maybe CryptoFile
fileSource, CIFileStatus d
fileStatus :: CIFileStatus d
fileStatus :: forall (d :: MsgDirection). CIFile d -> CIFileStatus d
fileStatus} UTCTime
ts TimeZone
tz = case Maybe CryptoFile
fileSource of
  Just (CryptoFile String
fPath Maybe CryptoFileArgs
_) -> UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
sentWithTime_ UTCTime
ts TimeZone
tz ([StyledString] -> CIMeta c d -> [StyledString])
-> [StyledString] -> CIMeta c d -> [StyledString]
forall a b. (a -> b) -> a -> b
$ String -> [StyledString]
ttySentFile String
fPath
  Maybe CryptoFile
_ -> [StyledString] -> CIMeta c d -> [StyledString]
forall a b. a -> b -> a
const []
  where
    ttySentFile :: String -> [StyledString]
ttySentFile String
fPath = [StyledString
"/f " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
to StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
ttyFilePath String
fPath] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
cancelSending
    cancelSending :: [StyledString]
cancelSending = case CIFileStatus d
fileStatus of
      CIFSSndTransfer ContactId
_ ContactId
_ -> []
      CIFileStatus d
_ -> [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/fc " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
fileId) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to cancel sending"]

sentWithTime_ :: CurrentTime -> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
sentWithTime_ :: forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
sentWithTime_ UTCTime
ts TimeZone
tz [StyledString]
styledMsg CIMeta {UTCTime
itemTs :: forall (c :: ChatType) (d :: MsgDirection). CIMeta c d -> UTCTime
itemTs :: UTCTime
itemTs} =
  StyledString -> [StyledString] -> [StyledString]
prependFirst (UTCTime -> TimeZone -> UTCTime -> StyledString
ttyMsgTime UTCTime
ts TimeZone
tz UTCTime
itemTs StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" ") [StyledString]
styledMsg

ttyMsgContent :: MsgContent -> [StyledString]
ttyMsgContent :: MsgContent -> [StyledString]
ttyMsgContent = ContactName -> [StyledString]
msgPlain (ContactName -> [StyledString])
-> (MsgContent -> ContactName) -> MsgContent -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MsgContent -> ContactName
msgContentText

prependFirst :: StyledString -> [StyledString] -> [StyledString]
prependFirst :: StyledString -> [StyledString] -> [StyledString]
prependFirst StyledString
s [] = [StyledString
s]
prependFirst StyledString
s (StyledString
s' : [StyledString]
ss) = (StyledString
s StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
s') StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: [StyledString]
ss

msgPlain :: Text -> [StyledString]
msgPlain :: ContactName -> [StyledString]
msgPlain = (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (MarkdownList -> StyledString
styleMarkdownList (MarkdownList -> StyledString)
-> (ContactName -> MarkdownList) -> ContactName -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> MarkdownList
parseMarkdownList) ([ContactName] -> [StyledString])
-> (ContactName -> [ContactName]) -> ContactName -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> [ContactName]
T.lines

viewRcvFileSndCancelled :: RcvFileTransfer -> [StyledString]
viewRcvFileSndCancelled :: RcvFileTransfer -> [StyledString]
viewRcvFileSndCancelled ft :: RcvFileTransfer
ft@RcvFileTransfer {senderDisplayName :: RcvFileTransfer -> ContactName
senderDisplayName = ContactName
c} =
  [ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" cancelled sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> RcvFileTransfer -> StyledString
rcvFile RcvFileTransfer
ft]

viewSndFileCancelled :: FileTransferMeta -> [SndFileTransfer] -> [StyledString]
viewSndFileCancelled :: FileTransferMeta -> [SndFileTransfer] -> [StyledString]
viewSndFileCancelled FileTransferMeta {ContactId
fileId :: ContactId
fileId :: FileTransferMeta -> ContactId
fileId, String
fileName :: String
fileName :: FileTransferMeta -> String
fileName} [SndFileTransfer]
fts =
  case (SndFileTransfer -> Bool) -> [SndFileTransfer] -> [SndFileTransfer]
forall a. (a -> Bool) -> [a] -> [a]
filter (\SndFileTransfer {fileStatus :: SndFileTransfer -> FileStatus
fileStatus = FileStatus
s} -> FileStatus
s FileStatus -> FileStatus -> Bool
forall a. Eq a => a -> a -> Bool
/= FileStatus
FSCancelled Bool -> Bool -> Bool
&& FileStatus
s FileStatus -> FileStatus -> Bool
forall a. Eq a => a -> a -> Bool
/= FileStatus
FSComplete) [SndFileTransfer]
fts of
    [] -> [StyledString
"cancelled sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName]
    [SndFileTransfer]
ts -> [StyledString
"cancelled sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [SndFileTransfer] -> StyledString
listRecipients [SndFileTransfer]
ts]

sendingFile_ :: StyledString -> SndFileTransfer -> [StyledString]
sendingFile_ :: StyledString -> SndFileTransfer -> [StyledString]
sendingFile_ StyledString
status ft :: SndFileTransfer
ft@SndFileTransfer {recipientDisplayName :: SndFileTransfer -> ContactName
recipientDisplayName = ContactName
c} =
  [StyledString
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SndFileTransfer -> StyledString
sndFile SndFileTransfer
ft StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c]

uploadingFile :: StyledString -> AChatItem -> [StyledString]
uploadingFile :: StyledString -> AChatItem -> [StyledString]
uploadingFile StyledString
status = \case
  AChatItem SChatType c
_ SMsgDirection d
_ (DirectChat Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c}) ChatItem {file :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIFile d)
file = Just CIFile {ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId :: ContactId
fileId, String
fileName :: forall (d :: MsgDirection). CIFile d -> String
fileName :: String
fileName}, chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir = CIDirection c d
CIDirectSnd} ->
    [StyledString
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" uploading " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" for " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c]
  AChatItem SChatType c
_ SMsgDirection d
_ (GroupChat GroupInfo
g Maybe GroupChatScopeInfo
_scopeInfo) ChatItem {file :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIFile d)
file = Just CIFile {ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId :: ContactId
fileId, String
fileName :: forall (d :: MsgDirection). CIFile d -> String
fileName :: String
fileName}, chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir = CIDirection c d
CIGroupSnd} ->
    [StyledString
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" uploading " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" for " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> StyledString
ttyGroup' GroupInfo
g]
  AChatItem
_ -> [StyledString
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" uploading file"]

uploadingFileStandalone :: StyledString -> FileTransferMeta -> [StyledString]
uploadingFileStandalone :: StyledString -> FileTransferMeta -> [StyledString]
uploadingFileStandalone StyledString
status FileTransferMeta {ContactId
fileId :: FileTransferMeta -> ContactId
fileId :: ContactId
fileId, String
fileName :: FileTransferMeta -> String
fileName :: String
fileName} = [StyledString
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" standalone uploading " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName]

standaloneUploadRedirect :: FileTransferMeta -> FileTransferMeta -> [StyledString]
standaloneUploadRedirect :: FileTransferMeta -> FileTransferMeta -> [StyledString]
standaloneUploadRedirect FileTransferMeta {ContactId
fileId :: FileTransferMeta -> ContactId
fileId :: ContactId
fileId, String
fileName :: FileTransferMeta -> String
fileName :: String
fileName} FileTransferMeta {fileId :: FileTransferMeta -> ContactId
fileId = ContactId
redirectId} =
  [ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" uploaded, preparing redirect file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
redirectId]

standaloneUploadComplete :: FileTransferMeta -> [Text] -> [StyledString]
standaloneUploadComplete :: FileTransferMeta -> [ContactName] -> [StyledString]
standaloneUploadComplete FileTransferMeta {ContactId
fileId :: FileTransferMeta -> ContactId
fileId :: ContactId
fileId, String
fileName :: FileTransferMeta -> String
fileName :: String
fileName} = \case
  [] -> [ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" upload complete."]
  [ContactName]
uris ->
    ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" upload complete. download with:"
      StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain [ContactName]
uris

sndFile :: SndFileTransfer -> StyledString
sndFile :: SndFileTransfer -> StyledString
sndFile SndFileTransfer {ContactId
fileId :: ContactId
fileId :: SndFileTransfer -> ContactId
fileId, String
fileName :: String
fileName :: SndFileTransfer -> String
fileName} = ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName

viewReceivedFileInvitation :: StyledString -> CIFile d -> CurrentTime -> TimeZone -> CIMeta c d -> [StyledString]
viewReceivedFileInvitation :: forall (d :: MsgDirection) (c :: ChatType).
StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
viewReceivedFileInvitation StyledString
from CIFile d
file UTCTime
ts TimeZone
tz CIMeta c d
meta = UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone
-> StyledString
-> [StyledString]
-> CIMeta c d
-> [StyledString]
-> Bool
-> [StyledString]
receivedWithTime_ UTCTime
ts TimeZone
tz StyledString
from [] CIMeta c d
meta (CIFile d -> [StyledString]
forall (d :: MsgDirection). CIFile d -> [StyledString]
receivedFileInvitation_ CIFile d
file) Bool
False

receivedFileInvitation_ :: CIFile d -> [StyledString]
receivedFileInvitation_ :: forall (d :: MsgDirection). CIFile d -> [StyledString]
receivedFileInvitation_ CIFile {ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId :: ContactId
fileId, String
fileName :: forall (d :: MsgDirection). CIFile d -> String
fileName :: String
fileName, Integer
fileSize :: Integer
fileSize :: forall (d :: MsgDirection). CIFile d -> Integer
fileSize, CIFileStatus d
fileStatus :: forall (d :: MsgDirection). CIFile d -> CIFileStatus d
fileStatus :: CIFileStatus d
fileStatus} =
  [StyledString
"sends file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
ttyFilePath String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Integer -> StyledString
humanReadableSize Integer
fileSize StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" / " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Integer -> StyledString
forall a. Show a => a -> StyledString
sShow Integer
fileSize StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" bytes)"]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> case CIFileStatus d
fileStatus of
      CIFileStatus d
CIFSRcvAccepted -> []
      CIFileStatus d
_ -> [StyledString
"use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/fr " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
fileId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" [<dir>/ | <path>]") StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to receive it"]

humanReadableSize :: Integer -> StyledString
humanReadableSize :: Integer -> StyledString
humanReadableSize Integer
size
  | Integer
size Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
kB = Integer -> StyledString
forall a. Show a => a -> StyledString
sShow Integer
size StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" bytes"
  | Integer
size Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
mB = Integer -> String -> StyledString
hrSize Integer
kB String
"KiB"
  | Integer
size Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
gB = Integer -> String -> StyledString
hrSize Integer
mB String
"MiB"
  | Bool
otherwise = Integer -> String -> StyledString
hrSize Integer
gB String
"GiB"
  where
    hrSize :: Integer -> String -> StyledString
hrSize Integer
sB String
name = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ [String] -> String
unwords [Maybe Int -> Double -> String -> String
forall a. RealFloat a => Maybe Int -> a -> String -> String
showFFloat (Int -> Maybe Int
forall a. a -> Maybe a
Just Int
1) (Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
size Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ (Integer -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
sB :: Double)) String
"", String
name]
    kB :: Integer
kB = Integer
1024
    mB :: Integer
mB = Integer
kB Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1024
    gB :: Integer
gB = Integer
mB Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
1024

savingFile' :: AChatItem -> [StyledString]
savingFile' :: AChatItem -> [StyledString]
savingFile' (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat ChatItem {file :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIFile d)
file = Just CIFile {ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId :: ContactId
fileId, fileSource :: forall (d :: MsgDirection). CIFile d -> Maybe CryptoFile
fileSource = Just (CryptoFile String
filePath Maybe CryptoFileArgs
_)}, CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir}) =
  [StyledString
"saving file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ChatInfo c -> CIDirection c d -> StyledString
forall (c :: ChatType) (d :: MsgDirection).
ChatInfo c -> CIDirection c d -> StyledString
fileFrom ChatInfo c
chat CIDirection c d
chatDir StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
filePath]
savingFile' AChatItem
_ = [StyledString
"saving file"] -- shouldn't happen

receivingFile_' :: (Maybe RemoteHostId, Maybe User) -> Bool -> String -> AChatItem -> [StyledString]
receivingFile_' :: (Maybe ContactId, Maybe User)
-> Bool -> String -> AChatItem -> [StyledString]
receivingFile_' (Maybe ContactId, Maybe User)
hu Bool
testView String
status (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
chat ChatItem {file :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIFile d)
file = Just CIFile {ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId :: ContactId
fileId, String
fileName :: forall (d :: MsgDirection). CIFile d -> String
fileName :: String
fileName, fileSource :: forall (d :: MsgDirection). CIFile d -> Maybe CryptoFile
fileSource = Just f :: CryptoFile
f@(CryptoFile String
_ Maybe CryptoFileArgs
cfArgs_)}, CIDirection c d
chatDir :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> CIDirection c d
chatDir :: CIDirection c d
chatDir}) =
  [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ChatInfo c -> CIDirection c d -> StyledString
forall (c :: ChatType) (d :: MsgDirection).
ChatInfo c -> CIDirection c d -> StyledString
fileFrom ChatInfo c
chat CIDirection c d
chatDir] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> Maybe CryptoFileArgs -> [StyledString]
cfArgsStr Maybe CryptoFileArgs
cfArgs_ [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString]
getRemoteFileStr
  where
    cfArgsStr :: Maybe CryptoFileArgs -> [StyledString]
cfArgsStr (Just CryptoFileArgs
cfArgs) = [Bool -> CryptoFileArgs -> StyledString
cryptoFileArgsStr Bool
testView CryptoFileArgs
cfArgs | String
status String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"completed"]
    cfArgsStr Maybe CryptoFileArgs
_ = []
    getRemoteFileStr :: [StyledString]
getRemoteFileStr = case (Maybe ContactId, Maybe User)
hu of
      (Just ContactId
rhId, Just User {ContactId
userId :: User -> ContactId
userId :: ContactId
userId})
        | String
status String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"completed" ->
            [ StyledString
"File received to connected remote host " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rhId,
              StyledString
"To download to this device use:",
              String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/get remote file " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
rhId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ByteString -> String
LB.unpack (RemoteFile -> ByteString
forall a. ToJSON a => a -> ByteString
J.encode RemoteFile {ContactId
userId :: ContactId
userId :: ContactId
userId, ContactId
fileId :: ContactId
fileId :: ContactId
fileId, sent :: Bool
sent = Bool
False, fileSource :: CryptoFile
fileSource = CryptoFile
f}))
            ]
      (Maybe ContactId, Maybe User)
_ -> []
receivingFile_' (Maybe ContactId, Maybe User)
_ Bool
_ String
status AChatItem
_ = [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" receiving file"]

receivingFileStandalone :: String -> RcvFileTransfer -> [StyledString]
receivingFileStandalone :: String -> RcvFileTransfer -> [StyledString]
receivingFileStandalone String
status RcvFileTransfer {ContactId
fileId :: ContactId
fileId :: RcvFileTransfer -> ContactId
fileId, fileInvitation :: RcvFileTransfer -> FileInvitation
fileInvitation = FileInvitation {String
fileName :: String
fileName :: FileInvitation -> String
fileName}} =
  [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" standalone receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName]

viewLocalFile :: StyledString -> CIFile d -> CurrentTime -> TimeZone -> CIMeta c d -> [StyledString]
viewLocalFile :: forall (d :: MsgDirection) (c :: ChatType).
StyledString
-> CIFile d -> UTCTime -> TimeZone -> CIMeta c d -> [StyledString]
viewLocalFile StyledString
to CIFile {ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId :: ContactId
fileId, Maybe CryptoFile
fileSource :: forall (d :: MsgDirection). CIFile d -> Maybe CryptoFile
fileSource :: Maybe CryptoFile
fileSource} UTCTime
ts TimeZone
tz = case Maybe CryptoFile
fileSource of
  Just (CryptoFile String
fPath Maybe CryptoFileArgs
_) -> UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
forall (c :: ChatType) (d :: MsgDirection).
UTCTime
-> TimeZone -> [StyledString] -> CIMeta c d -> [StyledString]
sentWithTime_ UTCTime
ts TimeZone
tz [StyledString
to StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fPath]
  Maybe CryptoFile
_ -> [StyledString] -> CIMeta c d -> [StyledString]
forall a b. a -> b -> a
const []

cryptoFileArgsStr :: Bool -> CryptoFileArgs -> StyledString
cryptoFileArgsStr :: Bool -> CryptoFileArgs -> StyledString
cryptoFileArgsStr Bool
testView cfArgs :: CryptoFileArgs
cfArgs@(CFArgs SbKey
key CbNonce
nonce)
  | Bool
testView = CryptoFileArgs -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON CryptoFileArgs
cfArgs
  | Bool
otherwise = ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ ByteString
"encryption key: " ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> SbKey -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode SbKey
key ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
", nonce: " ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> CbNonce -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode CbNonce
nonce

fileFrom :: ChatInfo c -> CIDirection c d -> StyledString
fileFrom :: forall (c :: ChatType) (d :: MsgDirection).
ChatInfo c -> CIDirection c d -> StyledString
fileFrom (DirectChat Contact
ct) CIDirection c d
CIDirectRcv = StyledString
" from " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Contact -> StyledString
ttyContact' Contact
ct
fileFrom ChatInfo c
_ (CIGroupRcv GroupMember
m) = StyledString
" from " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> GroupMember -> StyledString
ttyMember GroupMember
m
fileFrom ChatInfo c
_ CIDirection c d
_ = StyledString
""

receivingFile_ :: StyledString -> RcvFileTransfer -> [StyledString]
receivingFile_ :: StyledString -> RcvFileTransfer -> [StyledString]
receivingFile_ StyledString
status ft :: RcvFileTransfer
ft@RcvFileTransfer {senderDisplayName :: RcvFileTransfer -> ContactName
senderDisplayName = ContactName
c} =
  [StyledString
status StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> RcvFileTransfer -> StyledString
rcvFile RcvFileTransfer
ft StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> if ContactName
c ContactName -> ContactName -> Bool
forall a. Eq a => a -> a -> Bool
== ContactName
"" then StyledString
"" else StyledString
" from " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c]

rcvFile :: RcvFileTransfer -> StyledString
rcvFile :: RcvFileTransfer -> StyledString
rcvFile RcvFileTransfer {ContactId
fileId :: RcvFileTransfer -> ContactId
fileId :: ContactId
fileId, fileInvitation :: RcvFileTransfer -> FileInvitation
fileInvitation = FileInvitation {String
fileName :: FileInvitation -> String
fileName :: String
fileName}} = ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName

fileTransferStr :: Int64 -> String -> StyledString
fileTransferStr :: ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName = StyledString
"file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
ttyFilePath String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"

viewFileTransferStatus :: (FileTransfer, [Integer]) -> [StyledString]
viewFileTransferStatus :: (FileTransfer, [Integer]) -> [StyledString]
viewFileTransferStatus (FTSnd FileTransferMeta {ContactId
fileId :: FileTransferMeta -> ContactId
fileId :: ContactId
fileId, String
fileName :: FileTransferMeta -> String
fileName :: String
fileName, Bool
cancelled :: Bool
cancelled :: FileTransferMeta -> Bool
cancelled} [], [Integer]
_) =
  [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": no file transfers"]
    [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"file transfer cancelled" | Bool
cancelled]
viewFileTransferStatus (FTSnd FileTransferMeta {Bool
cancelled :: FileTransferMeta -> Bool
cancelled :: Bool
cancelled} fts :: [SndFileTransfer]
fts@(SndFileTransfer
ft : [SndFileTransfer]
_), [Integer]
chunksNum) =
  [StyledString]
recipientStatuses [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"file transfer cancelled" | Bool
cancelled]
  where
    recipientStatuses :: [StyledString]
recipientStatuses =
      case ([SndFileTransfer] -> [StyledString])
-> [[SndFileTransfer]] -> [StyledString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap [SndFileTransfer] -> [StyledString]
recipientsTransferStatus ([[SndFileTransfer]] -> [StyledString])
-> [[SndFileTransfer]] -> [StyledString]
forall a b. (a -> b) -> a -> b
$ (SndFileTransfer -> SndFileTransfer -> Bool)
-> [SndFileTransfer] -> [[SndFileTransfer]]
forall a. (a -> a -> Bool) -> [a] -> [[a]]
groupBy (FileStatus -> FileStatus -> Bool
forall a. Eq a => a -> a -> Bool
(==) (FileStatus -> FileStatus -> Bool)
-> (SndFileTransfer -> FileStatus)
-> SndFileTransfer
-> SndFileTransfer
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` SndFileTransfer -> FileStatus
fs) ([SndFileTransfer] -> [[SndFileTransfer]])
-> [SndFileTransfer] -> [[SndFileTransfer]]
forall a b. (a -> b) -> a -> b
$ (SndFileTransfer -> FileStatus)
-> [SndFileTransfer] -> [SndFileTransfer]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn SndFileTransfer -> FileStatus
fs [SndFileTransfer]
fts of
        [StyledString
recipientsStatus] -> [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SndFileTransfer -> StyledString
sndFile SndFileTransfer
ft StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
recipientsStatus]
        [StyledString]
recipientsStatuses -> (StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SndFileTransfer -> StyledString
sndFile SndFileTransfer
ft StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": ") StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (StyledString -> StyledString) -> [StyledString] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (StyledString
"  " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>) [StyledString]
recipientsStatuses
    fs :: SndFileTransfer -> FileStatus
    fs :: SndFileTransfer -> FileStatus
fs SndFileTransfer {FileStatus
fileStatus :: SndFileTransfer -> FileStatus
fileStatus :: FileStatus
fileStatus} = FileStatus
fileStatus
    recipientsTransferStatus :: [SndFileTransfer] -> [StyledString]
recipientsTransferStatus [] = []
    recipientsTransferStatus ts :: [SndFileTransfer]
ts@(SndFileTransfer {FileStatus
fileStatus :: SndFileTransfer -> FileStatus
fileStatus :: FileStatus
fileStatus, Integer
fileSize :: Integer
fileSize :: SndFileTransfer -> Integer
fileSize, Integer
chunkSize :: Integer
chunkSize :: SndFileTransfer -> Integer
chunkSize} : [SndFileTransfer]
_) = [StyledString
sndStatus StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [SndFileTransfer] -> StyledString
listRecipients [SndFileTransfer]
ts]
      where
        sndStatus :: StyledString
sndStatus = case FileStatus
fileStatus of
          FileStatus
FSNew -> StyledString
"not accepted"
          FileStatus
FSAccepted -> StyledString
"just started"
          FileStatus
FSConnected -> StyledString
"in progress (" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Integer -> StyledString
forall a. Show a => a -> StyledString
sShow ([Integer] -> Integer
forall a. Num a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [Integer]
chunksNum Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
chunkSize Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
100 Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
`div` (Int -> Integer
forall a. Integral a => a -> Integer
toInteger ([Integer] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Integer]
chunksNum) Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
fileSize)) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"%)"
          FileStatus
FSComplete -> StyledString
"complete"
          FileStatus
FSCancelled -> StyledString
"cancelled"
viewFileTransferStatus (FTRcv ft :: RcvFileTransfer
ft@RcvFileTransfer {ContactId
fileId :: RcvFileTransfer -> ContactId
fileId :: ContactId
fileId, fileInvitation :: RcvFileTransfer -> FileInvitation
fileInvitation = FileInvitation {Integer
fileSize :: Integer
fileSize :: FileInvitation -> Integer
fileSize}, RcvFileStatus
fileStatus :: RcvFileStatus
fileStatus :: RcvFileTransfer -> RcvFileStatus
fileStatus, Integer
chunkSize :: Integer
chunkSize :: RcvFileTransfer -> Integer
chunkSize}, [Integer]
chunksNum) =
  [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> RcvFileTransfer -> StyledString
rcvFile RcvFileTransfer
ft StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
rcvStatus]
  where
    rcvStatus :: StyledString
rcvStatus = case RcvFileStatus
fileStatus of
      RcvFileStatus
RFSNew -> StyledString
"not accepted yet, use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/fr " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
fileId) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to receive file"
      RFSAccepted String
_ -> StyledString
"just started"
      RFSConnected String
_ -> StyledString
"progress " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [Integer] -> Integer -> Integer -> StyledString
fileProgress [Integer]
chunksNum Integer
chunkSize Integer
fileSize
      RFSComplete String
filePath -> StyledString
"complete, path: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
filePath
      RFSCancelled (Just String
filePath) -> StyledString
"cancelled, received part path: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
filePath
      RFSCancelled Maybe String
Nothing -> StyledString
"cancelled"

viewFileTransferStatusXFTP :: AChatItem -> [StyledString]
viewFileTransferStatusXFTP :: AChatItem -> [StyledString]
viewFileTransferStatusXFTP (AChatItem SChatType c
_ SMsgDirection d
_ ChatInfo c
_ ChatItem {file :: forall (c :: ChatType) (d :: MsgDirection).
ChatItem c d -> Maybe (CIFile d)
file = Just CIFile {ContactId
fileId :: forall (d :: MsgDirection). CIFile d -> ContactId
fileId :: ContactId
fileId, String
fileName :: forall (d :: MsgDirection). CIFile d -> String
fileName :: String
fileName, Integer
fileSize :: forall (d :: MsgDirection). CIFile d -> Integer
fileSize :: Integer
fileSize, CIFileStatus d
fileStatus :: forall (d :: MsgDirection). CIFile d -> CIFileStatus d
fileStatus :: CIFileStatus d
fileStatus, Maybe CryptoFile
fileSource :: forall (d :: MsgDirection). CIFile d -> Maybe CryptoFile
fileSource :: Maybe CryptoFile
fileSource}}) =
  case CIFileStatus d
fileStatus of
    CIFileStatus d
CIFSSndStored -> [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" just started"]
    CIFSSndTransfer ContactId
progress ContactId
total -> [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" in progress " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> ContactId -> Integer -> StyledString
fileProgressXFTP ContactId
progress ContactId
total Integer
fileSize]
    CIFileStatus d
CIFSSndCancelled -> [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" cancelled"]
    CIFileStatus d
CIFSSndComplete -> [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" complete"]
    CIFSSndError FileError
sndFileErr -> [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (FileError -> String
forall a. Show a => a -> String
show FileError
sndFileErr)]
    CIFSSndWarning FileError
sndFileErr -> [StyledString
"sending " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" warning: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (FileError -> String
forall a. Show a => a -> String
show FileError
sndFileErr)]
    CIFileStatus d
CIFSRcvInvitation -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" not accepted yet, use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/fr " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
fileId) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to receive file"]
    CIFileStatus d
CIFSRcvAccepted -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" just started"]
    CIFSRcvTransfer ContactId
progress ContactId
total -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" progress " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> ContactId -> Integer -> StyledString
fileProgressXFTP ContactId
progress ContactId
total Integer
fileSize]
    CIFileStatus d
CIFSRcvAborted -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" aborted, use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (String
"/fr " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
fileId) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" to receive file"]
    CIFileStatus d
CIFSRcvComplete -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" complete" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
-> (CryptoFile -> StyledString) -> Maybe CryptoFile -> StyledString
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StyledString
"" (\(CryptoFile String
fp Maybe CryptoFileArgs
_) -> StyledString
", path: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
fp) Maybe CryptoFile
fileSource]
    CIFileStatus d
CIFSRcvCancelled -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" cancelled"]
    CIFSRcvError FileError
rcvFileErr -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (FileError -> String
forall a. Show a => a -> String
show FileError
rcvFileErr)]
    CIFSRcvWarning FileError
rcvFileErr -> [StyledString
"receiving " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" warning: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (FileError -> String
forall a. Show a => a -> String
show FileError
rcvFileErr)]
    CIFSInvalid ContactName
text -> [StyledString
fstr StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" invalid status: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
text]
  where
    fstr :: StyledString
fstr = ContactId -> String -> StyledString
fileTransferStr ContactId
fileId String
fileName
viewFileTransferStatusXFTP AChatItem
_ = [StyledString
"no file status"]

listRecipients :: [SndFileTransfer] -> StyledString
listRecipients :: [SndFileTransfer] -> StyledString
listRecipients = [StyledString] -> StyledString
forall a. Monoid a => [a] -> a
mconcat ([StyledString] -> StyledString)
-> ([SndFileTransfer] -> [StyledString])
-> [SndFileTransfer]
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
intersperse StyledString
", " ([StyledString] -> [StyledString])
-> ([SndFileTransfer] -> [StyledString])
-> [SndFileTransfer]
-> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SndFileTransfer -> StyledString)
-> [SndFileTransfer] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (ContactName -> StyledString
ttyContact (ContactName -> StyledString)
-> (SndFileTransfer -> ContactName)
-> SndFileTransfer
-> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SndFileTransfer -> ContactName
recipientDisplayName)

fileProgress :: [Integer] -> Integer -> Integer -> StyledString
fileProgress :: [Integer] -> Integer -> Integer -> StyledString
fileProgress [Integer]
chunksNum Integer
chunkSize Integer
fileSize =
  Integer -> StyledString
forall a. Show a => a -> StyledString
sShow ([Integer] -> Integer
forall a. Num a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [Integer]
chunksNum Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
chunkSize Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
100 Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
`div` Integer
fileSize) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"% of " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Integer -> StyledString
humanReadableSize Integer
fileSize

fileProgressXFTP :: Int64 -> Int64 -> Integer -> StyledString
fileProgressXFTP :: ContactId -> ContactId -> Integer -> StyledString
fileProgressXFTP ContactId
progress ContactId
total Integer
fileSize =
  ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow (ContactId
progress ContactId -> ContactId -> ContactId
forall a. Num a => a -> a -> a
* ContactId
100 ContactId -> ContactId -> ContactId
forall a. Integral a => a -> a -> a
`div` ContactId
total) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"% of " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Integer -> StyledString
humanReadableSize Integer
fileSize

viewCallInvitation :: Contact -> CallType -> Maybe C.Key -> [StyledString]
viewCallInvitation :: Contact -> CallType -> Maybe Key -> [StyledString]
viewCallInvitation ct :: Contact
ct@Contact {ContactId
contactId :: Contact -> ContactId
contactId :: ContactId
contactId} callType :: CallType
callType@CallType {CallMedia
media :: CallMedia
media :: CallType -> CallMedia
media} Maybe Key
sharedKey =
  [ Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" wants to connect with you via WebRTC " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CallType -> StyledString
callMediaStr CallType
callType StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" call " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CallType -> StyledString
encryptedCallText CallType
callType,
    StyledString
"To accept the call, please open the link below in your browser" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CallType -> StyledString
supporedBrowsers CallType
callType,
    StyledString
"",
    StyledString
"https://simplex.chat/call#" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ByteString
queryString
  ]
  where
    aesKey :: Maybe String
aesKey = ByteString -> String
B.unpack (ByteString -> String) -> (Key -> ByteString) -> Key -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode (ByteString -> ByteString)
-> (Key -> ByteString) -> Key -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Key -> ByteString
C.unKey (Key -> String) -> Maybe Key -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Key
sharedKey
    queryString :: ByteString
queryString =
      Bool -> SimpleQuery -> ByteString
Q.renderSimpleQuery
        Bool
False
        [ (ByteString
"command", ByteString -> ByteString
LB.toStrict (ByteString -> ByteString)
-> (WCallCommand -> ByteString) -> WCallCommand -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WCallCommand -> ByteString
forall a. ToJSON a => a -> ByteString
J.encode (WCallCommand -> ByteString) -> WCallCommand -> ByteString
forall a b. (a -> b) -> a -> b
$ WCCallStart {CallMedia
media :: CallMedia
media :: CallMedia
media, Maybe String
aesKey :: Maybe String
aesKey :: Maybe String
aesKey, useWorker :: Bool
useWorker = Bool
True}),
          (ByteString
"contact_id", String -> ByteString
B.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
$ ContactId -> String
forall a. Show a => a -> String
show ContactId
contactId)
        ]

viewCallOffer :: Contact -> CallType -> WebRTCSession -> Maybe C.Key -> [StyledString]
viewCallOffer :: Contact -> CallType -> WebRTCSession -> Maybe Key -> [StyledString]
viewCallOffer ct :: Contact
ct@Contact {ContactId
contactId :: Contact -> ContactId
contactId :: ContactId
contactId} callType :: CallType
callType@CallType {CallMedia
media :: CallType -> CallMedia
media :: CallMedia
media} WebRTCSession {rtcSession :: WebRTCSession -> ContactName
rtcSession = ContactName
offer, rtcIceCandidates :: WebRTCSession -> ContactName
rtcIceCandidates = ContactName
iceCandidates} Maybe Key
sharedKey =
  [ Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" accepted your WebRTC " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CallType -> StyledString
callMediaStr CallType
callType StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" call " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CallType -> StyledString
encryptedCallText CallType
callType,
    StyledString
"To connect, please open the link below in your browser" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> CallType -> StyledString
supporedBrowsers CallType
callType,
    StyledString
"",
    StyledString
"https://simplex.chat/call#" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ByteString
queryString
  ]
  where
    aesKey :: Maybe String
aesKey = ByteString -> String
B.unpack (ByteString -> String) -> (Key -> ByteString) -> Key -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode (ByteString -> ByteString)
-> (Key -> ByteString) -> Key -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Key -> ByteString
C.unKey (Key -> String) -> Maybe Key -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Key
sharedKey
    queryString :: ByteString
queryString =
      Bool -> SimpleQuery -> ByteString
Q.renderSimpleQuery
        Bool
False
        [ (ByteString
"command", ByteString -> ByteString
LB.toStrict (ByteString -> ByteString)
-> (WCallCommand -> ByteString) -> WCallCommand -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WCallCommand -> ByteString
forall a. ToJSON a => a -> ByteString
J.encode (WCallCommand -> ByteString) -> WCallCommand -> ByteString
forall a b. (a -> b) -> a -> b
$ WCCallOffer {ContactName
offer :: ContactName
offer :: ContactName
offer, ContactName
iceCandidates :: ContactName
iceCandidates :: ContactName
iceCandidates, CallMedia
media :: CallMedia
media :: CallMedia
media, Maybe String
aesKey :: Maybe String
aesKey :: Maybe String
aesKey, useWorker :: Bool
useWorker = Bool
True}),
          (ByteString
"contact_id", String -> ByteString
B.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
$ ContactId -> String
forall a. Show a => a -> String
show ContactId
contactId)
        ]

viewCallAnswer :: Contact -> WebRTCSession -> [StyledString]
viewCallAnswer :: Contact -> WebRTCSession -> [StyledString]
viewCallAnswer Contact
ct WebRTCSession {rtcSession :: WebRTCSession -> ContactName
rtcSession = ContactName
answer, rtcIceCandidates :: WebRTCSession -> ContactName
rtcIceCandidates = ContactName
iceCandidates} =
  [ Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" continued the WebRTC call",
    StyledString
"To connect, please paste the data below in your browser window you opened earlier and click Connect button",
    StyledString
"",
    WCallCommand -> StyledString
forall a. ToJSON a => a -> StyledString
viewJSON WCCallAnswer {ContactName
answer :: ContactName
answer :: ContactName
answer, ContactName
iceCandidates :: ContactName
iceCandidates :: ContactName
iceCandidates}
  ]

callMediaStr :: CallType -> StyledString
callMediaStr :: CallType -> StyledString
callMediaStr CallType {CallMedia
media :: CallType -> CallMedia
media :: CallMedia
media} = case CallMedia
media of
  CallMedia
CMVideo -> StyledString
"video"
  CallMedia
CMAudio -> StyledString
"audio"

encryptedCallText :: CallType -> StyledString
encryptedCallText :: CallType -> StyledString
encryptedCallText CallType
callType
  | CallType -> Bool
encryptedCall CallType
callType = StyledString
"(e2e encrypted)"
  | Bool
otherwise = StyledString
"(not e2e encrypted)"

supporedBrowsers :: CallType -> StyledString
supporedBrowsers :: CallType -> StyledString
supporedBrowsers CallType
callType
  | CallType -> Bool
encryptedCall CallType
callType = StyledString
" (only Chrome and Safari support e2e encryption for WebRTC, Safari may require enabling WebRTC insertable streams)"
  | Bool
otherwise = StyledString
""

viewVersionInfo :: ChatLogLevel -> CoreVersionInfo -> [StyledString]
viewVersionInfo :: ChatLogLevel -> CoreVersionInfo -> [StyledString]
viewVersionInfo ChatLogLevel
logLevel CoreVersionInfo {String
version :: String
version :: CoreVersionInfo -> String
version, String
simplexmqVersion :: String
simplexmqVersion :: CoreVersionInfo -> String
simplexmqVersion, String
simplexmqCommit :: String
simplexmqCommit :: CoreVersionInfo -> String
simplexmqCommit} =
  (String -> StyledString) -> [String] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([String] -> [StyledString]) -> [String] -> [StyledString]
forall a b. (a -> b) -> a -> b
$
    if ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLInfo
      then [String -> String
versionString String
version, String
"simplexmq: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
simplexmqVersion String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String -> String
forall a. (IsString a, Semigroup a) => a -> a
parens String
simplexmqCommit]
      else [String -> String
versionString String
version]
  where

parens :: (IsString a, Semigroup a) => a -> a
parens :: forall a. (IsString a, Semigroup a) => a -> a
parens a
s = a
" (" a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
s a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
")"

viewRemoteHosts :: [RemoteHostInfo] -> [StyledString]
viewRemoteHosts :: [RemoteHostInfo] -> [StyledString]
viewRemoteHosts = \case
  [] -> [StyledString
"No remote hosts"]
  [RemoteHostInfo]
hs -> StyledString
"Remote hosts: " StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (RemoteHostInfo -> StyledString)
-> [RemoteHostInfo] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map RemoteHostInfo -> StyledString
viewRemoteHostInfo [RemoteHostInfo]
hs
  where
    viewRemoteHostInfo :: RemoteHostInfo -> StyledString
viewRemoteHostInfo RemoteHostInfo {ContactId
remoteHostId :: RemoteHostInfo -> ContactId
remoteHostId :: ContactId
remoteHostId, ContactName
hostDeviceName :: RemoteHostInfo -> ContactName
hostDeviceName :: ContactName
hostDeviceName, Maybe RemoteHostSessionState
sessionState :: Maybe RemoteHostSessionState
sessionState :: RemoteHostInfo -> Maybe RemoteHostSessionState
sessionState, Maybe RCCtrlAddress
bindAddress_ :: Maybe RCCtrlAddress
bindAddress_ :: RemoteHostInfo -> Maybe RCCtrlAddress
bindAddress_, Maybe Word16
bindPort_ :: Maybe Word16
bindPort_ :: RemoteHostInfo -> Maybe Word16
bindPort_} =
      ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactId -> ContactName
forall a. Show a => a -> ContactName
tshow ContactId
remoteHostId ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
". " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
hostDeviceName ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (RemoteHostSessionState -> ContactName)
-> Maybe RemoteHostSessionState
-> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" RemoteHostSessionState -> ContactName
viewSessionState Maybe RemoteHostSessionState
sessionState ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Maybe RCCtrlAddress -> Maybe Word16 -> ContactName
forall {a}. Show a => Maybe RCCtrlAddress -> Maybe a -> ContactName
ctrlBinds Maybe RCCtrlAddress
bindAddress_ Maybe Word16
bindPort_
    ctrlBinds :: Maybe RCCtrlAddress -> Maybe a -> ContactName
ctrlBinds Maybe RCCtrlAddress
Nothing Maybe a
Nothing = ContactName
""
    ctrlBinds Maybe RCCtrlAddress
rca_ Maybe a
port_ = [ContactName] -> ContactName
forall a. Monoid a => [a] -> a
mconcat [ContactName
" [", ContactName
-> (RCCtrlAddress -> ContactName)
-> Maybe RCCtrlAddress
-> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" RCCtrlAddress -> ContactName
rca Maybe RCCtrlAddress
rca_, ContactName -> (a -> ContactName) -> Maybe a -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" a -> ContactName
forall a. Show a => a -> ContactName
port Maybe a
port_, ContactName
"]"]
      where
        rca :: RCCtrlAddress -> ContactName
rca RCCtrlAddress {ContactName
interface :: ContactName
interface :: RCCtrlAddress -> ContactName
interface, TransportHost
address :: RCCtrlAddress -> TransportHost
address :: TransportHost
address} = ContactName
interface ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ByteString -> ContactName
decodeLatin1 (TransportHost -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode TransportHost
address)
        port :: a -> ContactName
port a
p = ContactName
":" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> a -> ContactName
forall a. Show a => a -> ContactName
tshow a
p
    viewSessionState :: RemoteHostSessionState -> ContactName
viewSessionState = \case
      RemoteHostSessionState
RHSStarting -> ContactName
" (starting)"
      RHSConnecting ContactName
_ -> ContactName
" (connecting)"
      RHSPendingConfirmation {ContactName
sessionCode :: ContactName
sessionCode :: RemoteHostSessionState -> ContactName
sessionCode} -> ContactName
" (pending confirmation, code: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
sessionCode ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
")"
      RHSConfirmed ContactName
_ -> ContactName
" (confirmed)"
      RHSConnected ContactName
_ -> ContactName
" (connected)"

viewRemoteCtrls :: [RemoteCtrlInfo] -> [StyledString]
viewRemoteCtrls :: [RemoteCtrlInfo] -> [StyledString]
viewRemoteCtrls = \case
  [] -> [StyledString
"No remote controllers"]
  [RemoteCtrlInfo]
hs -> StyledString
"Remote controllers: " StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: (RemoteCtrlInfo -> StyledString)
-> [RemoteCtrlInfo] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map RemoteCtrlInfo -> StyledString
viewRemoteCtrlInfo [RemoteCtrlInfo]
hs
  where
    viewRemoteCtrlInfo :: RemoteCtrlInfo -> StyledString
viewRemoteCtrlInfo RemoteCtrlInfo {ContactId
remoteCtrlId :: RemoteCtrlInfo -> ContactId
remoteCtrlId :: ContactId
remoteCtrlId, ContactName
ctrlDeviceName :: RemoteCtrlInfo -> ContactName
ctrlDeviceName :: ContactName
ctrlDeviceName, Maybe RemoteCtrlSessionState
sessionState :: Maybe RemoteCtrlSessionState
sessionState :: RemoteCtrlInfo -> Maybe RemoteCtrlSessionState
sessionState} =
      ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactId -> ContactName
forall a. Show a => a -> ContactName
tshow ContactId
remoteCtrlId ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
". " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
ctrlDeviceName ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (RemoteCtrlSessionState -> ContactName)
-> Maybe RemoteCtrlSessionState
-> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" RemoteCtrlSessionState -> ContactName
viewSessionState Maybe RemoteCtrlSessionState
sessionState
    viewSessionState :: RemoteCtrlSessionState -> ContactName
viewSessionState = \case
      RemoteCtrlSessionState
RCSStarting -> ContactName
" (starting)"
      RemoteCtrlSessionState
RCSSearching -> ContactName
" (searching)"
      RemoteCtrlSessionState
RCSConnecting -> ContactName
" (connecting)"
      RCSPendingConfirmation {ContactName
sessionCode :: ContactName
sessionCode :: RemoteCtrlSessionState -> ContactName
sessionCode} -> ContactName
" (pending confirmation, code: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
sessionCode ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
")"
      RCSConnected ContactName
_ -> ContactName
" (connected)"

viewRemoteCtrl :: CtrlAppInfo -> AppVersion -> Bool -> StyledString
viewRemoteCtrl :: CtrlAppInfo -> AppVersion -> Bool -> StyledString
viewRemoteCtrl CtrlAppInfo {ContactName
deviceName :: ContactName
deviceName :: CtrlAppInfo -> ContactName
deviceName, appVersionRange :: CtrlAppInfo -> AppVersionRange
appVersionRange = AppVersionRange AppVersion
_ (AppVersion Version
ctrlVersion)} (AppVersion Version
v) Bool
compatible =
  (if ContactName -> Bool
T.null ContactName
deviceName then StyledString
"" else ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
deviceName StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", ")
    StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> (StyledString
"v" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (Version -> String
V.showVersion Version
ctrlVersion) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
ctrlVersionInfo)
  where
    ctrlVersionInfo :: StyledString
ctrlVersionInfo
      | Version
ctrlVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
< Version
v = StyledString
" (older than this app - upgrade controller" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
showCompatible StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"
      | Version
ctrlVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
> Version
v = StyledString
" (newer than this app - upgrade it" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
showCompatible StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
")"
      | Bool
otherwise = StyledString
""
    showCompatible :: StyledString
showCompatible = if Bool
compatible then StyledString
"" else StyledString
", " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
bold' String
"not compatible"

viewRemoteCtrlStopped :: RemoteCtrlStopReason -> [StyledString]
viewRemoteCtrlStopped :: RemoteCtrlStopReason -> [StyledString]
viewRemoteCtrlStopped = \case
  RCSRConnectionFailed (ChatErrorAgent (RCP RCErrorType
RCEIdentity) AgentConnId
_ Maybe ConnectionEntity
_) ->
    [StyledString
"remote controller stopped: this link was used with another controller, please create a new link on the host"]
  RemoteCtrlStopReason
_ -> [StyledString
"remote controller stopped"]

viewChatError :: Bool -> ChatLogLevel -> Bool -> ChatError -> [StyledString]
viewChatError :: Bool -> ChatLogLevel -> Bool -> ChatError -> [StyledString]
viewChatError Bool
isCmd ChatLogLevel
logLevel Bool
testView = \case
  ChatError ChatErrorType
err -> case ChatErrorType
err of
    ChatErrorType
CENoActiveUser -> [StyledString
"error: active user is required"]
    CENoConnectionUser AgentConnId
agentConnId -> [StyledString
"error: message user not found, conn id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentConnId -> StyledString
forall a. Show a => a -> StyledString
sShow AgentConnId
agentConnId | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLError]
    CENoSndFileUser AgentSndFileId
aFileId -> [StyledString
"error: snd file user not found, file id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentSndFileId -> StyledString
forall a. Show a => a -> StyledString
sShow AgentSndFileId
aFileId | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLError]
    CENoRcvFileUser AgentRcvFileId
aFileId -> [StyledString
"error: rcv file user not found, file id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentRcvFileId -> StyledString
forall a. Show a => a -> StyledString
sShow AgentRcvFileId
aFileId | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLError]
    ChatErrorType
CEActiveUserExists -> [StyledString
"error: active user already exists"]
    CEUserExists ContactName
name -> [StyledString
"user with the name " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
name StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" already exists"]
    ChatErrorType
CEUserUnknown -> [StyledString
"user does not exist or incorrect password"]
    CEDifferentActiveUser ContactId
commandUserId ContactId
activeUserId -> [StyledString
"error: different active user, command user id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
commandUserId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", active user id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
activeUserId]
    CECantDeleteActiveUser ContactId
_ -> [StyledString
"cannot delete active user"]
    CECantDeleteLastUser ContactId
_ -> [StyledString
"cannot delete last user"]
    CECantHideLastUser ContactId
_ -> [StyledString
"cannot hide the only not hidden user"]
    CEHiddenUserAlwaysMuted ContactId
_ -> [StyledString
"hidden user always muted when inactive"]
    CEEmptyUserPassword ContactId
_ -> [StyledString
"user password is required"]
    CEUserAlreadyHidden ContactId
_ -> [StyledString
"user is already hidden"]
    CEUserNotHidden ContactId
_ -> [StyledString
"user is not hidden"]
    CEInvalidDisplayName {ContactName
displayName :: ContactName
displayName :: ChatErrorType -> ContactName
displayName, ContactName
validName :: ContactName
validName :: ChatErrorType -> ContactName
validName} ->
      (ContactName -> StyledString) -> [ContactName] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ([ContactName] -> [StyledString])
-> [ContactName] -> [StyledString]
forall a b. (a -> b) -> a -> b
$
        [if ContactName -> Bool
T.null ContactName
displayName then ContactName
"display name can't be empty" else ContactName
"invalid display name: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
displayName]
          [ContactName] -> [ContactName] -> [ContactName]
forall a. Semigroup a => a -> a -> a
<> [ContactName
"you could use this one: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
validName | Bool -> Bool
not (ContactName -> Bool
T.null ContactName
validName)]
    ChatErrorType
CEChatNotStarted -> [StyledString
"error: chat not started"]
    ChatErrorType
CEChatNotStopped -> [StyledString
"error: chat not stopped"]
    ChatErrorType
CEChatStoreChanged -> [StyledString
"error: chat store changed, please restart chat"]
    ChatErrorType
CEInvalidConnReq -> [StyledString]
viewInvalidConnReq
    ChatErrorType
CEUnsupportedConnReq -> [ StyledString
"", StyledString
"Connection link is not supported by the your app version, please ugrade it."]
    CEInvalidChatMessage Connection {ContactId
connId :: Connection -> ContactId
connId :: ContactId
connId} Maybe MsgMetaJSON
msgMeta_ ContactName
msg String
e ->
      [ String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$
          (String
"chat message error: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
e String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" (" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactName -> String
T.unpack (Int -> ContactName -> ContactName
T.take Int
120 ContactName
msg) String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
")")
            String -> String -> String
forall a. Semigroup a => a -> a -> a
<> (String
", connection id: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
connId)
            String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String -> (MsgMetaJSON -> String) -> Maybe MsgMetaJSON -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" (\MsgMetaJSON {ContactId
rcvId :: ContactId
rcvId :: MsgMetaJSON -> ContactId
rcvId} -> String
", agent msg rcv id: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
rcvId) Maybe MsgMetaJSON
msgMeta_
      ]
    ChatErrorType
CEConnReqMessageProhibited -> [StyledString
"message is not allowed with this connection link"]
    CEContactNotFound ContactName
cName Maybe (GroupInfo, GroupMember)
m_ -> ContactName -> Maybe (GroupInfo, GroupMember) -> [StyledString]
viewContactNotFound ContactName
cName Maybe (GroupInfo, GroupMember)
m_
    CEContactNotReady Contact
c -> [Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": not ready"]
    CEContactDisabled Contact
ct -> [Contact -> StyledString
ttyContact' Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": disabled, to enable: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/enable " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
ct) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", to delete: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/d " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
ct)]
    CEContactNotActive Contact
c -> [Contact -> StyledString
ttyContact' Contact
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": not active"]
    CEConnectionDisabled Connection {ContactId
connId :: Connection -> ContactId
connId :: ContactId
connId, ConnType
connType :: ConnType
connType :: Connection -> ConnType
connType} -> [ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"connection " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ConnType -> ContactName
forall a. TextEncoding a => a -> ContactName
textEncode ConnType
connType ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" (" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactId -> ContactName
forall a. Show a => a -> ContactName
tshow ContactId
connId ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
") is disabled" | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLWarning]
    CEGroupDuplicateMember ContactName
c -> [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is already in the group"]
    ChatErrorType
CEGroupDuplicateMemberId -> [StyledString
"cannot add member - duplicate member ID"]
    CEGroupUserRole GroupInfo
g GroupMemberRole
role ->
      (StyledString -> [StyledString] -> [StyledString]
forall a. a -> [a] -> [a]
: []) (StyledString -> [StyledString])
-> (StyledString -> StyledString) -> StyledString -> [StyledString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<>) (StyledString -> [StyledString]) -> StyledString -> [StyledString]
forall a b. (a -> b) -> a -> b
$ case GroupMemberRole
role of
        GroupMemberRole
GRAuthor -> StyledString
": you don't have permission to send messages"
        GroupMemberRole
_ -> StyledString
": you have insufficient permissions for this action, the required role is " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (GroupMemberRole -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode GroupMemberRole
role)
    CEGroupMemberInitialRole GroupInfo
g GroupMemberRole
role -> [GroupInfo -> StyledString
ttyGroup' GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": initial role for group member cannot be " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (GroupMemberRole -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode GroupMemberRole
role) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", use member or observer"]
    ChatErrorType
CEContactIncognitoCantInvite -> [StyledString
"you're using your main profile for this group - prohibited to invite contacts to whom you are connected incognito"]
    ChatErrorType
CEGroupIncognitoCantInvite -> [StyledString
"you are using an incognito profile for this group - prohibited to invite contacts"]
    CEGroupContactRole ContactName
c -> [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" has insufficient permissions for this group action"]
    CEGroupNotJoined GroupInfo
g -> [StyledString
"you did not join this group, use " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/join #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g)]
    ChatErrorType
CEGroupMemberNotActive -> [StyledString
"your group connection is not active yet, try later"]
    CECantBlockMemberForSelf GroupInfo
g GroupMember
m Bool
showMsgs ->
      [ StyledString
"admins or above can't block member for self, use "
          StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight
            ( (if Bool
showMsgs then ContactName
"/unblock for all" else ContactName
"/block for all")
                ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> (ContactName
" #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
viewMemberName GroupMember
m)
            )
      ]
    ChatErrorType
CEGroupMemberUserRemoved -> [StyledString
"you are no longer a member of the group"]
    ChatErrorType
CEGroupMemberNotFound -> [StyledString
"group doesn't have this member"]
    CEGroupCantResendInvitation GroupInfo
g ContactName
c -> GroupInfo -> ContactName -> [StyledString]
viewCannotResendInvitation GroupInfo
g ContactName
c
    CEGroupInternal String
s -> [StyledString
"chat group bug: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
s]
    CEFileNotFound String
f -> [StyledString
"file not found: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
f]
    CEFileSize String
f -> [StyledString
"file size exceeds the limit: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
f]
    CEFileAlreadyReceiving String
f -> [StyledString
"file is already being received: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
f]
    CEFileCancelled String
f -> [StyledString
"file cancelled: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
f]
    CEFileCancel ContactId
fileId String
e -> [StyledString
"error cancelling file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. Show a => a -> StyledString
sShow String
e]
    CEFileAlreadyExists String
f -> [StyledString
"file already exists: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
f]
    CEFileWrite String
f String
e -> [StyledString
"cannot write file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
f StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
    CEFileSend ContactId
fileId AgentErrorType
e -> [StyledString
"error sending file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
": " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentErrorType -> StyledString
forall a. Show a => a -> StyledString
sShow AgentErrorType
e]
    CEFileRcvChunk String
e -> [StyledString
"error receiving file: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
    CEFileInternal String
e -> [StyledString
"file error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
    CEFileImageType String
_ -> [StyledString
"image type must be jpg, send as a file using " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/f"]
    CEFileImageSize String
_ -> [StyledString
"max image size: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Integer -> StyledString
forall a. Show a => a -> StyledString
sShow Integer
maxImageSize StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" bytes, resize it or send as a file using " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/f"]
    CEFileNotReceived ContactId
fileId -> [StyledString
"file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" not received"]
    CEFileNotApproved ContactId
fileId [XFTPServer]
unknownSrvs -> [StyledString
"file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" aborted, unknwon XFTP servers:"] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> (XFTPServer -> StyledString) -> [XFTPServer] -> [StyledString]
forall a b. (a -> b) -> [a] -> [b]
map (String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString)
-> (XFTPServer -> String) -> XFTPServer -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. XFTPServer -> String
forall a. Show a => a -> String
show) [XFTPServer]
unknownSrvs
    CEFallbackToSMPProhibited ContactId
fileId -> [StyledString
"recipient tried to accept file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" via old protocol, prohibited"]
    CEInlineFileProhibited ContactId
_ -> [StyledString
"A small file sent without acceptance - you can enable receiving such files with -f option."]
    ChatErrorType
CEInvalidForward -> [StyledString
"cannot forward message(s)"]
    ChatErrorType
CEInvalidChatItemUpdate -> [StyledString
"cannot update this item"]
    ChatErrorType
CEInvalidChatItemDelete -> [StyledString
"cannot delete this item"]
    ChatErrorType
CEHasCurrentCall -> [StyledString
"call already in progress"]
    ChatErrorType
CENoCurrentCall -> [StyledString
"no call in progress"]
    CECallContact ContactId
_ -> []
    CECallState CallStateTag
_ -> []
    CEDirectMessagesProhibited MsgDirection
dir Contact
ct -> MsgDirection -> Contact -> [StyledString]
viewDirectMessagesProhibited MsgDirection
dir Contact
ct
    ChatErrorType
CEAgentVersion -> [StyledString
"unsupported agent version"]
    CEAgentNoSubResult AgentConnId
connId -> [StyledString
"no subscription result for connection: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentConnId -> StyledString
forall a. Show a => a -> StyledString
sShow AgentConnId
connId]
    CEServerProtocol AProtocolType
p -> [ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ ByteString
"Servers for protocol " ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> AProtocolType -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode AProtocolType
p ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
" cannot be configured by the users"]
    CECommandError String
e -> [StyledString
"bad chat command: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
    CEAgentCommandError String
e -> [StyledString
"agent command error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
    CEInvalidFileDescription String
e -> [StyledString
"invalid file description: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
    ChatErrorType
CEConnectionIncognitoChangeProhibited -> [StyledString
"incognito mode change prohibited"]
    ChatErrorType
CEConnectionUserChangeProhibited -> [StyledString
"incognito mode change prohibited for user"]
    ChatErrorType
CEPeerChatVRangeIncompatible -> [StyledString
"peer chat protocol version range incompatible"]
    CEInternalError String
e -> [StyledString
"internal chat error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
    CEException String
e -> [StyledString
"exception: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e]
  -- e -> ["chat error: " <> sShow e]
  ChatErrorStore StoreError
err -> case StoreError
err of
    StoreError
SEDuplicateName -> [StyledString
"this display name is already used by user, contact or group"]
    SEUserNotFoundByName ContactName
u -> [StyledString
"no user " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
u]
    SEContactNotFoundByName ContactName
c -> [StyledString
"no contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c]
    SEContactNotReady ContactName
c -> [StyledString
"contact " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" is not active yet"]
    SEGroupNotFoundByName ContactName
g -> [StyledString
"no group " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyGroup ContactName
g]
    StoreError
SEGroupAlreadyJoined -> [StyledString
"you already joined this group"]
    SEFileNotFound ContactId
fileId -> ContactId -> [StyledString]
forall {a}. Show a => a -> [StyledString]
fileNotFound ContactId
fileId
    SESndFileNotFound ContactId
fileId -> ContactId -> [StyledString]
forall {a}. Show a => a -> [StyledString]
fileNotFound ContactId
fileId
    SERcvFileNotFound ContactId
fileId -> ContactId -> [StyledString]
forall {a}. Show a => a -> [StyledString]
fileNotFound ContactId
fileId
    StoreError
SEDuplicateContactLink -> [StyledString
"you already have chat address, to show: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/sa"]
    StoreError
SEUserContactLinkNotFound -> [StyledString
"no chat address, to create: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
highlight' String
"/ad"]
    SEContactRequestNotFoundByName ContactName
c -> [StyledString
"no contact request from " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyContact ContactName
c]
    SEFileIdNotFoundBySharedMsgId SharedMsgId
_ -> [] -- recipient tried to accept cancelled file
    SEConnectionNotFound AgentConnId
agentConnId -> [StyledString
"event connection not found, agent ID: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentConnId -> StyledString
forall a. Show a => a -> StyledString
sShow AgentConnId
agentConnId | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLWarning] -- mutes delete group error
    SEChatItemNotFoundByText ContactName
text -> [StyledString
"message not found by text: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
text]
    SEDuplicateGroupLink GroupInfo
g -> [StyledString
"you already have link for this group, to show: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/show link #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g)]
    SEGroupLinkNotFound GroupInfo
g -> [StyledString
"no group link, to create: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/create link #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g)]
    SERemoteCtrlNotFound ContactId
rcId -> [StyledString
"no remote controller " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rcId]
    SERemoteHostNotFound ContactId
rhId -> [StyledString
"no remote host " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
rhId]
    SEDuplicateGroupMessage {ContactId
groupId :: ContactId
groupId :: StoreError -> ContactId
groupId, SharedMsgId
sharedMsgId :: SharedMsgId
sharedMsgId :: StoreError -> SharedMsgId
sharedMsgId}
      | Bool
testView -> [StyledString
"duplicate group message, group id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
groupId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", message id: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SharedMsgId -> StyledString
forall a. Show a => a -> StyledString
sShow SharedMsgId
sharedMsgId]
      | Bool
otherwise -> []
    StoreError
SEUserNoteFolderNotFound -> [StyledString
"no notes folder"]
    SEInternalError {String
message :: String
message :: StoreError -> String
message}
      | Bool
testView Bool -> Bool -> Bool
&& String
message String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"referenced group member not found" -> []
    StoreError
e -> [StyledString
"chat db error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StoreError -> StyledString
forall a. Show a => a -> StyledString
sShow StoreError
e]
  ChatErrorDatabase DatabaseError
err -> case DatabaseError
err of
    DatabaseError
DBErrorEncrypted -> [StyledString
"error: chat database is already encrypted"]
    DatabaseError
DBErrorPlaintext -> [StyledString
"error: chat database is not encrypted"]
    DBErrorExport SQLiteError
e -> [StyledString
"error encrypting database: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SQLiteError -> StyledString
sqliteError' SQLiteError
e]
    DBErrorOpen SQLiteError
e -> [StyledString
"error opening database after encryption: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> SQLiteError -> StyledString
sqliteError' SQLiteError
e]
    DatabaseError
e -> [StyledString
"chat database error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> DatabaseError -> StyledString
forall a. Show a => a -> StyledString
sShow DatabaseError
e]
  ChatErrorAgent AgentErrorType
err (AgentConnId ByteString
acId) Maybe ConnectionEntity
entity_ -> case AgentErrorType
err of
    CMD CommandErrorType
PROHIBITED String
cxt -> [StyledString
withConnEntity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String
"error: command is prohibited, " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
cxt)]
    SMP String
_ ErrorType
SMP.AUTH ->
      [ StyledString
withConnEntity
          StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"error: connection authorization failed - this could happen if connection was deleted, secured with different credentials, or due to a bug - please re-create the connection"
      ]
    SMP String
_ (SMP.BLOCKED BlockingInfo {BlockingReason
reason :: BlockingReason
reason :: BlockingInfo -> BlockingReason
reason}) ->
      [StyledString
withConnEntity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"error: connection blocked by server operator: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
reasonStr]
      where
        reasonStr :: StyledString
reasonStr = case BlockingReason
reason of
          BlockingReason
BRSpam -> StyledString
"spam"
          BlockingReason
BRContent -> StyledString
"content violates conditions of use"
    BROKER String
_ (NETWORK NetworkError
_) | Bool -> Bool
not Bool
isCmd -> []
    BROKER String
_ BrokerErrorType
TIMEOUT | Bool -> Bool
not Bool
isCmd -> []
    AGENT SMPAgentError
A_DUPLICATE -> [StyledString
withConnEntity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"error: AGENT A_DUPLICATE" | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Eq a => a -> a -> Bool
== ChatLogLevel
CLLDebug Bool -> Bool -> Bool
|| Bool
isCmd]
    AGENT (A_PROHIBITED String
e) -> [StyledString
withConnEntity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"error: AGENT A_PROHIBITED, " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain String
e | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLWarning Bool -> Bool -> Bool
|| Bool
isCmd]
    CONN ConnectionErrorType
NOT_FOUND String
_ -> [StyledString
withConnEntity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"error: CONN NOT_FOUND" | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLWarning Bool -> Bool -> Bool
|| Bool
isCmd]
    CRITICAL Bool
restart String
e -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"critical error: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
e] [StyledString] -> [StyledString] -> [StyledString]
forall a. Semigroup a => a -> a -> a
<> [StyledString
"please restart the app" | Bool
restart]
    INTERNAL String
e -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"internal error: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
e]
    AgentErrorType
e -> [StyledString
withConnEntity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"smp agent error: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> AgentErrorType -> StyledString
forall a. Show a => a -> StyledString
sShow AgentErrorType
e | ChatLogLevel
logLevel ChatLogLevel -> ChatLogLevel -> Bool
forall a. Ord a => a -> a -> Bool
<= ChatLogLevel
CLLWarning Bool -> Bool -> Bool
|| Bool
isCmd]
    where
      withConnEntity :: StyledString
withConnEntity = case Maybe ConnectionEntity
entity_ of
        Just entity :: ConnectionEntity
entity@(RcvDirectMsgConnection Connection
conn Maybe Contact
contact_) -> case Maybe Contact
contact_ of
          Just Contact {ContactId
contactId :: Contact -> ContactId
contactId :: ContactId
contactId} ->
            StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ConnectionEntity -> StyledString
connEntityLabel ConnectionEntity
entity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", contactId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
contactId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", connId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Connection -> StyledString
cId Connection
conn StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] "
          Maybe Contact
Nothing ->
            StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ConnectionEntity -> StyledString
connEntityLabel ConnectionEntity
entity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", connId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Connection -> StyledString
cId Connection
conn StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] "
        Just entity :: ConnectionEntity
entity@(RcvGroupMsgConnection Connection
conn GroupInfo {ContactId
groupId :: GroupInfo -> ContactId
groupId :: ContactId
groupId} GroupMember {ContactId
groupMemberId :: GroupMember -> ContactId
groupMemberId :: ContactId
groupMemberId}) ->
          StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ConnectionEntity -> StyledString
connEntityLabel ConnectionEntity
entity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", groupId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
groupId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", memberId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
groupMemberId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", connId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Connection -> StyledString
cId Connection
conn StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] "
        Just entity :: ConnectionEntity
entity@(UserContactConnection Connection
conn UserContact {ContactId
userContactLinkId :: ContactId
userContactLinkId :: UserContact -> ContactId
userContactLinkId}) ->
          StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ConnectionEntity -> StyledString
connEntityLabel ConnectionEntity
entity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", userContactLinkId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
userContactLinkId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", connId: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> Connection -> StyledString
cId Connection
conn StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] "
        Maybe ConnectionEntity
Nothing
          | ByteString
acId ByteString -> ByteString -> Bool
forall a. Eq a => a -> a -> Bool
== ByteString
"" -> StyledString
""
          | Bool
otherwise -> ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString) -> ByteString -> StyledString
forall a b. (a -> b) -> a -> b
$ ByteString
"agent conn ID: " ByteString -> ByteString -> ByteString
forall a. Semigroup a => a -> a -> a
<> ByteString
acId
      cId :: Connection -> StyledString
      cId :: Connection -> StyledString
cId Connection {ContactId
connId :: Connection -> ContactId
connId :: ContactId
connId} = ContactId -> StyledString
forall a. Show a => a -> StyledString
sShow ContactId
connId
  ChatErrorRemoteCtrl RemoteCtrlError
e -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"remote controller error: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> RemoteCtrlError -> String
forall a. Show a => a -> String
show RemoteCtrlError
e]
  ChatErrorRemoteHost RHKey
RHNew RemoteHostError
e -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"new remote host error: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> RemoteHostError -> String
forall a. Show a => a -> String
show RemoteHostError
e]
  ChatErrorRemoteHost (RHId ContactId
rhId) RemoteHostError
e -> [String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (String -> StyledString) -> String -> StyledString
forall a b. (a -> b) -> a -> b
$ String
"remote host " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> ContactId -> String
forall a. Show a => a -> String
show ContactId
rhId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" error: " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> RemoteHostError -> String
forall a. Show a => a -> String
show RemoteHostError
e]
  where
    fileNotFound :: a -> [StyledString]
fileNotFound a
fileId = [StyledString
"file " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> a -> StyledString
forall a. Show a => a -> StyledString
sShow a
fileId StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
" not found"]
    sqliteError' :: SQLiteError -> StyledString
sqliteError' = \case
      SQLiteError
SQLiteErrorNotADatabase -> StyledString
"wrong passphrase or invalid database file"
      SQLiteError String
e -> String -> StyledString
forall a. Show a => a -> StyledString
sShow String
e

viewConnectionEntityDisabled :: ConnectionEntity -> [StyledString]
viewConnectionEntityDisabled :: ConnectionEntity -> [StyledString]
viewConnectionEntityDisabled ConnectionEntity
entity = case ConnectionEntity
entity of
  RcvDirectMsgConnection Connection
_ (Just Contact
c) -> [StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
entityLabel StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] connection is disabled, to enable: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/enable " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
c) StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", to delete: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/d " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Contact -> ContactName
viewContactName Contact
c)]
  RcvGroupMsgConnection Connection
_ GroupInfo
g GroupMember
m -> [StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
entityLabel StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] connection is disabled, to enable: " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight (ContactName
"/enable #" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
viewMemberName GroupMember
m)]
  ConnectionEntity
_ -> [StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
entityLabel StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] connection is disabled"]
  where
    entityLabel :: StyledString
entityLabel = ConnectionEntity -> StyledString
connEntityLabel ConnectionEntity
entity

viewConnectionEntityInactive :: ConnectionEntity -> Bool -> [StyledString]
viewConnectionEntityInactive :: ConnectionEntity -> Bool -> [StyledString]
viewConnectionEntityInactive ConnectionEntity
entity Bool
inactive
  | Bool
inactive = [StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ConnectionEntity -> StyledString
connEntityLabel ConnectionEntity
entity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] connection is marked as inactive"]
  | Bool
otherwise = [StyledString
"[" StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ConnectionEntity -> StyledString
connEntityLabel ConnectionEntity
entity StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
"] inactive connection is marked as active"]

viewJSON :: J.ToJSON a => a -> StyledString
viewJSON :: forall a. ToJSON a => a -> StyledString
viewJSON = ByteString -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ByteString -> StyledString)
-> (a -> ByteString) -> a -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
LB.toStrict (ByteString -> ByteString) -> (a -> ByteString) -> a -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ByteString
forall a. ToJSON a => a -> ByteString
J.encode

connEntityLabel :: ConnectionEntity -> StyledString
connEntityLabel :: ConnectionEntity -> StyledString
connEntityLabel = \case
  RcvDirectMsgConnection Connection
_ (Just Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c}) -> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain ContactName
c
  RcvDirectMsgConnection Connection
_ Maybe Contact
Nothing -> StyledString
"rcv direct msg"
  RcvGroupMsgConnection Connection
_ GroupInfo {localDisplayName :: GroupInfo -> ContactName
localDisplayName = ContactName
g} GroupMember {localDisplayName :: GroupMember -> ContactName
localDisplayName = ContactName
m} -> ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
m
  UserContactConnection Connection
_ UserContact {} -> StyledString
"contact address"

ttyContact :: ContactName -> StyledString
ttyContact :: ContactName -> StyledString
ttyContact = Format -> ContactName -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Color -> Format
colored Color
Green) (ContactName -> StyledString)
-> (ContactName -> ContactName) -> ContactName -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactName -> ContactName
viewName

ttyContact' :: Contact -> StyledString
ttyContact' :: Contact -> StyledString
ttyContact' Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} = ContactName -> StyledString
ttyContact ContactName
c

ttyFullContact :: Contact -> StyledString
ttyFullContact :: Contact -> StyledString
ttyFullContact Contact {ContactName
localDisplayName :: Contact -> ContactName
localDisplayName :: ContactName
localDisplayName, profile :: Contact -> LocalProfile
profile = LocalProfile {ContactName
fullName :: LocalProfile -> ContactName
fullName :: ContactName
fullName, Maybe ContactName
shortDescr :: LocalProfile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr}} =
  ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
localDisplayName ContactName
fullName Maybe ContactName
shortDescr

ttyMember :: GroupMember -> StyledString
ttyMember :: GroupMember -> StyledString
ttyMember GroupMember {ContactName
localDisplayName :: GroupMember -> ContactName
localDisplayName :: ContactName
localDisplayName} = ContactName -> StyledString
ttyContact ContactName
localDisplayName

ttyFullMember :: GroupMember -> StyledString
ttyFullMember :: GroupMember -> StyledString
ttyFullMember GroupMember {ContactName
localDisplayName :: GroupMember -> ContactName
localDisplayName :: ContactName
localDisplayName, memberProfile :: GroupMember -> LocalProfile
memberProfile = LocalProfile {ContactName
fullName :: LocalProfile -> ContactName
fullName :: ContactName
fullName, Maybe ContactName
shortDescr :: LocalProfile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr}} =
  ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
localDisplayName ContactName
fullName Maybe ContactName
shortDescr

ttyFullName :: ContactName -> Text -> Maybe Text -> StyledString
ttyFullName :: ContactName -> ContactName -> Maybe ContactName -> StyledString
ttyFullName ContactName
c ContactName
fullName Maybe ContactName
shortDescr = ContactName -> StyledString
ttyContact ContactName
c StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName -> Maybe ContactName -> StyledString
optFullName ContactName
c ContactName
fullName Maybe ContactName
shortDescr

ttyToContact :: ContactName -> StyledString
ttyToContact :: ContactName -> StyledString
ttyToContact ContactName
c = ContactName -> StyledString
ttyTo (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"@" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
c ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" "

ttyToContact' :: Contact -> StyledString
ttyToContact' :: Contact -> StyledString
ttyToContact' ct :: Contact
ct@Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} = Contact -> StyledString
ctIncognito Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyToContact ContactName
c

ttyToContactEdited' :: Contact -> StyledString
ttyToContactEdited' :: Contact -> StyledString
ttyToContactEdited' ct :: Contact
ct@Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} = Contact -> StyledString
ctIncognito Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyTo (ContactName
"@" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
c ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" [edited] ")

ttyQuotedContact :: Contact -> StyledString
ttyQuotedContact :: Contact -> StyledString
ttyQuotedContact Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} = ContactName -> StyledString
ttyFrom (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName -> ContactName
viewName ContactName
c ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
">"

ttyQuotedMember :: Maybe GroupMember -> StyledString
ttyQuotedMember :: Maybe GroupMember -> StyledString
ttyQuotedMember (Just GroupMember {localDisplayName :: GroupMember -> ContactName
localDisplayName = ContactName
c}) = StyledString
"> " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom (ContactName -> ContactName
viewName ContactName
c)
ttyQuotedMember Maybe GroupMember
_ = StyledString
"> " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom ContactName
"?"

ttyFromContact :: Contact -> StyledString
ttyFromContact :: Contact -> StyledString
ttyFromContact ct :: Contact
ct@Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} = Contact -> StyledString
ctIncognito Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom (ContactName -> ContactName
viewName ContactName
c ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"> ")

ttyFromContactEdited :: Contact -> StyledString
ttyFromContactEdited :: Contact -> StyledString
ttyFromContactEdited ct :: Contact
ct@Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} = Contact -> StyledString
ctIncognito Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom (ContactName -> ContactName
viewName ContactName
c ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"> [edited] ")

ttyFromContactDeleted :: Contact -> Maybe Text -> StyledString
ttyFromContactDeleted :: Contact -> Maybe ContactName -> StyledString
ttyFromContactDeleted ct :: Contact
ct@Contact {localDisplayName :: Contact -> ContactName
localDisplayName = ContactName
c} Maybe ContactName
deletedText_ =
  Contact -> StyledString
ctIncognito Contact
ct StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom (ContactName -> ContactName
viewName ContactName
c ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"> " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (ContactName -> ContactName) -> Maybe ContactName -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (\ContactName
t -> ContactName
"[" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
t ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"] ") Maybe ContactName
deletedText_)

ttyGroup :: GroupName -> StyledString
ttyGroup :: ContactName -> StyledString
ttyGroup ContactName
g = Format -> ContactName -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Color -> Format
colored Color
Blue) (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName
viewName ContactName
g

ttyGroup' :: GroupInfo -> StyledString
ttyGroup' :: GroupInfo -> StyledString
ttyGroup' = ContactName -> StyledString
ttyGroup (ContactName -> StyledString)
-> (GroupInfo -> ContactName) -> GroupInfo -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupInfo -> ContactName
groupName'

viewContactName :: Contact -> Text
viewContactName :: Contact -> ContactName
viewContactName = ContactName -> ContactName
viewName (ContactName -> ContactName)
-> (Contact -> ContactName) -> Contact -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Contact -> ContactName
forall a. IsContact a => a -> ContactName
localDisplayName'

viewGroupName :: GroupInfo -> Text
viewGroupName :: GroupInfo -> ContactName
viewGroupName = ContactName -> ContactName
viewName (ContactName -> ContactName)
-> (GroupInfo -> ContactName) -> GroupInfo -> ContactName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupInfo -> ContactName
groupName'

viewMemberName :: GroupMember -> Text
viewMemberName :: GroupMember -> ContactName
viewMemberName GroupMember {localDisplayName :: GroupMember -> ContactName
localDisplayName = ContactName
n} = ContactName -> ContactName
viewName ContactName
n

ttyGroups :: [GroupName] -> StyledString
ttyGroups :: [ContactName] -> StyledString
ttyGroups [] = StyledString
""
ttyGroups [ContactName
g] = ContactName -> StyledString
ttyGroup ContactName
g
ttyGroups (ContactName
g : [ContactName]
gs) = ContactName -> StyledString
ttyGroup ContactName
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> StyledString
", " StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> [ContactName] -> StyledString
ttyGroups [ContactName]
gs

ttyFullGroup :: GroupInfo -> StyledString
ttyFullGroup :: GroupInfo -> StyledString
ttyFullGroup GroupInfo {localDisplayName :: GroupInfo -> ContactName
localDisplayName = ContactName
g, groupProfile :: GroupInfo -> GroupProfile
groupProfile = GroupProfile {ContactName
fullName :: GroupProfile -> ContactName
fullName :: ContactName
fullName, Maybe ContactName
shortDescr :: GroupProfile -> Maybe ContactName
shortDescr :: Maybe ContactName
shortDescr}} =
  ContactName -> StyledString
ttyGroup ContactName
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> ContactName -> Maybe ContactName -> StyledString
optFullName ContactName
g ContactName
fullName Maybe ContactName
shortDescr

ttyFromGroup :: GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroup :: GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m = GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> StyledString
ttyFromGroupAttention GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Bool
False

ttyFromGroupAttention :: GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> StyledString
ttyFromGroupAttention :: GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> StyledString
ttyFromGroupAttention GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Bool
attention = GroupInfo -> StyledString
membershipIncognito GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom (GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> ContactName
fromGroupAttention_ GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Bool
attention)

ttyFromGroupEdited :: GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroupEdited :: GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> StyledString
ttyFromGroupEdited GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m = GroupInfo -> StyledString
membershipIncognito GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom (GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> ContactName
fromGroup_ GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"[edited] ")

ttyFromGroupDeleted :: GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> Maybe Text -> StyledString
ttyFromGroupDeleted :: GroupInfo
-> Maybe GroupChatScopeInfo
-> GroupMember
-> Maybe ContactName
-> StyledString
ttyFromGroupDeleted GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Maybe ContactName
deletedText_ =
  GroupInfo -> StyledString
membershipIncognito GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyFrom (GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> ContactName
fromGroup_ GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
-> (ContactName -> ContactName) -> Maybe ContactName -> ContactName
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ContactName
"" (\ContactName
t -> ContactName
"[" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
t ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"] ") Maybe ContactName
deletedText_)

fromGroup_ :: GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> Text
fromGroup_ :: GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> ContactName
fromGroup_ GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m = GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> ContactName
fromGroupAttention_ GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Bool
False

fromGroupAttention_ :: GroupInfo -> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> Text
fromGroupAttention_ :: GroupInfo
-> Maybe GroupChatScopeInfo -> GroupMember -> Bool -> ContactName
fromGroupAttention_ GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo GroupMember
m Bool
attention =
  let attn :: ContactName
attn = if Bool
attention then ContactName
"!" else ContactName
""
   in ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Maybe GroupChatScopeInfo -> ContactName
groupScopeInfoStr Maybe GroupChatScopeInfo
scopeInfo ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
viewMemberName GroupMember
m ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
attn ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
"> "

ttyFrom :: Text -> StyledString
ttyFrom :: ContactName -> StyledString
ttyFrom = Format -> ContactName -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Format -> ContactName -> StyledString)
-> Format -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ Color -> Format
colored Color
Yellow

ttyTo :: Text -> StyledString
ttyTo :: ContactName -> StyledString
ttyTo = Format -> ContactName -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Format -> ContactName -> StyledString)
-> Format -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ Color -> Format
colored Color
Cyan

ttyToGroup :: GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroup :: GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroup GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo = GroupInfo -> StyledString
membershipIncognito GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyTo (ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Maybe GroupChatScopeInfo -> ContactName
groupScopeInfoStr Maybe GroupChatScopeInfo
scopeInfo)

ttyToGroupEdited :: GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroupEdited :: GroupInfo -> Maybe GroupChatScopeInfo -> StyledString
ttyToGroupEdited GroupInfo
g Maybe GroupChatScopeInfo
scopeInfo = GroupInfo -> StyledString
membershipIncognito GroupInfo
g StyledString -> StyledString -> StyledString
forall a. Semigroup a => a -> a -> a
<> ContactName -> StyledString
ttyTo (ContactName
"#" ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupInfo -> ContactName
viewGroupName GroupInfo
g ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> Maybe GroupChatScopeInfo -> ContactName
groupScopeInfoStr Maybe GroupChatScopeInfo
scopeInfo ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
" [edited] ")

groupScopeInfoStr :: Maybe GroupChatScopeInfo -> Text
groupScopeInfoStr :: Maybe GroupChatScopeInfo -> ContactName
groupScopeInfoStr = \case
  Maybe GroupChatScopeInfo
Nothing -> ContactName
""
  Just (GCSIMemberSupport {Maybe GroupMember
groupMember_ :: Maybe GroupMember
groupMember_ :: GroupChatScopeInfo -> Maybe GroupMember
groupMember_}) -> case Maybe GroupMember
groupMember_ of
    Maybe GroupMember
Nothing -> ContactName
"(support) "
    Just GroupMember
m -> ContactName
"(support: " ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> GroupMember -> ContactName
viewMemberName GroupMember
m ContactName -> ContactName -> ContactName
forall a. Semigroup a => a -> a -> a
<> ContactName
") "

ttyFilePath :: FilePath -> StyledString
ttyFilePath :: String -> StyledString
ttyFilePath = String -> StyledString
forall a. StyledFormat a => a -> StyledString
plain

optFullName :: ContactName -> Text -> Maybe Text -> StyledString
optFullName :: ContactName -> ContactName -> Maybe ContactName -> StyledString
optFullName ContactName
localDisplayName ContactName
fullName Maybe ContactName
shortDescr = ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
plain (ContactName -> StyledString) -> ContactName -> StyledString
forall a b. (a -> b) -> a -> b
$ ContactName -> ContactName -> Maybe ContactName -> ContactName
optionalFullName ContactName
localDisplayName ContactName
fullName Maybe ContactName
shortDescr

ctIncognito :: Contact -> StyledString
ctIncognito :: Contact -> StyledString
ctIncognito Contact
ct = if Contact -> Bool
contactConnIncognito Contact
ct then StyledString
incognitoPrefix else StyledString
""

membershipIncognito :: GroupInfo -> StyledString
membershipIncognito :: GroupInfo -> StyledString
membershipIncognito = GroupMember -> StyledString
memIncognito (GroupMember -> StyledString)
-> (GroupInfo -> GroupMember) -> GroupInfo -> StyledString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupInfo -> GroupMember
membership

memIncognito :: GroupMember -> StyledString
memIncognito :: GroupMember -> StyledString
memIncognito GroupMember
m = if GroupMember -> Bool
memberIncognito GroupMember
m then StyledString
incognitoPrefix else StyledString
""

incognitoPrefix :: StyledString
incognitoPrefix :: StyledString
incognitoPrefix = String -> StyledString
styleIncognito' String
"i "

incognitoProfile' :: Profile -> StyledString
incognitoProfile' :: Profile -> StyledString
incognitoProfile' Profile {ContactName
displayName :: Profile -> ContactName
displayName :: ContactName
displayName} = ContactName -> StyledString
forall a. StyledFormat a => a -> StyledString
styleIncognito ContactName
displayName

highlight :: StyledFormat a => a -> StyledString
highlight :: forall a. StyledFormat a => a -> StyledString
highlight = Format -> a -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Format -> a -> StyledString) -> Format -> a -> StyledString
forall a b. (a -> b) -> a -> b
$ Color -> Format
colored Color
Cyan

highlight' :: String -> StyledString
highlight' :: String -> StyledString
highlight' = String -> StyledString
forall a. StyledFormat a => a -> StyledString
highlight

styleIncognito :: StyledFormat a => a -> StyledString
styleIncognito :: forall a. StyledFormat a => a -> StyledString
styleIncognito = Format -> a -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Format -> a -> StyledString) -> Format -> a -> StyledString
forall a b. (a -> b) -> a -> b
$ Color -> Format
colored Color
Magenta

styleIncognito' :: String -> StyledString
styleIncognito' :: String -> StyledString
styleIncognito' = String -> StyledString
forall a. StyledFormat a => a -> StyledString
styleIncognito

styleTime :: String -> StyledString
styleTime :: String -> StyledString
styleTime = [SGR] -> String -> StyledString
Styled [ConsoleLayer -> ColorIntensity -> Color -> SGR
SetColor ConsoleLayer
Foreground ColorIntensity
Vivid Color
Black]

ttyError :: StyledFormat a => a -> StyledString
ttyError :: forall a. StyledFormat a => a -> StyledString
ttyError = Format -> a -> StyledString
forall a. StyledFormat a => Format -> a -> StyledString
styled (Format -> a -> StyledString) -> Format -> a -> StyledString
forall a b. (a -> b) -> a -> b
$ Color -> Format
colored Color
Red

ttyError' :: String -> StyledString
ttyError' :: String -> StyledString
ttyError' = String -> StyledString
forall a. StyledFormat a => a -> StyledString
ttyError