{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# OPTIONS_GHC -fno-warn-ambiguous-fields #-}
{-# HLINT ignore "Use newtype instead of data" #-}
module Simplex.Chat.Types where
import Control.Applicative ((<|>))
import Crypto.Number.Serialize (os2ip)
import Data.Aeson (FromJSON (..), ToJSON (..))
import qualified Data.Aeson as J
import qualified Data.Aeson.Encoding as JE
import qualified Data.Aeson.TH as JQ
import qualified Data.Attoparsec.ByteString.Char8 as A
import qualified Data.ByteString.Base64 as B64
import Data.ByteString.Char8 (ByteString, pack, unpack)
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy as LB
import Data.Functor (($>))
import Data.Int (Int64)
import Data.Maybe (fromMaybe, isJust, isNothing)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Encoding (encodeUtf8)
import Data.Time.Clock (UTCTime)
import Data.Typeable (Typeable)
import Data.Word (Word16)
import Simplex.Chat.Types.Preferences
import Simplex.Chat.Types.Shared
import Simplex.Chat.Types.UITheme
import Simplex.FileTransfer.Description (FileDigest)
import Simplex.FileTransfer.Types (RcvFileId, SndFileId)
import Simplex.Messaging.Agent.Protocol (ACorrId, ACreatedConnLink, AEventTag (..), AEvtTag (..), ConnId, ConnShortLink, ConnectionLink, ConnectionMode (..), ConnectionRequestUri, CreatedConnLink, InvitationId, SAEntity (..), UserId)
import Simplex.Messaging.Agent.Store.DB (Binary (..), blobFieldDecoder, fromTextField_)
import Simplex.Messaging.Crypto.File (CryptoFileArgs (..))
import Simplex.Messaging.Crypto.Ratchet (PQEncryption (..), PQSupport, pattern PQEncOff)
import Simplex.Messaging.Encoding.String
import Simplex.Messaging.Parsers (defaultJSON, dropPrefix, enumJSON, sumTypeJSON)
import Simplex.Messaging.Util (decodeJSON, encodeJSON, safeDecodeUtf8, (<$?>))
import Simplex.Messaging.Version
import Simplex.Messaging.Version.Internal
#if defined(dbPostgres)
import Database.PostgreSQL.Simple (ResultError (..))
import Database.PostgreSQL.Simple.FromField (FromField(..), FieldParser, returnError)
import Database.PostgreSQL.Simple.ToField (ToField (..))
#else
import Database.SQLite.Simple (ResultError (..))
import Database.SQLite.Simple.FromField (FromField (..), FieldParser, returnError)
import Database.SQLite.Simple.ToField (ToField (..))
#endif
class IsContact a where
contactId' :: a -> ContactId
profile' :: a -> LocalProfile
localDisplayName' :: a -> ContactName
preferences' :: a -> Maybe Preferences
instance IsContact User where
contactId' :: User -> CommandId
contactId' User {CommandId
userContactId :: CommandId
userContactId :: User -> CommandId
userContactId} = CommandId
userContactId
{-# INLINE contactId' #-}
profile' :: User -> LocalProfile
profile' User {LocalProfile
profile :: LocalProfile
profile :: User -> LocalProfile
profile} = LocalProfile
profile
{-# INLINE profile' #-}
localDisplayName' :: User -> Text
localDisplayName' User {Text
localDisplayName :: Text
localDisplayName :: User -> Text
localDisplayName} = Text
localDisplayName
{-# INLINE localDisplayName' #-}
preferences' :: User -> Maybe Preferences
preferences' User {profile :: User -> LocalProfile
profile = LocalProfile {Maybe Preferences
preferences :: Maybe Preferences
preferences :: LocalProfile -> Maybe Preferences
preferences}} = Maybe Preferences
preferences
{-# INLINE preferences' #-}
instance IsContact Contact where
contactId' :: Contact -> CommandId
contactId' Contact {CommandId
contactId :: CommandId
contactId :: Contact -> CommandId
contactId} = CommandId
contactId
{-# INLINE contactId' #-}
profile' :: Contact -> LocalProfile
profile' Contact {LocalProfile
profile :: LocalProfile
profile :: Contact -> LocalProfile
profile} = LocalProfile
profile
{-# INLINE profile' #-}
localDisplayName' :: Contact -> Text
localDisplayName' Contact {Text
localDisplayName :: Text
localDisplayName :: Contact -> Text
localDisplayName} = Text
localDisplayName
{-# INLINE localDisplayName' #-}
preferences' :: Contact -> Maybe Preferences
preferences' Contact {profile :: Contact -> LocalProfile
profile = LocalProfile {Maybe Preferences
preferences :: LocalProfile -> Maybe Preferences
preferences :: Maybe Preferences
preferences}} = Maybe Preferences
preferences
{-# INLINE preferences' #-}
newtype AgentUserId = AgentUserId UserId
deriving (AgentUserId -> AgentUserId -> Bool
(AgentUserId -> AgentUserId -> Bool)
-> (AgentUserId -> AgentUserId -> Bool) -> Eq AgentUserId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AgentUserId -> AgentUserId -> Bool
== :: AgentUserId -> AgentUserId -> Bool
$c/= :: AgentUserId -> AgentUserId -> Bool
/= :: AgentUserId -> AgentUserId -> Bool
Eq, Int -> AgentUserId -> ShowS
[AgentUserId] -> ShowS
AgentUserId -> String
(Int -> AgentUserId -> ShowS)
-> (AgentUserId -> String)
-> ([AgentUserId] -> ShowS)
-> Show AgentUserId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AgentUserId -> ShowS
showsPrec :: Int -> AgentUserId -> ShowS
$cshow :: AgentUserId -> String
show :: AgentUserId -> String
$cshowList :: [AgentUserId] -> ShowS
showList :: [AgentUserId] -> ShowS
Show)
instance StrEncoding AgentUserId where
strEncode :: AgentUserId -> ByteString
strEncode (AgentUserId CommandId
uId) = CommandId -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode CommandId
uId
strDecode :: ByteString -> Either String AgentUserId
strDecode ByteString
s = CommandId -> AgentUserId
AgentUserId (CommandId -> AgentUserId)
-> Either String CommandId -> Either String AgentUserId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String CommandId
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser AgentUserId
strP = CommandId -> AgentUserId
AgentUserId (CommandId -> AgentUserId)
-> Parser ByteString CommandId -> Parser AgentUserId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString CommandId
forall a. StrEncoding a => Parser a
strP
instance FromJSON AgentUserId where
parseJSON :: Value -> Parser AgentUserId
parseJSON = String -> Value -> Parser AgentUserId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"AgentUserId"
instance ToJSON AgentUserId where
toJSON :: AgentUserId -> Value
toJSON = AgentUserId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: AgentUserId -> Encoding
toEncoding = AgentUserId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
deriving newtype instance FromField AgentUserId
instance ToField AgentUserId where toField :: AgentUserId -> SQLData
toField (AgentUserId CommandId
uId) = CommandId -> SQLData
forall a. ToField a => a -> SQLData
toField CommandId
uId
aUserId :: User -> UserId
aUserId :: User -> CommandId
aUserId User {agentUserId :: User -> AgentUserId
agentUserId = AgentUserId CommandId
uId} = CommandId
uId
data User = User
{ User -> CommandId
userId :: UserId,
User -> AgentUserId
agentUserId :: AgentUserId,
User -> CommandId
userContactId :: ContactId,
User -> Text
localDisplayName :: ContactName,
User -> LocalProfile
profile :: LocalProfile,
User -> FullPreferences
fullPreferences :: FullPreferences,
User -> Bool
activeUser :: Bool,
User -> CommandId
activeOrder :: Int64,
User -> Maybe UserPwdHash
viewPwdHash :: Maybe UserPwdHash,
User -> Bool
showNtfs :: Bool,
User -> Bool
sendRcptsContacts :: Bool,
User -> Bool
sendRcptsSmallGroups :: Bool,
User -> BoolDef
autoAcceptMemberContacts :: BoolDef,
User -> Maybe UTCTime
userMemberProfileUpdatedAt :: Maybe UTCTime,
User -> Maybe UIThemeEntityOverrides
uiThemes :: Maybe UIThemeEntityOverrides
}
deriving (Int -> User -> ShowS
[User] -> ShowS
User -> String
(Int -> User -> ShowS)
-> (User -> String) -> ([User] -> ShowS) -> Show User
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> User -> ShowS
showsPrec :: Int -> User -> ShowS
$cshow :: User -> String
show :: User -> String
$cshowList :: [User] -> ShowS
showList :: [User] -> ShowS
Show)
data NewUser = NewUser
{ NewUser -> Maybe Profile
profile :: Maybe Profile,
NewUser -> Bool
pastTimestamp :: Bool
}
deriving (Int -> NewUser -> ShowS
[NewUser] -> ShowS
NewUser -> String
(Int -> NewUser -> ShowS)
-> (NewUser -> String) -> ([NewUser] -> ShowS) -> Show NewUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NewUser -> ShowS
showsPrec :: Int -> NewUser -> ShowS
$cshow :: NewUser -> String
show :: NewUser -> String
$cshowList :: [NewUser] -> ShowS
showList :: [NewUser] -> ShowS
Show)
newtype B64UrlByteString = B64UrlByteString ByteString
deriving (B64UrlByteString -> B64UrlByteString -> Bool
(B64UrlByteString -> B64UrlByteString -> Bool)
-> (B64UrlByteString -> B64UrlByteString -> Bool)
-> Eq B64UrlByteString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: B64UrlByteString -> B64UrlByteString -> Bool
== :: B64UrlByteString -> B64UrlByteString -> Bool
$c/= :: B64UrlByteString -> B64UrlByteString -> Bool
/= :: B64UrlByteString -> B64UrlByteString -> Bool
Eq, Int -> B64UrlByteString -> ShowS
[B64UrlByteString] -> ShowS
B64UrlByteString -> String
(Int -> B64UrlByteString -> ShowS)
-> (B64UrlByteString -> String)
-> ([B64UrlByteString] -> ShowS)
-> Show B64UrlByteString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> B64UrlByteString -> ShowS
showsPrec :: Int -> B64UrlByteString -> ShowS
$cshow :: B64UrlByteString -> String
show :: B64UrlByteString -> String
$cshowList :: [B64UrlByteString] -> ShowS
showList :: [B64UrlByteString] -> ShowS
Show)
deriving newtype (FieldParser B64UrlByteString
FieldParser B64UrlByteString -> FromField B64UrlByteString
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser B64UrlByteString
fromField :: FieldParser B64UrlByteString
FromField)
instance ToField B64UrlByteString where toField :: B64UrlByteString -> SQLData
toField (B64UrlByteString ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding B64UrlByteString where
strEncode :: B64UrlByteString -> ByteString
strEncode (B64UrlByteString ByteString
m) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
m
strP :: Parser B64UrlByteString
strP = ByteString -> B64UrlByteString
B64UrlByteString (ByteString -> B64UrlByteString)
-> Parser ByteString ByteString -> Parser B64UrlByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON B64UrlByteString where
parseJSON :: Value -> Parser B64UrlByteString
parseJSON = String -> Value -> Parser B64UrlByteString
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"B64UrlByteString"
instance ToJSON B64UrlByteString where
toJSON :: B64UrlByteString -> Value
toJSON = B64UrlByteString -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: B64UrlByteString -> Encoding
toEncoding = B64UrlByteString -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
data UserPwdHash = UserPwdHash {UserPwdHash -> B64UrlByteString
hash :: B64UrlByteString, UserPwdHash -> B64UrlByteString
salt :: B64UrlByteString}
deriving (UserPwdHash -> UserPwdHash -> Bool
(UserPwdHash -> UserPwdHash -> Bool)
-> (UserPwdHash -> UserPwdHash -> Bool) -> Eq UserPwdHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserPwdHash -> UserPwdHash -> Bool
== :: UserPwdHash -> UserPwdHash -> Bool
$c/= :: UserPwdHash -> UserPwdHash -> Bool
/= :: UserPwdHash -> UserPwdHash -> Bool
Eq, Int -> UserPwdHash -> ShowS
[UserPwdHash] -> ShowS
UserPwdHash -> String
(Int -> UserPwdHash -> ShowS)
-> (UserPwdHash -> String)
-> ([UserPwdHash] -> ShowS)
-> Show UserPwdHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserPwdHash -> ShowS
showsPrec :: Int -> UserPwdHash -> ShowS
$cshow :: UserPwdHash -> String
show :: UserPwdHash -> String
$cshowList :: [UserPwdHash] -> ShowS
showList :: [UserPwdHash] -> ShowS
Show)
data UserInfo = UserInfo
{ UserInfo -> User
user :: User,
UserInfo -> Int
unreadCount :: Int
}
deriving (Int -> UserInfo -> ShowS
[UserInfo] -> ShowS
UserInfo -> String
(Int -> UserInfo -> ShowS)
-> (UserInfo -> String) -> ([UserInfo] -> ShowS) -> Show UserInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserInfo -> ShowS
showsPrec :: Int -> UserInfo -> ShowS
$cshow :: UserInfo -> String
show :: UserInfo -> String
$cshowList :: [UserInfo] -> ShowS
showList :: [UserInfo] -> ShowS
Show)
type ContactId = Int64
type ProfileId = Int64
type ChatTagId = Int64
data Contact = Contact
{ Contact -> CommandId
contactId :: ContactId,
Contact -> Text
localDisplayName :: ContactName,
Contact -> LocalProfile
profile :: LocalProfile,
Contact -> Maybe Connection
activeConn :: Maybe Connection,
Contact -> Bool
contactUsed :: Bool,
Contact -> ContactStatus
contactStatus :: ContactStatus,
Contact -> ChatSettings
chatSettings :: ChatSettings,
Contact -> Preferences
userPreferences :: Preferences,
Contact -> ContactUserPreferences
mergedPreferences :: ContactUserPreferences,
Contact -> UTCTime
createdAt :: UTCTime,
Contact -> UTCTime
updatedAt :: UTCTime,
Contact -> Maybe UTCTime
chatTs :: Maybe UTCTime,
Contact -> Maybe PreparedContact
preparedContact :: Maybe PreparedContact,
Contact -> Maybe CommandId
contactRequestId :: Maybe Int64,
Contact -> Maybe CommandId
contactGroupMemberId :: Maybe GroupMemberId,
Contact -> Bool
contactGrpInvSent :: Bool,
Contact -> Maybe GroupDirectInvitation
groupDirectInv :: Maybe GroupDirectInvitation,
Contact -> [CommandId]
chatTags :: [ChatTagId],
Contact -> Maybe CommandId
chatItemTTL :: Maybe Int64,
Contact -> Maybe UIThemeEntityOverrides
uiThemes :: Maybe UIThemeEntityOverrides,
Contact -> Bool
chatDeleted :: Bool,
Contact -> Maybe CustomData
customData :: Maybe CustomData
}
deriving (Contact -> Contact -> Bool
(Contact -> Contact -> Bool)
-> (Contact -> Contact -> Bool) -> Eq Contact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Contact -> Contact -> Bool
== :: Contact -> Contact -> Bool
$c/= :: Contact -> Contact -> Bool
/= :: Contact -> Contact -> Bool
Eq, Int -> Contact -> ShowS
[Contact] -> ShowS
Contact -> String
(Int -> Contact -> ShowS)
-> (Contact -> String) -> ([Contact] -> ShowS) -> Show Contact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Contact -> ShowS
showsPrec :: Int -> Contact -> ShowS
$cshow :: Contact -> String
show :: Contact -> String
$cshowList :: [Contact] -> ShowS
showList :: [Contact] -> ShowS
Show)
contactRequestId' :: Contact -> Maybe Int64
contactRequestId' :: Contact -> Maybe CommandId
contactRequestId' Contact {Maybe CommandId
contactRequestId :: Contact -> Maybe CommandId
contactRequestId :: Maybe CommandId
contactRequestId} = Maybe CommandId
contactRequestId
data PreparedContact = PreparedContact
{ PreparedContact -> ACreatedConnLink
connLinkToConnect :: ACreatedConnLink,
PreparedContact -> ConnectionMode
uiConnLinkType :: ConnectionMode,
PreparedContact -> Maybe SharedMsgId
welcomeSharedMsgId :: Maybe SharedMsgId,
PreparedContact -> Maybe SharedMsgId
requestSharedMsgId :: Maybe SharedMsgId
}
deriving (PreparedContact -> PreparedContact -> Bool
(PreparedContact -> PreparedContact -> Bool)
-> (PreparedContact -> PreparedContact -> Bool)
-> Eq PreparedContact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PreparedContact -> PreparedContact -> Bool
== :: PreparedContact -> PreparedContact -> Bool
$c/= :: PreparedContact -> PreparedContact -> Bool
/= :: PreparedContact -> PreparedContact -> Bool
Eq, Int -> PreparedContact -> ShowS
[PreparedContact] -> ShowS
PreparedContact -> String
(Int -> PreparedContact -> ShowS)
-> (PreparedContact -> String)
-> ([PreparedContact] -> ShowS)
-> Show PreparedContact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PreparedContact -> ShowS
showsPrec :: Int -> PreparedContact -> ShowS
$cshow :: PreparedContact -> String
show :: PreparedContact -> String
$cshowList :: [PreparedContact] -> ShowS
showList :: [PreparedContact] -> ShowS
Show)
data GroupDirectInvitation = GroupDirectInvitation
{ GroupDirectInvitation -> ConnReqInvitation
groupDirectInvLink :: ConnReqInvitation,
GroupDirectInvitation -> Maybe CommandId
fromGroupId_ :: Maybe GroupId,
GroupDirectInvitation -> Maybe CommandId
fromGroupMemberId_ :: Maybe GroupMemberId,
GroupDirectInvitation -> Maybe CommandId
fromGroupMemberConnId_ :: Maybe Int64,
GroupDirectInvitation -> Bool
groupDirectInvStartedConnection :: Bool
}
deriving (GroupDirectInvitation -> GroupDirectInvitation -> Bool
(GroupDirectInvitation -> GroupDirectInvitation -> Bool)
-> (GroupDirectInvitation -> GroupDirectInvitation -> Bool)
-> Eq GroupDirectInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupDirectInvitation -> GroupDirectInvitation -> Bool
== :: GroupDirectInvitation -> GroupDirectInvitation -> Bool
$c/= :: GroupDirectInvitation -> GroupDirectInvitation -> Bool
/= :: GroupDirectInvitation -> GroupDirectInvitation -> Bool
Eq, Int -> GroupDirectInvitation -> ShowS
[GroupDirectInvitation] -> ShowS
GroupDirectInvitation -> String
(Int -> GroupDirectInvitation -> ShowS)
-> (GroupDirectInvitation -> String)
-> ([GroupDirectInvitation] -> ShowS)
-> Show GroupDirectInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupDirectInvitation -> ShowS
showsPrec :: Int -> GroupDirectInvitation -> ShowS
$cshow :: GroupDirectInvitation -> String
show :: GroupDirectInvitation -> String
$cshowList :: [GroupDirectInvitation] -> ShowS
showList :: [GroupDirectInvitation] -> ShowS
Show)
newtype SharedMsgId = SharedMsgId ByteString
deriving (SharedMsgId -> SharedMsgId -> Bool
(SharedMsgId -> SharedMsgId -> Bool)
-> (SharedMsgId -> SharedMsgId -> Bool) -> Eq SharedMsgId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SharedMsgId -> SharedMsgId -> Bool
== :: SharedMsgId -> SharedMsgId -> Bool
$c/= :: SharedMsgId -> SharedMsgId -> Bool
/= :: SharedMsgId -> SharedMsgId -> Bool
Eq, Int -> SharedMsgId -> ShowS
[SharedMsgId] -> ShowS
SharedMsgId -> String
(Int -> SharedMsgId -> ShowS)
-> (SharedMsgId -> String)
-> ([SharedMsgId] -> ShowS)
-> Show SharedMsgId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SharedMsgId -> ShowS
showsPrec :: Int -> SharedMsgId -> ShowS
$cshow :: SharedMsgId -> String
show :: SharedMsgId -> String
$cshowList :: [SharedMsgId] -> ShowS
showList :: [SharedMsgId] -> ShowS
Show)
deriving newtype (FieldParser SharedMsgId
FieldParser SharedMsgId -> FromField SharedMsgId
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser SharedMsgId
fromField :: FieldParser SharedMsgId
FromField)
instance ToField SharedMsgId where toField :: SharedMsgId -> SQLData
toField (SharedMsgId ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding SharedMsgId where
strEncode :: SharedMsgId -> ByteString
strEncode (SharedMsgId ByteString
m) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
m
strDecode :: ByteString -> Either String SharedMsgId
strDecode ByteString
s = ByteString -> SharedMsgId
SharedMsgId (ByteString -> SharedMsgId)
-> Either String ByteString -> Either String SharedMsgId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser SharedMsgId
strP = ByteString -> SharedMsgId
SharedMsgId (ByteString -> SharedMsgId)
-> Parser ByteString ByteString -> Parser SharedMsgId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON SharedMsgId where
parseJSON :: Value -> Parser SharedMsgId
parseJSON = String -> Value -> Parser SharedMsgId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"SharedMsgId"
instance ToJSON SharedMsgId where
toJSON :: SharedMsgId -> Value
toJSON = SharedMsgId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: SharedMsgId -> Encoding
toEncoding = SharedMsgId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
newtype CustomData = CustomData J.Object
deriving (CustomData -> CustomData -> Bool
(CustomData -> CustomData -> Bool)
-> (CustomData -> CustomData -> Bool) -> Eq CustomData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CustomData -> CustomData -> Bool
== :: CustomData -> CustomData -> Bool
$c/= :: CustomData -> CustomData -> Bool
/= :: CustomData -> CustomData -> Bool
Eq, Int -> CustomData -> ShowS
[CustomData] -> ShowS
CustomData -> String
(Int -> CustomData -> ShowS)
-> (CustomData -> String)
-> ([CustomData] -> ShowS)
-> Show CustomData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CustomData -> ShowS
showsPrec :: Int -> CustomData -> ShowS
$cshow :: CustomData -> String
show :: CustomData -> String
$cshowList :: [CustomData] -> ShowS
showList :: [CustomData] -> ShowS
Show)
instance ToJSON CustomData where
toJSON :: CustomData -> Value
toJSON (CustomData Object
v) = Object -> Value
forall a. ToJSON a => a -> Value
toJSON Object
v
toEncoding :: CustomData -> Encoding
toEncoding (CustomData Object
v) = Object -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding Object
v
instance FromJSON CustomData where
parseJSON :: Value -> Parser CustomData
parseJSON = String
-> (Object -> Parser CustomData) -> Value -> Parser CustomData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
J.withObject String
"CustomData" (CustomData -> Parser CustomData
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CustomData -> Parser CustomData)
-> (Object -> CustomData) -> Object -> Parser CustomData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Object -> CustomData
CustomData)
instance ToField CustomData where toField :: CustomData -> SQLData
toField (CustomData Object
v) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData)
-> (ByteString -> Binary ByteString) -> ByteString -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Binary ByteString
forall a. a -> Binary a
Binary (ByteString -> Binary ByteString)
-> (ByteString -> ByteString) -> ByteString -> Binary ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
LB.toStrict (ByteString -> SQLData) -> ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ Object -> ByteString
forall a. ToJSON a => a -> ByteString
J.encode Object
v
instance FromField CustomData where fromField :: FieldParser CustomData
fromField = (ByteString -> Either String CustomData) -> FieldParser CustomData
forall k.
Typeable k =>
(ByteString -> Either String k) -> FieldParser k
blobFieldDecoder ByteString -> Either String CustomData
forall a. FromJSON a => ByteString -> Either String a
J.eitherDecodeStrict
contactConn :: Contact -> Maybe Connection
contactConn :: Contact -> Maybe Connection
contactConn Contact {Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = Maybe Connection
activeConn
contactConnId :: Contact -> Maybe ConnId
contactConnId :: Contact -> Maybe ByteString
contactConnId Contact
c = Connection -> ByteString
aConnId (Connection -> ByteString) -> Maybe Connection -> Maybe ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Contact -> Maybe Connection
contactConn Contact
c
type IncognitoEnabled = Bool
contactConnIncognito :: Contact -> IncognitoEnabled
contactConnIncognito :: Contact -> Bool
contactConnIncognito = Bool -> (Connection -> Bool) -> Maybe Connection -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Connection -> Bool
connIncognito (Maybe Connection -> Bool)
-> (Contact -> Maybe Connection) -> Contact -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Contact -> Maybe Connection
contactConn
contactDirect :: Contact -> Bool
contactDirect :: Contact -> Bool
contactDirect Contact {Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = Bool -> (Connection -> Bool) -> Maybe Connection -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
True Connection -> Bool
connDirect Maybe Connection
activeConn
connDirect :: Connection -> Bool
connDirect :: Connection -> Bool
connDirect Connection {Int
connLevel :: Int
connLevel :: Connection -> Int
connLevel, Bool
viaGroupLink :: Bool
viaGroupLink :: Connection -> Bool
viaGroupLink} = Int
connLevel Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
viaGroupLink
directOrUsed :: Contact -> Bool
directOrUsed :: Contact -> Bool
directOrUsed ct :: Contact
ct@Contact {Bool
contactUsed :: Contact -> Bool
contactUsed :: Bool
contactUsed} =
Contact -> Bool
contactDirect Contact
ct Bool -> Bool -> Bool
|| Bool
contactUsed
anyDirectOrUsed :: Contact -> Bool
anyDirectOrUsed :: Contact -> Bool
anyDirectOrUsed Contact {Bool
contactUsed :: Contact -> Bool
contactUsed :: Bool
contactUsed, Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = ((\Connection {Int
connLevel :: Connection -> Int
connLevel :: Int
connLevel} -> Int
connLevel) (Connection -> Int) -> Maybe Connection -> Maybe Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Connection
activeConn) Maybe Int -> Maybe Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int -> Maybe Int
forall a. a -> Maybe a
Just Int
0 Bool -> Bool -> Bool
|| Bool
contactUsed
contactReady :: Contact -> Bool
contactReady :: Contact -> Bool
contactReady Contact {Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = Bool -> (Connection -> Bool) -> Maybe Connection -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Connection -> Bool
connReady Maybe Connection
activeConn
contactActive :: Contact -> Bool
contactActive :: Contact -> Bool
contactActive Contact {ContactStatus
contactStatus :: Contact -> ContactStatus
contactStatus :: ContactStatus
contactStatus} = ContactStatus
contactStatus ContactStatus -> ContactStatus -> Bool
forall a. Eq a => a -> a -> Bool
== ContactStatus
CSActive
contactDeleted :: Contact -> Bool
contactDeleted :: Contact -> Bool
contactDeleted Contact {ContactStatus
contactStatus :: Contact -> ContactStatus
contactStatus :: ContactStatus
contactStatus} = ContactStatus
contactStatus ContactStatus -> ContactStatus -> Bool
forall a. Eq a => a -> a -> Bool
== ContactStatus
CSDeleted Bool -> Bool -> Bool
|| ContactStatus
contactStatus ContactStatus -> ContactStatus -> Bool
forall a. Eq a => a -> a -> Bool
== ContactStatus
CSDeletedByUser
contactSecurityCode :: Contact -> Maybe SecurityCode
contactSecurityCode :: Contact -> Maybe SecurityCode
contactSecurityCode Contact {Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = Connection -> Maybe SecurityCode
connectionCode (Connection -> Maybe SecurityCode)
-> Maybe Connection -> Maybe SecurityCode
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Maybe Connection
activeConn
contactPQEnabled :: Contact -> PQEncryption
contactPQEnabled :: Contact -> PQEncryption
contactPQEnabled Contact {Maybe Connection
activeConn :: Contact -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = PQEncryption
-> (Connection -> PQEncryption) -> Maybe Connection -> PQEncryption
forall b a. b -> (a -> b) -> Maybe a -> b
maybe PQEncryption
PQEncOff Connection -> PQEncryption
connPQEnabled Maybe Connection
activeConn
data ContactStatus
= CSActive
| CSDeleted
| CSDeletedByUser
deriving (ContactStatus -> ContactStatus -> Bool
(ContactStatus -> ContactStatus -> Bool)
-> (ContactStatus -> ContactStatus -> Bool) -> Eq ContactStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContactStatus -> ContactStatus -> Bool
== :: ContactStatus -> ContactStatus -> Bool
$c/= :: ContactStatus -> ContactStatus -> Bool
/= :: ContactStatus -> ContactStatus -> Bool
Eq, Int -> ContactStatus -> ShowS
[ContactStatus] -> ShowS
ContactStatus -> String
(Int -> ContactStatus -> ShowS)
-> (ContactStatus -> String)
-> ([ContactStatus] -> ShowS)
-> Show ContactStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContactStatus -> ShowS
showsPrec :: Int -> ContactStatus -> ShowS
$cshow :: ContactStatus -> String
show :: ContactStatus -> String
$cshowList :: [ContactStatus] -> ShowS
showList :: [ContactStatus] -> ShowS
Show, Eq ContactStatus
Eq ContactStatus =>
(ContactStatus -> ContactStatus -> Ordering)
-> (ContactStatus -> ContactStatus -> Bool)
-> (ContactStatus -> ContactStatus -> Bool)
-> (ContactStatus -> ContactStatus -> Bool)
-> (ContactStatus -> ContactStatus -> Bool)
-> (ContactStatus -> ContactStatus -> ContactStatus)
-> (ContactStatus -> ContactStatus -> ContactStatus)
-> Ord ContactStatus
ContactStatus -> ContactStatus -> Bool
ContactStatus -> ContactStatus -> Ordering
ContactStatus -> ContactStatus -> ContactStatus
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ContactStatus -> ContactStatus -> Ordering
compare :: ContactStatus -> ContactStatus -> Ordering
$c< :: ContactStatus -> ContactStatus -> Bool
< :: ContactStatus -> ContactStatus -> Bool
$c<= :: ContactStatus -> ContactStatus -> Bool
<= :: ContactStatus -> ContactStatus -> Bool
$c> :: ContactStatus -> ContactStatus -> Bool
> :: ContactStatus -> ContactStatus -> Bool
$c>= :: ContactStatus -> ContactStatus -> Bool
>= :: ContactStatus -> ContactStatus -> Bool
$cmax :: ContactStatus -> ContactStatus -> ContactStatus
max :: ContactStatus -> ContactStatus -> ContactStatus
$cmin :: ContactStatus -> ContactStatus -> ContactStatus
min :: ContactStatus -> ContactStatus -> ContactStatus
Ord)
instance FromField ContactStatus where fromField :: FieldParser ContactStatus
fromField = (Text -> Maybe ContactStatus) -> FieldParser ContactStatus
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe ContactStatus
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField ContactStatus where toField :: ContactStatus -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (ContactStatus -> Text) -> ContactStatus -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromJSON ContactStatus where
parseJSON :: Value -> Parser ContactStatus
parseJSON = String -> Value -> Parser ContactStatus
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"ContactStatus"
instance ToJSON ContactStatus where
toJSON :: ContactStatus -> Value
toJSON = Text -> Value
J.String (Text -> Value)
-> (ContactStatus -> Text) -> ContactStatus -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: ContactStatus -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding)
-> (ContactStatus -> Text) -> ContactStatus -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContactStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding ContactStatus where
textDecode :: Text -> Maybe ContactStatus
textDecode = \case
Text
"active" -> ContactStatus -> Maybe ContactStatus
forall a. a -> Maybe a
Just ContactStatus
CSActive
Text
"deleted" -> ContactStatus -> Maybe ContactStatus
forall a. a -> Maybe a
Just ContactStatus
CSDeleted
Text
"deletedByUser" -> ContactStatus -> Maybe ContactStatus
forall a. a -> Maybe a
Just ContactStatus
CSDeletedByUser
Text
_ -> Maybe ContactStatus
forall a. Maybe a
Nothing
textEncode :: ContactStatus -> Text
textEncode = \case
ContactStatus
CSActive -> Text
"active"
ContactStatus
CSDeleted -> Text
"deleted"
ContactStatus
CSDeletedByUser -> Text
"deletedByUser"
data ContactRef = ContactRef
{ ContactRef -> CommandId
contactId :: ContactId,
ContactRef -> CommandId
connId :: Int64,
ContactRef -> AgentConnId
agentConnId :: AgentConnId,
ContactRef -> Text
localDisplayName :: ContactName
}
deriving (ContactRef -> ContactRef -> Bool
(ContactRef -> ContactRef -> Bool)
-> (ContactRef -> ContactRef -> Bool) -> Eq ContactRef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContactRef -> ContactRef -> Bool
== :: ContactRef -> ContactRef -> Bool
$c/= :: ContactRef -> ContactRef -> Bool
/= :: ContactRef -> ContactRef -> Bool
Eq, Int -> ContactRef -> ShowS
[ContactRef] -> ShowS
ContactRef -> String
(Int -> ContactRef -> ShowS)
-> (ContactRef -> String)
-> ([ContactRef] -> ShowS)
-> Show ContactRef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContactRef -> ShowS
showsPrec :: Int -> ContactRef -> ShowS
$cshow :: ContactRef -> String
show :: ContactRef -> String
$cshowList :: [ContactRef] -> ShowS
showList :: [ContactRef] -> ShowS
Show)
data ContactOrMember = COMContact Contact | COMGroupMember GroupMember
deriving (Int -> ContactOrMember -> ShowS
[ContactOrMember] -> ShowS
ContactOrMember -> String
(Int -> ContactOrMember -> ShowS)
-> (ContactOrMember -> String)
-> ([ContactOrMember] -> ShowS)
-> Show ContactOrMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContactOrMember -> ShowS
showsPrec :: Int -> ContactOrMember -> ShowS
$cshow :: ContactOrMember -> String
show :: ContactOrMember -> String
$cshowList :: [ContactOrMember] -> ShowS
showList :: [ContactOrMember] -> ShowS
Show)
contactOrMemberIds :: ContactOrMember -> (Maybe ContactId, Maybe GroupMemberId)
contactOrMemberIds :: ContactOrMember -> (Maybe CommandId, Maybe CommandId)
contactOrMemberIds = \case
COMContact Contact {CommandId
contactId :: Contact -> CommandId
contactId :: CommandId
contactId} -> (CommandId -> Maybe CommandId
forall a. a -> Maybe a
Just CommandId
contactId, Maybe CommandId
forall a. Maybe a
Nothing)
COMGroupMember GroupMember {CommandId
groupMemberId :: CommandId
groupMemberId :: GroupMember -> CommandId
groupMemberId} -> (Maybe CommandId
forall a. Maybe a
Nothing, CommandId -> Maybe CommandId
forall a. a -> Maybe a
Just CommandId
groupMemberId)
contactOrMemberIncognito :: ContactOrMember -> IncognitoEnabled
contactOrMemberIncognito :: ContactOrMember -> Bool
contactOrMemberIncognito = \case
COMContact Contact
ct -> Contact -> Bool
contactConnIncognito Contact
ct
COMGroupMember GroupMember
m -> GroupMember -> Bool
memberIncognito GroupMember
m
data UserContact = UserContact
{ UserContact -> CommandId
userContactLinkId :: Int64,
UserContact -> ConnReqContact
connReqContact :: ConnReqContact,
UserContact -> Maybe CommandId
groupId :: Maybe GroupId
}
deriving (UserContact -> UserContact -> Bool
(UserContact -> UserContact -> Bool)
-> (UserContact -> UserContact -> Bool) -> Eq UserContact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserContact -> UserContact -> Bool
== :: UserContact -> UserContact -> Bool
$c/= :: UserContact -> UserContact -> Bool
/= :: UserContact -> UserContact -> Bool
Eq, Int -> UserContact -> ShowS
[UserContact] -> ShowS
UserContact -> String
(Int -> UserContact -> ShowS)
-> (UserContact -> String)
-> ([UserContact] -> ShowS)
-> Show UserContact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserContact -> ShowS
showsPrec :: Int -> UserContact -> ShowS
$cshow :: UserContact -> String
show :: UserContact -> String
$cshowList :: [UserContact] -> ShowS
showList :: [UserContact] -> ShowS
Show)
data UserContactRequest = UserContactRequest
{ UserContactRequest -> CommandId
contactRequestId :: Int64,
UserContactRequest -> AgentInvId
agentInvitationId :: AgentInvId,
UserContactRequest -> Maybe CommandId
contactId_ :: Maybe ContactId,
UserContactRequest -> Maybe CommandId
businessGroupId_ :: Maybe GroupId,
UserContactRequest -> Maybe CommandId
userContactLinkId_ :: Maybe Int64,
UserContactRequest -> VersionRangeChat
cReqChatVRange :: VersionRangeChat,
UserContactRequest -> Text
localDisplayName :: ContactName,
UserContactRequest -> CommandId
profileId :: Int64,
UserContactRequest -> Profile
profile :: Profile,
UserContactRequest -> UTCTime
createdAt :: UTCTime,
UserContactRequest -> UTCTime
updatedAt :: UTCTime,
UserContactRequest -> Maybe XContactId
xContactId :: Maybe XContactId,
UserContactRequest -> PQSupport
pqSupport :: PQSupport,
UserContactRequest -> Maybe SharedMsgId
welcomeSharedMsgId :: Maybe SharedMsgId,
UserContactRequest -> Maybe SharedMsgId
requestSharedMsgId :: Maybe SharedMsgId
}
deriving (UserContactRequest -> UserContactRequest -> Bool
(UserContactRequest -> UserContactRequest -> Bool)
-> (UserContactRequest -> UserContactRequest -> Bool)
-> Eq UserContactRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserContactRequest -> UserContactRequest -> Bool
== :: UserContactRequest -> UserContactRequest -> Bool
$c/= :: UserContactRequest -> UserContactRequest -> Bool
/= :: UserContactRequest -> UserContactRequest -> Bool
Eq, Int -> UserContactRequest -> ShowS
[UserContactRequest] -> ShowS
UserContactRequest -> String
(Int -> UserContactRequest -> ShowS)
-> (UserContactRequest -> String)
-> ([UserContactRequest] -> ShowS)
-> Show UserContactRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserContactRequest -> ShowS
showsPrec :: Int -> UserContactRequest -> ShowS
$cshow :: UserContactRequest -> String
show :: UserContactRequest -> String
$cshowList :: [UserContactRequest] -> ShowS
showList :: [UserContactRequest] -> ShowS
Show)
newtype XContactId = XContactId ByteString
deriving (XContactId -> XContactId -> Bool
(XContactId -> XContactId -> Bool)
-> (XContactId -> XContactId -> Bool) -> Eq XContactId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XContactId -> XContactId -> Bool
== :: XContactId -> XContactId -> Bool
$c/= :: XContactId -> XContactId -> Bool
/= :: XContactId -> XContactId -> Bool
Eq, Int -> XContactId -> ShowS
[XContactId] -> ShowS
XContactId -> String
(Int -> XContactId -> ShowS)
-> (XContactId -> String)
-> ([XContactId] -> ShowS)
-> Show XContactId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XContactId -> ShowS
showsPrec :: Int -> XContactId -> ShowS
$cshow :: XContactId -> String
show :: XContactId -> String
$cshowList :: [XContactId] -> ShowS
showList :: [XContactId] -> ShowS
Show)
deriving newtype (FieldParser XContactId
FieldParser XContactId -> FromField XContactId
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser XContactId
fromField :: FieldParser XContactId
FromField)
instance ToField XContactId where toField :: XContactId -> SQLData
toField (XContactId ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding XContactId where
strEncode :: XContactId -> ByteString
strEncode (XContactId ByteString
m) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
m
strDecode :: ByteString -> Either String XContactId
strDecode ByteString
s = ByteString -> XContactId
XContactId (ByteString -> XContactId)
-> Either String ByteString -> Either String XContactId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser XContactId
strP = ByteString -> XContactId
XContactId (ByteString -> XContactId)
-> Parser ByteString ByteString -> Parser XContactId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON XContactId where
parseJSON :: Value -> Parser XContactId
parseJSON = String -> Value -> Parser XContactId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"XContactId"
instance ToJSON XContactId where
toJSON :: XContactId -> Value
toJSON = XContactId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: XContactId -> Encoding
toEncoding = XContactId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
newtype ConnReqUriHash = ConnReqUriHash {ConnReqUriHash -> ByteString
unConnReqUriHash :: ByteString}
deriving (ConnReqUriHash -> ConnReqUriHash -> Bool
(ConnReqUriHash -> ConnReqUriHash -> Bool)
-> (ConnReqUriHash -> ConnReqUriHash -> Bool) -> Eq ConnReqUriHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnReqUriHash -> ConnReqUriHash -> Bool
== :: ConnReqUriHash -> ConnReqUriHash -> Bool
$c/= :: ConnReqUriHash -> ConnReqUriHash -> Bool
/= :: ConnReqUriHash -> ConnReqUriHash -> Bool
Eq, Int -> ConnReqUriHash -> ShowS
[ConnReqUriHash] -> ShowS
ConnReqUriHash -> String
(Int -> ConnReqUriHash -> ShowS)
-> (ConnReqUriHash -> String)
-> ([ConnReqUriHash] -> ShowS)
-> Show ConnReqUriHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnReqUriHash -> ShowS
showsPrec :: Int -> ConnReqUriHash -> ShowS
$cshow :: ConnReqUriHash -> String
show :: ConnReqUriHash -> String
$cshowList :: [ConnReqUriHash] -> ShowS
showList :: [ConnReqUriHash] -> ShowS
Show)
deriving newtype (FieldParser ConnReqUriHash
FieldParser ConnReqUriHash -> FromField ConnReqUriHash
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser ConnReqUriHash
fromField :: FieldParser ConnReqUriHash
FromField)
instance ToField ConnReqUriHash where toField :: ConnReqUriHash -> SQLData
toField (ConnReqUriHash ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding ConnReqUriHash where
strEncode :: ConnReqUriHash -> ByteString
strEncode (ConnReqUriHash ByteString
m) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
m
strDecode :: ByteString -> Either String ConnReqUriHash
strDecode ByteString
s = ByteString -> ConnReqUriHash
ConnReqUriHash (ByteString -> ConnReqUriHash)
-> Either String ByteString -> Either String ConnReqUriHash
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser ConnReqUriHash
strP = ByteString -> ConnReqUriHash
ConnReqUriHash (ByteString -> ConnReqUriHash)
-> Parser ByteString ByteString -> Parser ConnReqUriHash
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON ConnReqUriHash where
parseJSON :: Value -> Parser ConnReqUriHash
parseJSON = String -> Value -> Parser ConnReqUriHash
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"ConnReqUriHash"
instance ToJSON ConnReqUriHash where
toJSON :: ConnReqUriHash -> Value
toJSON = ConnReqUriHash -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: ConnReqUriHash -> Encoding
toEncoding = ConnReqUriHash -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
data RequestEntity
= REContact Contact
| REBusinessChat GroupInfo GroupMember
type RepeatRequest = Bool
data RequestStage
= RSAcceptedRequest
{ RequestStage -> Maybe UserContactRequest
acceptedRequest :: Maybe UserContactRequest,
RequestStage -> RequestEntity
requestEntity :: RequestEntity
}
| RSCurrentRequest
{ RequestStage -> Maybe UserContactRequest
previousRequest :: Maybe UserContactRequest,
RequestStage -> UserContactRequest
currentRequest :: UserContactRequest,
RequestStage -> Maybe RequestEntity
requestEntity_ :: Maybe RequestEntity
}
type UserName = Text
type ContactName = Text
type MemberName = Text
type GroupName = Text
optionalFullName :: ContactName -> Text -> Maybe Text -> Text
optionalFullName :: Text -> Text -> Maybe Text -> Text
optionalFullName Text
displayName Text
fullName Maybe Text
shortDescr
| Text -> Bool
T.null Text
fullName Bool -> Bool -> Bool
|| Text
displayName Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
fullName = Text -> (Text -> Text) -> Maybe Text -> Text
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
"" (\Text
sd -> Text
" (" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
sd Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
")") Maybe Text
shortDescr
| Bool
otherwise = Text
" (" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fullName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
")"
data Group = Group {Group -> GroupInfo
groupInfo :: GroupInfo, Group -> [GroupMember]
members :: [GroupMember]}
deriving (Group -> Group -> Bool
(Group -> Group -> Bool) -> (Group -> Group -> Bool) -> Eq Group
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Group -> Group -> Bool
== :: Group -> Group -> Bool
$c/= :: Group -> Group -> Bool
/= :: Group -> Group -> Bool
Eq, Int -> Group -> ShowS
[Group] -> ShowS
Group -> String
(Int -> Group -> ShowS)
-> (Group -> String) -> ([Group] -> ShowS) -> Show Group
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Group -> ShowS
showsPrec :: Int -> Group -> ShowS
$cshow :: Group -> String
show :: Group -> String
$cshowList :: [Group] -> ShowS
showList :: [Group] -> ShowS
Show)
type GroupId = Int64
data GroupInfo = GroupInfo
{ GroupInfo -> CommandId
groupId :: GroupId,
GroupInfo -> BoolDef
useRelays :: BoolDef,
GroupInfo -> Text
localDisplayName :: GroupName,
GroupInfo -> GroupProfile
groupProfile :: GroupProfile,
GroupInfo -> Text
localAlias :: Text,
GroupInfo -> Maybe BusinessChatInfo
businessChat :: Maybe BusinessChatInfo,
GroupInfo -> FullGroupPreferences
fullGroupPreferences :: FullGroupPreferences,
GroupInfo -> GroupMember
membership :: GroupMember,
GroupInfo -> ChatSettings
chatSettings :: ChatSettings,
GroupInfo -> UTCTime
createdAt :: UTCTime,
GroupInfo -> UTCTime
updatedAt :: UTCTime,
GroupInfo -> Maybe UTCTime
chatTs :: Maybe UTCTime,
GroupInfo -> Maybe UTCTime
userMemberProfileSentAt :: Maybe UTCTime,
GroupInfo -> Maybe PreparedGroup
preparedGroup :: Maybe PreparedGroup,
GroupInfo -> [CommandId]
chatTags :: [ChatTagId],
GroupInfo -> Maybe CommandId
chatItemTTL :: Maybe Int64,
GroupInfo -> Maybe UIThemeEntityOverrides
uiThemes :: Maybe UIThemeEntityOverrides,
GroupInfo -> Maybe CustomData
customData :: Maybe CustomData,
GroupInfo -> GroupSummary
groupSummary :: GroupSummary,
GroupInfo -> Int
membersRequireAttention :: Int,
GroupInfo -> Maybe ConnReqContact
viaGroupLinkUri :: Maybe ConnReqContact
}
deriving (GroupInfo -> GroupInfo -> Bool
(GroupInfo -> GroupInfo -> Bool)
-> (GroupInfo -> GroupInfo -> Bool) -> Eq GroupInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupInfo -> GroupInfo -> Bool
== :: GroupInfo -> GroupInfo -> Bool
$c/= :: GroupInfo -> GroupInfo -> Bool
/= :: GroupInfo -> GroupInfo -> Bool
Eq, Int -> GroupInfo -> ShowS
[GroupInfo] -> ShowS
GroupInfo -> String
(Int -> GroupInfo -> ShowS)
-> (GroupInfo -> String)
-> ([GroupInfo] -> ShowS)
-> Show GroupInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupInfo -> ShowS
showsPrec :: Int -> GroupInfo -> ShowS
$cshow :: GroupInfo -> String
show :: GroupInfo -> String
$cshowList :: [GroupInfo] -> ShowS
showList :: [GroupInfo] -> ShowS
Show)
data BusinessChatType
= BCBusiness
| BCCustomer
deriving (BusinessChatType -> BusinessChatType -> Bool
(BusinessChatType -> BusinessChatType -> Bool)
-> (BusinessChatType -> BusinessChatType -> Bool)
-> Eq BusinessChatType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BusinessChatType -> BusinessChatType -> Bool
== :: BusinessChatType -> BusinessChatType -> Bool
$c/= :: BusinessChatType -> BusinessChatType -> Bool
/= :: BusinessChatType -> BusinessChatType -> Bool
Eq, Int -> BusinessChatType -> ShowS
[BusinessChatType] -> ShowS
BusinessChatType -> String
(Int -> BusinessChatType -> ShowS)
-> (BusinessChatType -> String)
-> ([BusinessChatType] -> ShowS)
-> Show BusinessChatType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessChatType -> ShowS
showsPrec :: Int -> BusinessChatType -> ShowS
$cshow :: BusinessChatType -> String
show :: BusinessChatType -> String
$cshowList :: [BusinessChatType] -> ShowS
showList :: [BusinessChatType] -> ShowS
Show)
instance TextEncoding BusinessChatType where
textEncode :: BusinessChatType -> Text
textEncode = \case
BusinessChatType
BCBusiness -> Text
"business"
BusinessChatType
BCCustomer -> Text
"customer"
textDecode :: Text -> Maybe BusinessChatType
textDecode = \case
Text
"business" -> BusinessChatType -> Maybe BusinessChatType
forall a. a -> Maybe a
Just BusinessChatType
BCBusiness
Text
"customer" -> BusinessChatType -> Maybe BusinessChatType
forall a. a -> Maybe a
Just BusinessChatType
BCCustomer
Text
_ -> Maybe BusinessChatType
forall a. Maybe a
Nothing
instance FromField BusinessChatType where fromField :: FieldParser BusinessChatType
fromField = (Text -> Maybe BusinessChatType) -> FieldParser BusinessChatType
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe BusinessChatType
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField BusinessChatType where toField :: BusinessChatType -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (BusinessChatType -> Text) -> BusinessChatType -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BusinessChatType -> Text
forall a. TextEncoding a => a -> Text
textEncode
data PreparedGroup = PreparedGroup
{ PreparedGroup -> CreatedLinkContact
connLinkToConnect :: CreatedLinkContact,
PreparedGroup -> Bool
connLinkPreparedConnection :: Bool,
PreparedGroup -> Bool
connLinkStartedConnection :: Bool,
PreparedGroup -> Maybe SharedMsgId
welcomeSharedMsgId :: Maybe SharedMsgId,
PreparedGroup -> Maybe SharedMsgId
requestSharedMsgId :: Maybe SharedMsgId
}
deriving (PreparedGroup -> PreparedGroup -> Bool
(PreparedGroup -> PreparedGroup -> Bool)
-> (PreparedGroup -> PreparedGroup -> Bool) -> Eq PreparedGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PreparedGroup -> PreparedGroup -> Bool
== :: PreparedGroup -> PreparedGroup -> Bool
$c/= :: PreparedGroup -> PreparedGroup -> Bool
/= :: PreparedGroup -> PreparedGroup -> Bool
Eq, Int -> PreparedGroup -> ShowS
[PreparedGroup] -> ShowS
PreparedGroup -> String
(Int -> PreparedGroup -> ShowS)
-> (PreparedGroup -> String)
-> ([PreparedGroup] -> ShowS)
-> Show PreparedGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PreparedGroup -> ShowS
showsPrec :: Int -> PreparedGroup -> ShowS
$cshow :: PreparedGroup -> String
show :: PreparedGroup -> String
$cshowList :: [PreparedGroup] -> ShowS
showList :: [PreparedGroup] -> ShowS
Show)
groupName' :: GroupInfo -> GroupName
groupName' :: GroupInfo -> Text
groupName' GroupInfo {localDisplayName :: GroupInfo -> Text
localDisplayName = Text
g} = Text
g
data GroupSummary = GroupSummary
{ GroupSummary -> CommandId
currentMembers :: Int64
}
deriving (GroupSummary -> GroupSummary -> Bool
(GroupSummary -> GroupSummary -> Bool)
-> (GroupSummary -> GroupSummary -> Bool) -> Eq GroupSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupSummary -> GroupSummary -> Bool
== :: GroupSummary -> GroupSummary -> Bool
$c/= :: GroupSummary -> GroupSummary -> Bool
/= :: GroupSummary -> GroupSummary -> Bool
Eq, Int -> GroupSummary -> ShowS
[GroupSummary] -> ShowS
GroupSummary -> String
(Int -> GroupSummary -> ShowS)
-> (GroupSummary -> String)
-> ([GroupSummary] -> ShowS)
-> Show GroupSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupSummary -> ShowS
showsPrec :: Int -> GroupSummary -> ShowS
$cshow :: GroupSummary -> String
show :: GroupSummary -> String
$cshowList :: [GroupSummary] -> ShowS
showList :: [GroupSummary] -> ShowS
Show)
data GroupLink = GroupLink
{ GroupLink -> CommandId
userContactLinkId :: Int64,
GroupLink -> CreatedLinkContact
connLinkContact :: CreatedLinkContact,
GroupLink -> Bool
shortLinkDataSet :: Bool,
GroupLink -> BoolDef
shortLinkLargeDataSet :: BoolDef,
GroupLink -> GroupLinkId
groupLinkId :: GroupLinkId,
GroupLink -> GroupMemberRole
acceptMemberRole :: GroupMemberRole
}
deriving (Int -> GroupLink -> ShowS
[GroupLink] -> ShowS
GroupLink -> String
(Int -> GroupLink -> ShowS)
-> (GroupLink -> String)
-> ([GroupLink] -> ShowS)
-> Show GroupLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupLink -> ShowS
showsPrec :: Int -> GroupLink -> ShowS
$cshow :: GroupLink -> String
show :: GroupLink -> String
$cshowList :: [GroupLink] -> ShowS
showList :: [GroupLink] -> ShowS
Show)
data ContactOrGroup = CGContact Contact | CGGroup GroupInfo [GroupMember]
data PreparedChatEntity = PCEContact Contact | PCEGroup {PreparedChatEntity -> GroupInfo
groupInfo :: GroupInfo, PreparedChatEntity -> GroupMember
hostMember :: GroupMember}
contactAndGroupIds :: ContactOrGroup -> (Maybe ContactId, Maybe GroupId)
contactAndGroupIds :: ContactOrGroup -> (Maybe CommandId, Maybe CommandId)
contactAndGroupIds = \case
CGContact Contact {CommandId
contactId :: Contact -> CommandId
contactId :: CommandId
contactId} -> (CommandId -> Maybe CommandId
forall a. a -> Maybe a
Just CommandId
contactId, Maybe CommandId
forall a. Maybe a
Nothing)
CGGroup GroupInfo {CommandId
groupId :: GroupInfo -> CommandId
groupId :: CommandId
groupId} [GroupMember]
_ -> (Maybe CommandId
forall a. Maybe a
Nothing, CommandId -> Maybe CommandId
forall a. a -> Maybe a
Just CommandId
groupId)
data ChatSettings = ChatSettings
{ ChatSettings -> MsgFilter
enableNtfs :: MsgFilter,
ChatSettings -> Maybe Bool
sendRcpts :: Maybe Bool,
ChatSettings -> Bool
favorite :: Bool
}
deriving (ChatSettings -> ChatSettings -> Bool
(ChatSettings -> ChatSettings -> Bool)
-> (ChatSettings -> ChatSettings -> Bool) -> Eq ChatSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatSettings -> ChatSettings -> Bool
== :: ChatSettings -> ChatSettings -> Bool
$c/= :: ChatSettings -> ChatSettings -> Bool
/= :: ChatSettings -> ChatSettings -> Bool
Eq, Int -> ChatSettings -> ShowS
[ChatSettings] -> ShowS
ChatSettings -> String
(Int -> ChatSettings -> ShowS)
-> (ChatSettings -> String)
-> ([ChatSettings] -> ShowS)
-> Show ChatSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatSettings -> ShowS
showsPrec :: Int -> ChatSettings -> ShowS
$cshow :: ChatSettings -> String
show :: ChatSettings -> String
$cshowList :: [ChatSettings] -> ShowS
showList :: [ChatSettings] -> ShowS
Show)
defaultChatSettings :: ChatSettings
defaultChatSettings :: ChatSettings
defaultChatSettings =
ChatSettings
{ enableNtfs :: MsgFilter
enableNtfs = MsgFilter
MFAll,
sendRcpts :: Maybe Bool
sendRcpts = Maybe Bool
forall a. Maybe a
Nothing,
favorite :: Bool
favorite = Bool
False
}
chatHasNtfs :: ChatSettings -> Bool
chatHasNtfs :: ChatSettings -> Bool
chatHasNtfs ChatSettings {MsgFilter
enableNtfs :: ChatSettings -> MsgFilter
enableNtfs :: MsgFilter
enableNtfs} = MsgFilter
enableNtfs MsgFilter -> MsgFilter -> Bool
forall a. Eq a => a -> a -> Bool
/= MsgFilter
MFNone
data MsgFilter = MFNone | MFAll | MFMentions
deriving (MsgFilter -> MsgFilter -> Bool
(MsgFilter -> MsgFilter -> Bool)
-> (MsgFilter -> MsgFilter -> Bool) -> Eq MsgFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MsgFilter -> MsgFilter -> Bool
== :: MsgFilter -> MsgFilter -> Bool
$c/= :: MsgFilter -> MsgFilter -> Bool
/= :: MsgFilter -> MsgFilter -> Bool
Eq, Int -> MsgFilter -> ShowS
[MsgFilter] -> ShowS
MsgFilter -> String
(Int -> MsgFilter -> ShowS)
-> (MsgFilter -> String)
-> ([MsgFilter] -> ShowS)
-> Show MsgFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MsgFilter -> ShowS
showsPrec :: Int -> MsgFilter -> ShowS
$cshow :: MsgFilter -> String
show :: MsgFilter -> String
$cshowList :: [MsgFilter] -> ShowS
showList :: [MsgFilter] -> ShowS
Show)
msgFilterInt :: MsgFilter -> Int
msgFilterInt :: MsgFilter -> Int
msgFilterInt = \case
MsgFilter
MFNone -> Int
0
MsgFilter
MFAll -> Int
1
MsgFilter
MFMentions -> Int
2
msgFilterIntP :: Int64 -> Maybe MsgFilter
msgFilterIntP :: CommandId -> Maybe MsgFilter
msgFilterIntP = \case
CommandId
0 -> MsgFilter -> Maybe MsgFilter
forall a. a -> Maybe a
Just MsgFilter
MFNone
CommandId
1 -> MsgFilter -> Maybe MsgFilter
forall a. a -> Maybe a
Just MsgFilter
MFAll
CommandId
2 -> MsgFilter -> Maybe MsgFilter
forall a. a -> Maybe a
Just MsgFilter
MFMentions
CommandId
_ -> MsgFilter -> Maybe MsgFilter
forall a. a -> Maybe a
Just MsgFilter
MFAll
fromIntField_ :: Typeable a => (Int64 -> Maybe a) -> FieldParser a
#if defined(dbPostgres)
fromIntField_ fromInt f val = fromField f val >>= parseInt
#else
fromIntField_ :: forall a. Typeable a => (CommandId -> Maybe a) -> FieldParser a
fromIntField_ CommandId -> Maybe a
fromInt Field
f = FieldParser CommandId
forall a. FromField a => FieldParser a
fromField Field
f Ok CommandId -> (CommandId -> Ok a) -> Ok a
forall a b. Ok a -> (a -> Ok b) -> Ok b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CommandId -> Ok a
parseInt
#endif
where
parseInt :: CommandId -> Ok a
parseInt CommandId
i = case CommandId -> Maybe a
fromInt CommandId
i of
Just a
x -> a -> Ok a
forall a. a -> Ok a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x
Maybe a
_ -> (String -> String -> String -> ResultError)
-> Field -> String -> Ok a
forall a err.
(Typeable a, Exception err) =>
(String -> String -> String -> err) -> Field -> String -> Ok a
returnError String -> String -> String -> ResultError
ConversionFailed Field
f (String -> Ok a) -> String -> Ok a
forall a b. (a -> b) -> a -> b
$ String
"invalid integer: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> CommandId -> String
forall a. Show a => a -> String
show CommandId
i
featureAllowed :: SChatFeature f -> (PrefEnabled -> Bool) -> Contact -> Bool
featureAllowed :: forall (f :: ChatFeature).
SChatFeature f -> (PrefEnabled -> Bool) -> Contact -> Bool
featureAllowed SChatFeature f
feature PrefEnabled -> Bool
forWhom Contact {ContactUserPreferences
mergedPreferences :: Contact -> ContactUserPreferences
mergedPreferences :: ContactUserPreferences
mergedPreferences} =
let ContactUserPreference {PrefEnabled
enabled :: PrefEnabled
enabled :: forall p. ContactUserPreference p -> PrefEnabled
enabled} = SChatFeature f
-> ContactUserPreferences
-> ContactUserPreference (FeaturePreference f)
forall (f :: ChatFeature).
SChatFeature f
-> ContactUserPreferences
-> ContactUserPreference (FeaturePreference f)
getContactUserPreference SChatFeature f
feature ContactUserPreferences
mergedPreferences
in PrefEnabled -> Bool
forWhom PrefEnabled
enabled
groupFeatureAllowed :: GroupFeatureNoRoleI f => SGroupFeature f -> GroupInfo -> Bool
groupFeatureAllowed :: forall (f :: GroupFeature).
GroupFeatureNoRoleI f =>
SGroupFeature f -> GroupInfo -> Bool
groupFeatureAllowed SGroupFeature f
feature GroupInfo
gInfo = SGroupFeature f -> FullGroupPreferences -> Bool
forall (f :: GroupFeature).
GroupFeatureNoRoleI f =>
SGroupFeature f -> FullGroupPreferences -> Bool
groupFeatureAllowed' SGroupFeature f
feature (FullGroupPreferences -> Bool) -> FullGroupPreferences -> Bool
forall a b. (a -> b) -> a -> b
$ GroupInfo -> FullGroupPreferences
fullGroupPreferences GroupInfo
gInfo
groupFeatureMemberAllowed :: GroupFeatureRoleI f => SGroupFeature f -> GroupMember -> GroupInfo -> Bool
groupFeatureMemberAllowed :: forall (f :: GroupFeature).
GroupFeatureRoleI f =>
SGroupFeature f -> GroupMember -> GroupInfo -> Bool
groupFeatureMemberAllowed SGroupFeature f
feature GroupMember {GroupMemberRole
memberRole :: GroupMemberRole
memberRole :: GroupMember -> GroupMemberRole
memberRole} =
SGroupFeature f -> GroupMemberRole -> FullGroupPreferences -> Bool
forall (f :: GroupFeature).
GroupFeatureRoleI f =>
SGroupFeature f -> GroupMemberRole -> FullGroupPreferences -> Bool
groupFeatureMemberAllowed' SGroupFeature f
feature GroupMemberRole
memberRole (FullGroupPreferences -> Bool)
-> (GroupInfo -> FullGroupPreferences) -> GroupInfo -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupInfo -> FullGroupPreferences
fullGroupPreferences
groupFeatureUserAllowed :: GroupFeatureRoleI f => SGroupFeature f -> GroupInfo -> Bool
groupFeatureUserAllowed :: forall (f :: GroupFeature).
GroupFeatureRoleI f =>
SGroupFeature f -> GroupInfo -> Bool
groupFeatureUserAllowed SGroupFeature f
feature GroupInfo {membership :: GroupInfo -> GroupMember
membership = GroupMember {GroupMemberRole
memberRole :: GroupMember -> GroupMemberRole
memberRole :: GroupMemberRole
memberRole}, FullGroupPreferences
fullGroupPreferences :: GroupInfo -> FullGroupPreferences
fullGroupPreferences :: FullGroupPreferences
fullGroupPreferences} =
SGroupFeature f -> GroupMemberRole -> FullGroupPreferences -> Bool
forall (f :: GroupFeature).
GroupFeatureRoleI f =>
SGroupFeature f -> GroupMemberRole -> FullGroupPreferences -> Bool
groupFeatureMemberAllowed' SGroupFeature f
feature GroupMemberRole
memberRole FullGroupPreferences
fullGroupPreferences
mergeUserChatPrefs :: User -> Contact -> FullPreferences
mergeUserChatPrefs :: User -> Contact -> FullPreferences
mergeUserChatPrefs User
user Contact
ct = User -> Bool -> Preferences -> FullPreferences
mergeUserChatPrefs' User
user (Contact -> Bool
contactConnIncognito Contact
ct) (Contact -> Preferences
userPreferences Contact
ct)
mergeUserChatPrefs' :: User -> Bool -> Preferences -> FullPreferences
mergeUserChatPrefs' :: User -> Bool -> Preferences -> FullPreferences
mergeUserChatPrefs' User
user Bool
connectedIncognito Preferences
userPreferences =
let userPrefs :: Maybe Preferences
userPrefs = if Bool
connectedIncognito then Maybe Preferences
forall a. Maybe a
Nothing else User -> Maybe Preferences
forall a. IsContact a => a -> Maybe Preferences
preferences' User
user
in Maybe Preferences -> Maybe Preferences -> Bool -> FullPreferences
mergePreferences (Preferences -> Maybe Preferences
forall a. a -> Maybe a
Just Preferences
userPreferences) Maybe Preferences
userPrefs Bool
False
updateMergedPreferences :: User -> Contact -> Contact
updateMergedPreferences :: User -> Contact -> Contact
updateMergedPreferences User
user Contact
ct =
let mergedPreferences :: ContactUserPreferences
mergedPreferences = User
-> Preferences
-> Maybe Preferences
-> Bool
-> ContactUserPreferences
contactUserPreferences User
user (Contact -> Preferences
userPreferences Contact
ct) (Contact -> Maybe Preferences
forall a. IsContact a => a -> Maybe Preferences
preferences' Contact
ct) (Contact -> Bool
contactConnIncognito Contact
ct)
in Contact
ct {mergedPreferences}
contactUserPreferences :: User -> Preferences -> Maybe Preferences -> Bool -> ContactUserPreferences
contactUserPreferences :: User
-> Preferences
-> Maybe Preferences
-> Bool
-> ContactUserPreferences
contactUserPreferences User
user Preferences
userPreferences Maybe Preferences
contactPreferences Bool
connectedIncognito =
ContactUserPreferences
{ timedMessages :: ContactUserPreference TimedMessagesPreference
timedMessages = SChatFeature 'CFTimedMessages
-> ContactUserPreference (FeaturePreference 'CFTimedMessages)
forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature 'CFTimedMessages
SCFTimedMessages,
fullDelete :: ContactUserPreference FullDeletePreference
fullDelete = SChatFeature 'CFFullDelete
-> ContactUserPreference (FeaturePreference 'CFFullDelete)
forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature 'CFFullDelete
SCFFullDelete,
reactions :: ContactUserPreference ReactionsPreference
reactions = SChatFeature 'CFReactions
-> ContactUserPreference (FeaturePreference 'CFReactions)
forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature 'CFReactions
SCFReactions,
voice :: ContactUserPreference VoicePreference
voice = SChatFeature 'CFVoice
-> ContactUserPreference (FeaturePreference 'CFVoice)
forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature 'CFVoice
SCFVoice,
files :: ContactUserPreference FilesPreference
files = SChatFeature 'CFFiles
-> ContactUserPreference (FeaturePreference 'CFFiles)
forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature 'CFFiles
SCFFiles,
calls :: ContactUserPreference CallsPreference
calls = SChatFeature 'CFCalls
-> ContactUserPreference (FeaturePreference 'CFCalls)
forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature 'CFCalls
SCFCalls,
sessions :: ContactUserPreference SessionsPreference
sessions = SChatFeature 'CFSessions
-> ContactUserPreference (FeaturePreference 'CFSessions)
forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature 'CFSessions
SCFSessions,
commands :: Maybe [ChatBotCommand]
commands = Maybe Preferences
contactPreferences Maybe Preferences
-> (Preferences -> Maybe [ChatBotCommand])
-> Maybe [ChatBotCommand]
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Preferences -> Maybe [ChatBotCommand]
forall p. HasCommands p => p -> Maybe [ChatBotCommand]
commands_
}
where
pref :: FeatureI f => SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref :: forall (f :: ChatFeature).
FeatureI f =>
SChatFeature f -> ContactUserPreference (FeaturePreference f)
pref SChatFeature f
f =
ContactUserPreference
{ enabled :: PrefEnabled
enabled = Bool -> FeaturePreference f -> FeaturePreference f -> PrefEnabled
forall (f :: ChatFeature).
FeatureI f =>
Bool -> FeaturePreference f -> FeaturePreference f -> PrefEnabled
prefEnabled (SChatFeature f -> Bool
forall {f :: ChatFeature}. SChatFeature f -> Bool
asymmetric SChatFeature f
f) FeaturePreference f
userPref FeaturePreference f
ctPref,
userPreference :: ContactUserPref (FeaturePreference f)
userPreference = if Bool
connectedIncognito then FeaturePreference f -> ContactUserPref (FeaturePreference f)
forall p. p -> ContactUserPref p
CUPContact FeaturePreference f
ctUserPref else ContactUserPref (FeaturePreference f)
-> (FeaturePreference f -> ContactUserPref (FeaturePreference f))
-> Maybe (FeaturePreference f)
-> ContactUserPref (FeaturePreference f)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (FeaturePreference f -> ContactUserPref (FeaturePreference f)
forall p. p -> ContactUserPref p
CUPUser FeaturePreference f
userPref) FeaturePreference f -> ContactUserPref (FeaturePreference f)
forall p. p -> ContactUserPref p
CUPContact Maybe (FeaturePreference f)
ctUserPref_,
contactPreference :: FeaturePreference f
contactPreference = FeaturePreference f
ctPref
}
where
asymmetric :: SChatFeature f -> Bool
asymmetric SChatFeature f
SCFTimedMessages = Bool
False
asymmetric SChatFeature f
_ = Bool
True
ctUserPref :: FeaturePreference f
ctUserPref = SChatFeature f -> Preferences -> FeaturePreference f
forall p (f :: ChatFeature).
PreferenceI p =>
SChatFeature f -> p -> FeaturePreference f
forall (f :: ChatFeature).
SChatFeature f -> Preferences -> FeaturePreference f
getPreference SChatFeature f
f Preferences
userPreferences
ctUserPref_ :: Maybe (FeaturePreference f)
ctUserPref_ = SChatFeature f -> Preferences -> Maybe (FeaturePreference f)
forall (f :: ChatFeature).
SChatFeature f -> Preferences -> Maybe (FeaturePreference f)
chatPrefSel SChatFeature f
f Preferences
userPreferences
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
ctUserPrefs
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
contactPreferences
ctUserPrefs :: FullPreferences
ctUserPrefs = User -> Bool -> Preferences -> FullPreferences
mergeUserChatPrefs' User
user Bool
connectedIncognito Preferences
userPreferences
data Profile = Profile
{ Profile -> Text
displayName :: ContactName,
Profile -> Text
fullName :: Text,
Profile -> Maybe Text
shortDescr :: Maybe Text,
Profile -> Maybe ImageData
image :: Maybe ImageData,
Profile -> Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact,
Profile -> Maybe Preferences
preferences :: Maybe Preferences,
Profile -> Maybe ChatPeerType
peerType :: Maybe ChatPeerType
}
deriving (Profile -> Profile -> Bool
(Profile -> Profile -> Bool)
-> (Profile -> Profile -> Bool) -> Eq Profile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Profile -> Profile -> Bool
== :: Profile -> Profile -> Bool
$c/= :: Profile -> Profile -> Bool
/= :: Profile -> Profile -> Bool
Eq, Int -> Profile -> ShowS
[Profile] -> ShowS
Profile -> String
(Int -> Profile -> ShowS)
-> (Profile -> String) -> ([Profile] -> ShowS) -> Show Profile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Profile -> ShowS
showsPrec :: Int -> Profile -> ShowS
$cshow :: Profile -> String
show :: Profile -> String
$cshowList :: [Profile] -> ShowS
showList :: [Profile] -> ShowS
Show)
data ChatPeerType = CPTHuman | CPTBot
deriving (ChatPeerType -> ChatPeerType -> Bool
(ChatPeerType -> ChatPeerType -> Bool)
-> (ChatPeerType -> ChatPeerType -> Bool) -> Eq ChatPeerType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatPeerType -> ChatPeerType -> Bool
== :: ChatPeerType -> ChatPeerType -> Bool
$c/= :: ChatPeerType -> ChatPeerType -> Bool
/= :: ChatPeerType -> ChatPeerType -> Bool
Eq, Int -> ChatPeerType -> ShowS
[ChatPeerType] -> ShowS
ChatPeerType -> String
(Int -> ChatPeerType -> ShowS)
-> (ChatPeerType -> String)
-> ([ChatPeerType] -> ShowS)
-> Show ChatPeerType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatPeerType -> ShowS
showsPrec :: Int -> ChatPeerType -> ShowS
$cshow :: ChatPeerType -> String
show :: ChatPeerType -> String
$cshowList :: [ChatPeerType] -> ShowS
showList :: [ChatPeerType] -> ShowS
Show)
instance FromJSON ChatPeerType where
parseJSON :: Value -> Parser ChatPeerType
parseJSON = String -> Value -> Parser ChatPeerType
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"ChatPeerType"
instance ToJSON ChatPeerType where
toJSON :: ChatPeerType -> Value
toJSON = Text -> Value
J.String (Text -> Value) -> (ChatPeerType -> Text) -> ChatPeerType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChatPeerType -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: ChatPeerType -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding)
-> (ChatPeerType -> Text) -> ChatPeerType -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChatPeerType -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromField ChatPeerType where fromField :: FieldParser ChatPeerType
fromField = (Text -> Maybe ChatPeerType) -> FieldParser ChatPeerType
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe ChatPeerType
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField ChatPeerType where toField :: ChatPeerType -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (ChatPeerType -> Text) -> ChatPeerType -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChatPeerType -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding ChatPeerType where
textDecode :: Text -> Maybe ChatPeerType
textDecode = \case
Text
"human" -> ChatPeerType -> Maybe ChatPeerType
forall a. a -> Maybe a
Just ChatPeerType
CPTHuman
Text
"bot" -> ChatPeerType -> Maybe ChatPeerType
forall a. a -> Maybe a
Just ChatPeerType
CPTBot
Text
_ -> Maybe ChatPeerType
forall a. Maybe a
Nothing
textEncode :: ChatPeerType -> Text
textEncode = \case
ChatPeerType
CPTHuman -> Text
"human"
ChatPeerType
CPTBot -> Text
"bot"
profileFromName :: ContactName -> Profile
profileFromName :: Text -> Profile
profileFromName Text
displayName =
Profile {Text
displayName :: Text
displayName :: Text
displayName, fullName :: Text
fullName = Text
"", shortDescr :: Maybe Text
shortDescr = Maybe Text
forall a. Maybe a
Nothing, image :: Maybe ImageData
image = Maybe ImageData
forall a. Maybe a
Nothing, contactLink :: Maybe ConnLinkContact
contactLink = Maybe ConnLinkContact
forall a. Maybe a
Nothing, preferences :: Maybe Preferences
preferences = Maybe Preferences
forall a. Maybe a
Nothing, peerType :: Maybe ChatPeerType
peerType = Maybe ChatPeerType
forall a. Maybe a
Nothing}
profilesMatch :: LocalProfile -> LocalProfile -> Bool
profilesMatch :: LocalProfile -> LocalProfile -> Bool
profilesMatch
LocalProfile {displayName :: LocalProfile -> Text
displayName = Text
n1, fullName :: LocalProfile -> Text
fullName = Text
fn1, image :: LocalProfile -> Maybe ImageData
image = Maybe ImageData
i1}
LocalProfile {displayName :: LocalProfile -> Text
displayName = Text
n2, fullName :: LocalProfile -> Text
fullName = Text
fn2, image :: LocalProfile -> Maybe ImageData
image = Maybe ImageData
i2} =
Text
n1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
n2 Bool -> Bool -> Bool
&& Text
fn1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
fn2 Bool -> Bool -> Bool
&& Maybe ImageData
i1 Maybe ImageData -> Maybe ImageData -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe ImageData
i2
data IncognitoProfile = NewIncognito Profile | ExistingIncognito LocalProfile
fromIncognitoProfile :: IncognitoProfile -> Profile
fromIncognitoProfile :: IncognitoProfile -> Profile
fromIncognitoProfile = \case
NewIncognito Profile
p -> Profile
p
ExistingIncognito LocalProfile
lp -> LocalProfile -> Profile
fromLocalProfile LocalProfile
lp
userProfileDirect :: User -> Maybe Profile -> Maybe Contact -> Bool -> Profile
userProfileDirect :: User -> Maybe Profile -> Maybe Contact -> Bool -> Profile
userProfileDirect user :: User
user@User {profile :: User -> LocalProfile
profile = LocalProfile
p} Maybe Profile
incognitoProfile Maybe Contact
ct Bool
canFallbackToUserTTL =
let p' :: Profile
p' = Profile -> Maybe Profile -> Profile
forall a. a -> Maybe a -> a
fromMaybe (LocalProfile -> Profile
fromLocalProfile LocalProfile
p) Maybe Profile
incognitoProfile
fullPrefs :: FullPreferences
fullPrefs = Maybe Preferences -> Maybe Preferences -> Bool -> FullPreferences
mergePreferences (Contact -> Preferences
userPreferences (Contact -> Preferences) -> Maybe Contact -> Maybe Preferences
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Contact
ct) Maybe Preferences
userPrefs Bool
canFallbackToUserTTL
in (Profile
p' :: Profile) {preferences = Just $ toChatPrefs fullPrefs}
where
userPrefs :: Maybe Preferences
userPrefs
| Maybe Profile -> Bool
forall a. Maybe a -> Bool
isNothing Maybe Profile
incognitoProfile = User -> Maybe Preferences
forall a. IsContact a => a -> Maybe Preferences
preferences' User
user
| Bool
otherwise =
let FullPreferences {timedMessages :: FullPreferences -> TimedMessagesPreference
timedMessages = TimedMessagesPreference {FeatureAllowed
allow :: FeatureAllowed
allow :: TimedMessagesPreference -> FeatureAllowed
allow}} = FullPreferences
defaultChatPrefs
userLevelTTL :: Maybe Int
userLevelTTL = User -> Maybe Preferences
forall a. IsContact a => a -> Maybe Preferences
preferences' User
user Maybe Preferences
-> (Preferences -> Maybe TimedMessagesPreference)
-> Maybe TimedMessagesPreference
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= SChatFeature 'CFTimedMessages
-> Preferences -> Maybe (FeaturePreference 'CFTimedMessages)
forall (f :: ChatFeature).
SChatFeature f -> Preferences -> Maybe (FeaturePreference f)
chatPrefSel SChatFeature 'CFTimedMessages
SCFTimedMessages Maybe TimedMessagesPreference
-> (TimedMessagesPreference -> Maybe Int) -> Maybe Int
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\TimedMessagesPreference {Maybe Int
ttl :: Maybe Int
ttl :: TimedMessagesPreference -> Maybe Int
ttl} -> Maybe Int
ttl)
in Preferences -> Maybe Preferences
forall a. a -> Maybe a
Just (Preferences -> Maybe Preferences)
-> Preferences -> Maybe Preferences
forall a b. (a -> b) -> a -> b
$ FullPreferences -> Preferences
toChatPrefs (FullPreferences
defaultChatPrefs :: FullPreferences) {timedMessages = TimedMessagesPreference {allow, ttl = userLevelTTL}}
type LocalAlias = Text
data LocalProfile = LocalProfile
{ LocalProfile -> CommandId
profileId :: ProfileId,
LocalProfile -> Text
displayName :: ContactName,
LocalProfile -> Text
fullName :: Text,
LocalProfile -> Maybe Text
shortDescr :: Maybe Text,
LocalProfile -> Maybe ImageData
image :: Maybe ImageData,
LocalProfile -> Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact,
LocalProfile -> Maybe Preferences
preferences :: Maybe Preferences,
LocalProfile -> Maybe ChatPeerType
peerType :: Maybe ChatPeerType,
LocalProfile -> Text
localAlias :: LocalAlias
}
deriving (LocalProfile -> LocalProfile -> Bool
(LocalProfile -> LocalProfile -> Bool)
-> (LocalProfile -> LocalProfile -> Bool) -> Eq LocalProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LocalProfile -> LocalProfile -> Bool
== :: LocalProfile -> LocalProfile -> Bool
$c/= :: LocalProfile -> LocalProfile -> Bool
/= :: LocalProfile -> LocalProfile -> Bool
Eq, Int -> LocalProfile -> ShowS
[LocalProfile] -> ShowS
LocalProfile -> String
(Int -> LocalProfile -> ShowS)
-> (LocalProfile -> String)
-> ([LocalProfile] -> ShowS)
-> Show LocalProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocalProfile -> ShowS
showsPrec :: Int -> LocalProfile -> ShowS
$cshow :: LocalProfile -> String
show :: LocalProfile -> String
$cshowList :: [LocalProfile] -> ShowS
showList :: [LocalProfile] -> ShowS
Show)
localProfileId :: LocalProfile -> ProfileId
localProfileId :: LocalProfile -> CommandId
localProfileId LocalProfile {CommandId
profileId :: LocalProfile -> CommandId
profileId :: CommandId
profileId} = CommandId
profileId
toLocalProfile :: ProfileId -> Profile -> LocalAlias -> LocalProfile
toLocalProfile :: CommandId -> Profile -> Text -> LocalProfile
toLocalProfile CommandId
profileId Profile {Text
displayName :: Profile -> Text
displayName :: Text
displayName, Text
fullName :: Profile -> Text
fullName :: Text
fullName, Maybe Text
shortDescr :: Profile -> Maybe Text
shortDescr :: Maybe Text
shortDescr, Maybe ImageData
image :: Profile -> Maybe ImageData
image :: Maybe ImageData
image, Maybe ConnLinkContact
contactLink :: Profile -> Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink, Maybe Preferences
preferences :: Profile -> Maybe Preferences
preferences :: Maybe Preferences
preferences, Maybe ChatPeerType
peerType :: Profile -> Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType} Text
localAlias =
LocalProfile {CommandId
profileId :: CommandId
profileId :: CommandId
profileId, Text
displayName :: Text
displayName :: Text
displayName, Text
fullName :: Text
fullName :: Text
fullName, Maybe Text
shortDescr :: Maybe Text
shortDescr :: Maybe Text
shortDescr, Maybe ImageData
image :: Maybe ImageData
image :: Maybe ImageData
image, Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink, Maybe Preferences
preferences :: Maybe Preferences
preferences :: Maybe Preferences
preferences, Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType, Text
localAlias :: Text
localAlias :: Text
localAlias}
fromLocalProfile :: LocalProfile -> Profile
fromLocalProfile :: LocalProfile -> Profile
fromLocalProfile LocalProfile {Text
displayName :: LocalProfile -> Text
displayName :: Text
displayName, Text
fullName :: LocalProfile -> Text
fullName :: Text
fullName, Maybe Text
shortDescr :: LocalProfile -> Maybe Text
shortDescr :: Maybe Text
shortDescr, Maybe ImageData
image :: LocalProfile -> Maybe ImageData
image :: Maybe ImageData
image, Maybe ConnLinkContact
contactLink :: LocalProfile -> Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink, Maybe Preferences
preferences :: LocalProfile -> Maybe Preferences
preferences :: Maybe Preferences
preferences, Maybe ChatPeerType
peerType :: LocalProfile -> Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType} =
Profile {Text
displayName :: Text
displayName :: Text
displayName, Text
fullName :: Text
fullName :: Text
fullName, Maybe Text
shortDescr :: Maybe Text
shortDescr :: Maybe Text
shortDescr, Maybe ImageData
image :: Maybe ImageData
image :: Maybe ImageData
image, Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink :: Maybe ConnLinkContact
contactLink, Maybe Preferences
preferences :: Maybe Preferences
preferences :: Maybe Preferences
preferences, Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType :: Maybe ChatPeerType
peerType}
data GroupProfile = GroupProfile
{ GroupProfile -> Text
displayName :: GroupName,
GroupProfile -> Text
fullName :: Text,
GroupProfile -> Maybe Text
shortDescr :: Maybe Text,
GroupProfile -> Maybe Text
description :: Maybe Text,
GroupProfile -> Maybe ImageData
image :: Maybe ImageData,
GroupProfile -> Maybe GroupPreferences
groupPreferences :: Maybe GroupPreferences,
GroupProfile -> Maybe GroupMemberAdmission
memberAdmission :: Maybe GroupMemberAdmission
}
deriving (GroupProfile -> GroupProfile -> Bool
(GroupProfile -> GroupProfile -> Bool)
-> (GroupProfile -> GroupProfile -> Bool) -> Eq GroupProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupProfile -> GroupProfile -> Bool
== :: GroupProfile -> GroupProfile -> Bool
$c/= :: GroupProfile -> GroupProfile -> Bool
/= :: GroupProfile -> GroupProfile -> Bool
Eq, Int -> GroupProfile -> ShowS
[GroupProfile] -> ShowS
GroupProfile -> String
(Int -> GroupProfile -> ShowS)
-> (GroupProfile -> String)
-> ([GroupProfile] -> ShowS)
-> Show GroupProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupProfile -> ShowS
showsPrec :: Int -> GroupProfile -> ShowS
$cshow :: GroupProfile -> String
show :: GroupProfile -> String
$cshowList :: [GroupProfile] -> ShowS
showList :: [GroupProfile] -> ShowS
Show)
data GroupMemberAdmission = GroupMemberAdmission
{
GroupMemberAdmission -> Maybe MemberCriteria
review :: Maybe MemberCriteria
}
deriving (GroupMemberAdmission -> GroupMemberAdmission -> Bool
(GroupMemberAdmission -> GroupMemberAdmission -> Bool)
-> (GroupMemberAdmission -> GroupMemberAdmission -> Bool)
-> Eq GroupMemberAdmission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupMemberAdmission -> GroupMemberAdmission -> Bool
== :: GroupMemberAdmission -> GroupMemberAdmission -> Bool
$c/= :: GroupMemberAdmission -> GroupMemberAdmission -> Bool
/= :: GroupMemberAdmission -> GroupMemberAdmission -> Bool
Eq, Int -> GroupMemberAdmission -> ShowS
[GroupMemberAdmission] -> ShowS
GroupMemberAdmission -> String
(Int -> GroupMemberAdmission -> ShowS)
-> (GroupMemberAdmission -> String)
-> ([GroupMemberAdmission] -> ShowS)
-> Show GroupMemberAdmission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupMemberAdmission -> ShowS
showsPrec :: Int -> GroupMemberAdmission -> ShowS
$cshow :: GroupMemberAdmission -> String
show :: GroupMemberAdmission -> String
$cshowList :: [GroupMemberAdmission] -> ShowS
showList :: [GroupMemberAdmission] -> ShowS
Show)
data MemberCriteria = MCAll
deriving (MemberCriteria -> MemberCriteria -> Bool
(MemberCriteria -> MemberCriteria -> Bool)
-> (MemberCriteria -> MemberCriteria -> Bool) -> Eq MemberCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MemberCriteria -> MemberCriteria -> Bool
== :: MemberCriteria -> MemberCriteria -> Bool
$c/= :: MemberCriteria -> MemberCriteria -> Bool
/= :: MemberCriteria -> MemberCriteria -> Bool
Eq, Int -> MemberCriteria -> ShowS
[MemberCriteria] -> ShowS
MemberCriteria -> String
(Int -> MemberCriteria -> ShowS)
-> (MemberCriteria -> String)
-> ([MemberCriteria] -> ShowS)
-> Show MemberCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MemberCriteria -> ShowS
showsPrec :: Int -> MemberCriteria -> ShowS
$cshow :: MemberCriteria -> String
show :: MemberCriteria -> String
$cshowList :: [MemberCriteria] -> ShowS
showList :: [MemberCriteria] -> ShowS
Show)
emptyGroupMemberAdmission :: GroupMemberAdmission
emptyGroupMemberAdmission :: GroupMemberAdmission
emptyGroupMemberAdmission = Maybe MemberCriteria -> GroupMemberAdmission
GroupMemberAdmission Maybe MemberCriteria
forall a. Maybe a
Nothing
newtype ImageData = ImageData Text
deriving (ImageData -> ImageData -> Bool
(ImageData -> ImageData -> Bool)
-> (ImageData -> ImageData -> Bool) -> Eq ImageData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ImageData -> ImageData -> Bool
== :: ImageData -> ImageData -> Bool
$c/= :: ImageData -> ImageData -> Bool
/= :: ImageData -> ImageData -> Bool
Eq, Int -> ImageData -> ShowS
[ImageData] -> ShowS
ImageData -> String
(Int -> ImageData -> ShowS)
-> (ImageData -> String)
-> ([ImageData] -> ShowS)
-> Show ImageData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ImageData -> ShowS
showsPrec :: Int -> ImageData -> ShowS
$cshow :: ImageData -> String
show :: ImageData -> String
$cshowList :: [ImageData] -> ShowS
showList :: [ImageData] -> ShowS
Show)
instance FromJSON ImageData where
parseJSON :: Value -> Parser ImageData
parseJSON = (Text -> ImageData) -> Parser Text -> Parser ImageData
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> ImageData
ImageData (Parser Text -> Parser ImageData)
-> (Value -> Parser Text) -> Value -> Parser ImageData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Parser Text
forall a. FromJSON a => Value -> Parser a
J.parseJSON
instance ToJSON ImageData where
toJSON :: ImageData -> Value
toJSON (ImageData Text
t) = Text -> Value
forall a. ToJSON a => a -> Value
J.toJSON Text
t
toEncoding :: ImageData -> Encoding
toEncoding (ImageData Text
t) = Text -> Encoding
forall a. ToJSON a => a -> Encoding
J.toEncoding Text
t
instance ToField ImageData where toField :: ImageData -> SQLData
toField (ImageData Text
t) = Text -> SQLData
forall a. ToField a => a -> SQLData
toField Text
t
deriving newtype instance FromField ImageData
data CReqClientData = CRDataGroup {CReqClientData -> GroupLinkId
groupLinkId :: GroupLinkId}
newtype GroupLinkId = GroupLinkId {GroupLinkId -> ByteString
unGroupLinkId :: ByteString}
deriving (GroupLinkId -> GroupLinkId -> Bool
(GroupLinkId -> GroupLinkId -> Bool)
-> (GroupLinkId -> GroupLinkId -> Bool) -> Eq GroupLinkId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupLinkId -> GroupLinkId -> Bool
== :: GroupLinkId -> GroupLinkId -> Bool
$c/= :: GroupLinkId -> GroupLinkId -> Bool
/= :: GroupLinkId -> GroupLinkId -> Bool
Eq, Int -> GroupLinkId -> ShowS
[GroupLinkId] -> ShowS
GroupLinkId -> String
(Int -> GroupLinkId -> ShowS)
-> (GroupLinkId -> String)
-> ([GroupLinkId] -> ShowS)
-> Show GroupLinkId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupLinkId -> ShowS
showsPrec :: Int -> GroupLinkId -> ShowS
$cshow :: GroupLinkId -> String
show :: GroupLinkId -> String
$cshowList :: [GroupLinkId] -> ShowS
showList :: [GroupLinkId] -> ShowS
Show)
deriving newtype (FieldParser GroupLinkId
FieldParser GroupLinkId -> FromField GroupLinkId
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser GroupLinkId
fromField :: FieldParser GroupLinkId
FromField)
instance ToField GroupLinkId where toField :: GroupLinkId -> SQLData
toField (GroupLinkId ByteString
g) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
g
instance StrEncoding GroupLinkId where
strEncode :: GroupLinkId -> ByteString
strEncode (GroupLinkId ByteString
g) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
g
strDecode :: ByteString -> Either String GroupLinkId
strDecode ByteString
s = ByteString -> GroupLinkId
GroupLinkId (ByteString -> GroupLinkId)
-> Either String ByteString -> Either String GroupLinkId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser GroupLinkId
strP = ByteString -> GroupLinkId
GroupLinkId (ByteString -> GroupLinkId)
-> Parser ByteString ByteString -> Parser GroupLinkId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON GroupLinkId where
parseJSON :: Value -> Parser GroupLinkId
parseJSON = String -> Value -> Parser GroupLinkId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"GroupLinkId"
instance ToJSON GroupLinkId where
toJSON :: GroupLinkId -> Value
toJSON = GroupLinkId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: GroupLinkId -> Encoding
toEncoding = GroupLinkId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
data GroupInvitation = GroupInvitation
{ GroupInvitation -> MemberIdRole
fromMember :: MemberIdRole,
GroupInvitation -> MemberIdRole
invitedMember :: MemberIdRole,
GroupInvitation -> ConnReqInvitation
connRequest :: ConnReqInvitation,
GroupInvitation -> GroupProfile
groupProfile :: GroupProfile,
GroupInvitation -> Maybe BusinessChatInfo
business :: Maybe BusinessChatInfo,
GroupInvitation -> Maybe GroupLinkId
groupLinkId :: Maybe GroupLinkId,
GroupInvitation -> Maybe Int
groupSize :: Maybe Int
}
deriving (GroupInvitation -> GroupInvitation -> Bool
(GroupInvitation -> GroupInvitation -> Bool)
-> (GroupInvitation -> GroupInvitation -> Bool)
-> Eq GroupInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupInvitation -> GroupInvitation -> Bool
== :: GroupInvitation -> GroupInvitation -> Bool
$c/= :: GroupInvitation -> GroupInvitation -> Bool
/= :: GroupInvitation -> GroupInvitation -> Bool
Eq, Int -> GroupInvitation -> ShowS
[GroupInvitation] -> ShowS
GroupInvitation -> String
(Int -> GroupInvitation -> ShowS)
-> (GroupInvitation -> String)
-> ([GroupInvitation] -> ShowS)
-> Show GroupInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupInvitation -> ShowS
showsPrec :: Int -> GroupInvitation -> ShowS
$cshow :: GroupInvitation -> String
show :: GroupInvitation -> String
$cshowList :: [GroupInvitation] -> ShowS
showList :: [GroupInvitation] -> ShowS
Show)
data GroupLinkInvitation = GroupLinkInvitation
{ GroupLinkInvitation -> MemberIdRole
fromMember :: MemberIdRole,
GroupLinkInvitation -> Text
fromMemberName :: ContactName,
GroupLinkInvitation -> MemberIdRole
invitedMember :: MemberIdRole,
GroupLinkInvitation -> GroupProfile
groupProfile :: GroupProfile,
GroupLinkInvitation -> Maybe GroupAcceptance
accepted :: Maybe GroupAcceptance,
GroupLinkInvitation -> Maybe BusinessChatInfo
business :: Maybe BusinessChatInfo,
GroupLinkInvitation -> Maybe Int
groupSize :: Maybe Int
}
deriving (GroupLinkInvitation -> GroupLinkInvitation -> Bool
(GroupLinkInvitation -> GroupLinkInvitation -> Bool)
-> (GroupLinkInvitation -> GroupLinkInvitation -> Bool)
-> Eq GroupLinkInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupLinkInvitation -> GroupLinkInvitation -> Bool
== :: GroupLinkInvitation -> GroupLinkInvitation -> Bool
$c/= :: GroupLinkInvitation -> GroupLinkInvitation -> Bool
/= :: GroupLinkInvitation -> GroupLinkInvitation -> Bool
Eq, Int -> GroupLinkInvitation -> ShowS
[GroupLinkInvitation] -> ShowS
GroupLinkInvitation -> String
(Int -> GroupLinkInvitation -> ShowS)
-> (GroupLinkInvitation -> String)
-> ([GroupLinkInvitation] -> ShowS)
-> Show GroupLinkInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupLinkInvitation -> ShowS
showsPrec :: Int -> GroupLinkInvitation -> ShowS
$cshow :: GroupLinkInvitation -> String
show :: GroupLinkInvitation -> String
$cshowList :: [GroupLinkInvitation] -> ShowS
showList :: [GroupLinkInvitation] -> ShowS
Show)
data GroupLinkRejection = GroupLinkRejection
{ GroupLinkRejection -> MemberIdRole
fromMember :: MemberIdRole,
GroupLinkRejection -> MemberIdRole
invitedMember :: MemberIdRole,
GroupLinkRejection -> GroupProfile
groupProfile :: GroupProfile,
GroupLinkRejection -> GroupRejectionReason
rejectionReason :: GroupRejectionReason
}
deriving (GroupLinkRejection -> GroupLinkRejection -> Bool
(GroupLinkRejection -> GroupLinkRejection -> Bool)
-> (GroupLinkRejection -> GroupLinkRejection -> Bool)
-> Eq GroupLinkRejection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupLinkRejection -> GroupLinkRejection -> Bool
== :: GroupLinkRejection -> GroupLinkRejection -> Bool
$c/= :: GroupLinkRejection -> GroupLinkRejection -> Bool
/= :: GroupLinkRejection -> GroupLinkRejection -> Bool
Eq, Int -> GroupLinkRejection -> ShowS
[GroupLinkRejection] -> ShowS
GroupLinkRejection -> String
(Int -> GroupLinkRejection -> ShowS)
-> (GroupLinkRejection -> String)
-> ([GroupLinkRejection] -> ShowS)
-> Show GroupLinkRejection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupLinkRejection -> ShowS
showsPrec :: Int -> GroupLinkRejection -> ShowS
$cshow :: GroupLinkRejection -> String
show :: GroupLinkRejection -> String
$cshowList :: [GroupLinkRejection] -> ShowS
showList :: [GroupLinkRejection] -> ShowS
Show)
data GroupRejectionReason
= GRRLongName
| GRRBlockedName
| GRRUnknown {GroupRejectionReason -> Text
text :: Text}
deriving (GroupRejectionReason -> GroupRejectionReason -> Bool
(GroupRejectionReason -> GroupRejectionReason -> Bool)
-> (GroupRejectionReason -> GroupRejectionReason -> Bool)
-> Eq GroupRejectionReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupRejectionReason -> GroupRejectionReason -> Bool
== :: GroupRejectionReason -> GroupRejectionReason -> Bool
$c/= :: GroupRejectionReason -> GroupRejectionReason -> Bool
/= :: GroupRejectionReason -> GroupRejectionReason -> Bool
Eq, Int -> GroupRejectionReason -> ShowS
[GroupRejectionReason] -> ShowS
GroupRejectionReason -> String
(Int -> GroupRejectionReason -> ShowS)
-> (GroupRejectionReason -> String)
-> ([GroupRejectionReason] -> ShowS)
-> Show GroupRejectionReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupRejectionReason -> ShowS
showsPrec :: Int -> GroupRejectionReason -> ShowS
$cshow :: GroupRejectionReason -> String
show :: GroupRejectionReason -> String
$cshowList :: [GroupRejectionReason] -> ShowS
showList :: [GroupRejectionReason] -> ShowS
Show)
instance FromField GroupRejectionReason where fromField :: FieldParser GroupRejectionReason
fromField = (ByteString -> Either String GroupRejectionReason)
-> FieldParser GroupRejectionReason
forall k.
Typeable k =>
(ByteString -> Either String k) -> FieldParser k
blobFieldDecoder ByteString -> Either String GroupRejectionReason
forall a. StrEncoding a => ByteString -> Either String a
strDecode
instance ToField GroupRejectionReason where toField :: GroupRejectionReason -> SQLData
toField = ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (ByteString -> SQLData)
-> (GroupRejectionReason -> ByteString)
-> GroupRejectionReason
-> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupRejectionReason -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode
instance StrEncoding GroupRejectionReason where
strEncode :: GroupRejectionReason -> ByteString
strEncode = \case
GroupRejectionReason
GRRLongName -> ByteString
"long_name"
GroupRejectionReason
GRRBlockedName -> ByteString
"blocked_name"
GRRUnknown Text
text -> Text -> ByteString
encodeUtf8 Text
text
strP :: Parser GroupRejectionReason
strP =
Parser ByteString ByteString
"long_name" Parser ByteString ByteString
-> GroupRejectionReason -> Parser GroupRejectionReason
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> GroupRejectionReason
GRRLongName
Parser GroupRejectionReason
-> Parser GroupRejectionReason -> Parser GroupRejectionReason
forall a.
Parser ByteString a -> Parser ByteString a -> Parser ByteString a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser ByteString ByteString
"blocked_name" Parser ByteString ByteString
-> GroupRejectionReason -> Parser GroupRejectionReason
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> GroupRejectionReason
GRRBlockedName
Parser GroupRejectionReason
-> Parser GroupRejectionReason -> Parser GroupRejectionReason
forall a.
Parser ByteString a -> Parser ByteString a -> Parser ByteString a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Text -> GroupRejectionReason
GRRUnknown (Text -> GroupRejectionReason)
-> (ByteString -> Text) -> ByteString -> GroupRejectionReason
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
safeDecodeUtf8 (ByteString -> GroupRejectionReason)
-> Parser ByteString ByteString -> Parser GroupRejectionReason
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
A.takeByteString
instance FromJSON GroupRejectionReason where
parseJSON :: Value -> Parser GroupRejectionReason
parseJSON = String -> Value -> Parser GroupRejectionReason
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"GroupRejectionReason"
instance ToJSON GroupRejectionReason where
toJSON :: GroupRejectionReason -> Value
toJSON = GroupRejectionReason -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: GroupRejectionReason -> Encoding
toEncoding = GroupRejectionReason -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
data MemberIdRole = MemberIdRole
{ MemberIdRole -> MemberId
memberId :: MemberId,
MemberIdRole -> GroupMemberRole
memberRole :: GroupMemberRole
}
deriving (MemberIdRole -> MemberIdRole -> Bool
(MemberIdRole -> MemberIdRole -> Bool)
-> (MemberIdRole -> MemberIdRole -> Bool) -> Eq MemberIdRole
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MemberIdRole -> MemberIdRole -> Bool
== :: MemberIdRole -> MemberIdRole -> Bool
$c/= :: MemberIdRole -> MemberIdRole -> Bool
/= :: MemberIdRole -> MemberIdRole -> Bool
Eq, Int -> MemberIdRole -> ShowS
[MemberIdRole] -> ShowS
MemberIdRole -> String
(Int -> MemberIdRole -> ShowS)
-> (MemberIdRole -> String)
-> ([MemberIdRole] -> ShowS)
-> Show MemberIdRole
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MemberIdRole -> ShowS
showsPrec :: Int -> MemberIdRole -> ShowS
$cshow :: MemberIdRole -> String
show :: MemberIdRole -> String
$cshowList :: [MemberIdRole] -> ShowS
showList :: [MemberIdRole] -> ShowS
Show)
data IntroInvitation = IntroInvitation
{ IntroInvitation -> ConnReqInvitation
groupConnReq :: ConnReqInvitation,
IntroInvitation -> Maybe ConnReqInvitation
directConnReq :: Maybe ConnReqInvitation
}
deriving (IntroInvitation -> IntroInvitation -> Bool
(IntroInvitation -> IntroInvitation -> Bool)
-> (IntroInvitation -> IntroInvitation -> Bool)
-> Eq IntroInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IntroInvitation -> IntroInvitation -> Bool
== :: IntroInvitation -> IntroInvitation -> Bool
$c/= :: IntroInvitation -> IntroInvitation -> Bool
/= :: IntroInvitation -> IntroInvitation -> Bool
Eq, Int -> IntroInvitation -> ShowS
[IntroInvitation] -> ShowS
IntroInvitation -> String
(Int -> IntroInvitation -> ShowS)
-> (IntroInvitation -> String)
-> ([IntroInvitation] -> ShowS)
-> Show IntroInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IntroInvitation -> ShowS
showsPrec :: Int -> IntroInvitation -> ShowS
$cshow :: IntroInvitation -> String
show :: IntroInvitation -> String
$cshowList :: [IntroInvitation] -> ShowS
showList :: [IntroInvitation] -> ShowS
Show)
data MemberInfo = MemberInfo
{ MemberInfo -> MemberId
memberId :: MemberId,
MemberInfo -> GroupMemberRole
memberRole :: GroupMemberRole,
MemberInfo -> Maybe ChatVersionRange
v :: Maybe ChatVersionRange,
MemberInfo -> Profile
profile :: Profile
}
deriving (MemberInfo -> MemberInfo -> Bool
(MemberInfo -> MemberInfo -> Bool)
-> (MemberInfo -> MemberInfo -> Bool) -> Eq MemberInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MemberInfo -> MemberInfo -> Bool
== :: MemberInfo -> MemberInfo -> Bool
$c/= :: MemberInfo -> MemberInfo -> Bool
/= :: MemberInfo -> MemberInfo -> Bool
Eq, Int -> MemberInfo -> ShowS
[MemberInfo] -> ShowS
MemberInfo -> String
(Int -> MemberInfo -> ShowS)
-> (MemberInfo -> String)
-> ([MemberInfo] -> ShowS)
-> Show MemberInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MemberInfo -> ShowS
showsPrec :: Int -> MemberInfo -> ShowS
$cshow :: MemberInfo -> String
show :: MemberInfo -> String
$cshowList :: [MemberInfo] -> ShowS
showList :: [MemberInfo] -> ShowS
Show)
data BusinessChatInfo = BusinessChatInfo
{ BusinessChatInfo -> BusinessChatType
chatType :: BusinessChatType,
BusinessChatInfo -> MemberId
businessId :: MemberId,
BusinessChatInfo -> MemberId
customerId :: MemberId
}
deriving (BusinessChatInfo -> BusinessChatInfo -> Bool
(BusinessChatInfo -> BusinessChatInfo -> Bool)
-> (BusinessChatInfo -> BusinessChatInfo -> Bool)
-> Eq BusinessChatInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BusinessChatInfo -> BusinessChatInfo -> Bool
== :: BusinessChatInfo -> BusinessChatInfo -> Bool
$c/= :: BusinessChatInfo -> BusinessChatInfo -> Bool
/= :: BusinessChatInfo -> BusinessChatInfo -> Bool
Eq, Int -> BusinessChatInfo -> ShowS
[BusinessChatInfo] -> ShowS
BusinessChatInfo -> String
(Int -> BusinessChatInfo -> ShowS)
-> (BusinessChatInfo -> String)
-> ([BusinessChatInfo] -> ShowS)
-> Show BusinessChatInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessChatInfo -> ShowS
showsPrec :: Int -> BusinessChatInfo -> ShowS
$cshow :: BusinessChatInfo -> String
show :: BusinessChatInfo -> String
$cshowList :: [BusinessChatInfo] -> ShowS
showList :: [BusinessChatInfo] -> ShowS
Show)
data MemberRestrictionStatus
= MRSBlocked
| MRSUnrestricted
| MRSUnknown Text
deriving (MemberRestrictionStatus -> MemberRestrictionStatus -> Bool
(MemberRestrictionStatus -> MemberRestrictionStatus -> Bool)
-> (MemberRestrictionStatus -> MemberRestrictionStatus -> Bool)
-> Eq MemberRestrictionStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MemberRestrictionStatus -> MemberRestrictionStatus -> Bool
== :: MemberRestrictionStatus -> MemberRestrictionStatus -> Bool
$c/= :: MemberRestrictionStatus -> MemberRestrictionStatus -> Bool
/= :: MemberRestrictionStatus -> MemberRestrictionStatus -> Bool
Eq, Int -> MemberRestrictionStatus -> ShowS
[MemberRestrictionStatus] -> ShowS
MemberRestrictionStatus -> String
(Int -> MemberRestrictionStatus -> ShowS)
-> (MemberRestrictionStatus -> String)
-> ([MemberRestrictionStatus] -> ShowS)
-> Show MemberRestrictionStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MemberRestrictionStatus -> ShowS
showsPrec :: Int -> MemberRestrictionStatus -> ShowS
$cshow :: MemberRestrictionStatus -> String
show :: MemberRestrictionStatus -> String
$cshowList :: [MemberRestrictionStatus] -> ShowS
showList :: [MemberRestrictionStatus] -> ShowS
Show)
instance FromField MemberRestrictionStatus where fromField :: FieldParser MemberRestrictionStatus
fromField = (ByteString -> Either String MemberRestrictionStatus)
-> FieldParser MemberRestrictionStatus
forall k.
Typeable k =>
(ByteString -> Either String k) -> FieldParser k
blobFieldDecoder ByteString -> Either String MemberRestrictionStatus
forall a. StrEncoding a => ByteString -> Either String a
strDecode
instance ToField MemberRestrictionStatus where toField :: MemberRestrictionStatus -> SQLData
toField = ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (ByteString -> SQLData)
-> (MemberRestrictionStatus -> ByteString)
-> MemberRestrictionStatus
-> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MemberRestrictionStatus -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode
instance StrEncoding MemberRestrictionStatus where
strEncode :: MemberRestrictionStatus -> ByteString
strEncode = \case
MemberRestrictionStatus
MRSBlocked -> ByteString
"blocked"
MemberRestrictionStatus
MRSUnrestricted -> ByteString
"unrestricted"
MRSUnknown Text
tag -> Text -> ByteString
encodeUtf8 Text
tag
strDecode :: ByteString -> Either String MemberRestrictionStatus
strDecode ByteString
s = MemberRestrictionStatus -> Either String MemberRestrictionStatus
forall a b. b -> Either a b
Right (MemberRestrictionStatus -> Either String MemberRestrictionStatus)
-> MemberRestrictionStatus -> Either String MemberRestrictionStatus
forall a b. (a -> b) -> a -> b
$ case ByteString
s of
ByteString
"blocked" -> MemberRestrictionStatus
MRSBlocked
ByteString
"unrestricted" -> MemberRestrictionStatus
MRSUnrestricted
ByteString
tag -> Text -> MemberRestrictionStatus
MRSUnknown (Text -> MemberRestrictionStatus)
-> Text -> MemberRestrictionStatus
forall a b. (a -> b) -> a -> b
$ ByteString -> Text
safeDecodeUtf8 ByteString
tag
strP :: Parser MemberRestrictionStatus
strP = ByteString -> Either String MemberRestrictionStatus
forall a. StrEncoding a => ByteString -> Either String a
strDecode (ByteString -> Either String MemberRestrictionStatus)
-> Parser ByteString ByteString -> Parser MemberRestrictionStatus
forall (m :: * -> *) a b.
MonadFail m =>
(a -> Either String b) -> m a -> m b
<$?> Parser ByteString ByteString
A.takeByteString
instance FromJSON MemberRestrictionStatus where
parseJSON :: Value -> Parser MemberRestrictionStatus
parseJSON = String -> Value -> Parser MemberRestrictionStatus
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"MemberRestrictionStatus"
instance ToJSON MemberRestrictionStatus where
toJSON :: MemberRestrictionStatus -> Value
toJSON = MemberRestrictionStatus -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: MemberRestrictionStatus -> Encoding
toEncoding = MemberRestrictionStatus -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
mrsBlocked :: MemberRestrictionStatus -> Bool
mrsBlocked :: MemberRestrictionStatus -> Bool
mrsBlocked = \case
MemberRestrictionStatus
MRSBlocked -> Bool
True
MemberRestrictionStatus
_ -> Bool
False
data MemberRestrictions = MemberRestrictions
{ MemberRestrictions -> MemberRestrictionStatus
restriction :: MemberRestrictionStatus
}
deriving (MemberRestrictions -> MemberRestrictions -> Bool
(MemberRestrictions -> MemberRestrictions -> Bool)
-> (MemberRestrictions -> MemberRestrictions -> Bool)
-> Eq MemberRestrictions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MemberRestrictions -> MemberRestrictions -> Bool
== :: MemberRestrictions -> MemberRestrictions -> Bool
$c/= :: MemberRestrictions -> MemberRestrictions -> Bool
/= :: MemberRestrictions -> MemberRestrictions -> Bool
Eq, Int -> MemberRestrictions -> ShowS
[MemberRestrictions] -> ShowS
MemberRestrictions -> String
(Int -> MemberRestrictions -> ShowS)
-> (MemberRestrictions -> String)
-> ([MemberRestrictions] -> ShowS)
-> Show MemberRestrictions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MemberRestrictions -> ShowS
showsPrec :: Int -> MemberRestrictions -> ShowS
$cshow :: MemberRestrictions -> String
show :: MemberRestrictions -> String
$cshowList :: [MemberRestrictions] -> ShowS
showList :: [MemberRestrictions] -> ShowS
Show)
memberRestrictions :: GroupMember -> Maybe MemberRestrictions
memberRestrictions :: GroupMember -> Maybe MemberRestrictions
memberRestrictions GroupMember
m
| GroupMember -> Bool
blockedByAdmin GroupMember
m = MemberRestrictions -> Maybe MemberRestrictions
forall a. a -> Maybe a
Just MemberRestrictions {restriction :: MemberRestrictionStatus
restriction = MemberRestrictionStatus
MRSBlocked}
| Bool
otherwise = Maybe MemberRestrictions
forall a. Maybe a
Nothing
data ReceivedGroupInvitation = ReceivedGroupInvitation
{ ReceivedGroupInvitation -> GroupMember
fromMember :: GroupMember,
ReceivedGroupInvitation -> ConnReqInvitation
connRequest :: ConnReqInvitation,
ReceivedGroupInvitation -> GroupInfo
groupInfo :: GroupInfo
}
deriving (ReceivedGroupInvitation -> ReceivedGroupInvitation -> Bool
(ReceivedGroupInvitation -> ReceivedGroupInvitation -> Bool)
-> (ReceivedGroupInvitation -> ReceivedGroupInvitation -> Bool)
-> Eq ReceivedGroupInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReceivedGroupInvitation -> ReceivedGroupInvitation -> Bool
== :: ReceivedGroupInvitation -> ReceivedGroupInvitation -> Bool
$c/= :: ReceivedGroupInvitation -> ReceivedGroupInvitation -> Bool
/= :: ReceivedGroupInvitation -> ReceivedGroupInvitation -> Bool
Eq, Int -> ReceivedGroupInvitation -> ShowS
[ReceivedGroupInvitation] -> ShowS
ReceivedGroupInvitation -> String
(Int -> ReceivedGroupInvitation -> ShowS)
-> (ReceivedGroupInvitation -> String)
-> ([ReceivedGroupInvitation] -> ShowS)
-> Show ReceivedGroupInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReceivedGroupInvitation -> ShowS
showsPrec :: Int -> ReceivedGroupInvitation -> ShowS
$cshow :: ReceivedGroupInvitation -> String
show :: ReceivedGroupInvitation -> String
$cshowList :: [ReceivedGroupInvitation] -> ShowS
showList :: [ReceivedGroupInvitation] -> ShowS
Show)
type GroupMemberId = Int64
data GroupMember = GroupMember
{ GroupMember -> CommandId
groupMemberId :: GroupMemberId,
GroupMember -> CommandId
groupId :: GroupId,
GroupMember -> CommandId
indexInGroup :: Int64,
GroupMember -> MemberId
memberId :: MemberId,
GroupMember -> GroupMemberRole
memberRole :: GroupMemberRole,
GroupMember -> GroupMemberCategory
memberCategory :: GroupMemberCategory,
GroupMember -> GroupMemberStatus
memberStatus :: GroupMemberStatus,
GroupMember -> GroupMemberSettings
memberSettings :: GroupMemberSettings,
GroupMember -> Bool
blockedByAdmin :: Bool,
GroupMember -> InvitedBy
invitedBy :: InvitedBy,
GroupMember -> Maybe CommandId
invitedByGroupMemberId :: Maybe GroupMemberId,
GroupMember -> Text
localDisplayName :: ContactName,
GroupMember -> LocalProfile
memberProfile :: LocalProfile,
GroupMember -> Maybe CommandId
memberContactId :: Maybe ContactId,
GroupMember -> CommandId
memberContactProfileId :: ProfileId,
GroupMember -> Maybe Connection
activeConn :: Maybe Connection,
GroupMember -> VersionRangeChat
memberChatVRange :: VersionRangeChat,
GroupMember -> UTCTime
createdAt :: UTCTime,
GroupMember -> UTCTime
updatedAt :: UTCTime,
GroupMember -> Maybe GroupSupportChat
supportChat :: Maybe GroupSupportChat
}
deriving (GroupMember -> GroupMember -> Bool
(GroupMember -> GroupMember -> Bool)
-> (GroupMember -> GroupMember -> Bool) -> Eq GroupMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupMember -> GroupMember -> Bool
== :: GroupMember -> GroupMember -> Bool
$c/= :: GroupMember -> GroupMember -> Bool
/= :: GroupMember -> GroupMember -> Bool
Eq, Int -> GroupMember -> ShowS
[GroupMember] -> ShowS
GroupMember -> String
(Int -> GroupMember -> ShowS)
-> (GroupMember -> String)
-> ([GroupMember] -> ShowS)
-> Show GroupMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupMember -> ShowS
showsPrec :: Int -> GroupMember -> ShowS
$cshow :: GroupMember -> String
show :: GroupMember -> String
$cshowList :: [GroupMember] -> ShowS
showList :: [GroupMember] -> ShowS
Show)
data GroupSupportChat = GroupSupportChat
{ GroupSupportChat -> UTCTime
chatTs :: UTCTime,
GroupSupportChat -> CommandId
unread :: Int64,
GroupSupportChat -> CommandId
memberAttention :: Int64,
GroupSupportChat -> CommandId
mentions :: Int64,
GroupSupportChat -> Maybe UTCTime
lastMsgFromMemberTs :: Maybe UTCTime
}
deriving (GroupSupportChat -> GroupSupportChat -> Bool
(GroupSupportChat -> GroupSupportChat -> Bool)
-> (GroupSupportChat -> GroupSupportChat -> Bool)
-> Eq GroupSupportChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupSupportChat -> GroupSupportChat -> Bool
== :: GroupSupportChat -> GroupSupportChat -> Bool
$c/= :: GroupSupportChat -> GroupSupportChat -> Bool
/= :: GroupSupportChat -> GroupSupportChat -> Bool
Eq, Int -> GroupSupportChat -> ShowS
[GroupSupportChat] -> ShowS
GroupSupportChat -> String
(Int -> GroupSupportChat -> ShowS)
-> (GroupSupportChat -> String)
-> ([GroupSupportChat] -> ShowS)
-> Show GroupSupportChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupSupportChat -> ShowS
showsPrec :: Int -> GroupSupportChat -> ShowS
$cshow :: GroupSupportChat -> String
show :: GroupSupportChat -> String
$cshowList :: [GroupSupportChat] -> ShowS
showList :: [GroupSupportChat] -> ShowS
Show)
gmRequiresAttention :: GroupMember -> Bool
gmRequiresAttention :: GroupMember -> Bool
gmRequiresAttention m :: GroupMember
m@GroupMember {Maybe GroupSupportChat
supportChat :: GroupMember -> Maybe GroupSupportChat
supportChat :: Maybe GroupSupportChat
supportChat} =
GroupMember -> Bool
memberPending GroupMember
m Bool -> Bool -> Bool
|| Bool
-> (GroupSupportChat -> Bool) -> Maybe GroupSupportChat -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False GroupSupportChat -> Bool
supportChatAttention Maybe GroupSupportChat
supportChat
where
supportChatAttention :: GroupSupportChat -> Bool
supportChatAttention GroupSupportChat {CommandId
memberAttention :: GroupSupportChat -> CommandId
memberAttention :: CommandId
memberAttention, CommandId
mentions :: GroupSupportChat -> CommandId
mentions :: CommandId
mentions} =
CommandId
memberAttention CommandId -> CommandId -> Bool
forall a. Ord a => a -> a -> Bool
> CommandId
0 Bool -> Bool -> Bool
|| CommandId
mentions CommandId -> CommandId -> Bool
forall a. Ord a => a -> a -> Bool
> CommandId
0
data GroupMemberRef = GroupMemberRef {GroupMemberRef -> CommandId
groupMemberId :: Int64, GroupMemberRef -> Profile
profile :: Profile}
deriving (GroupMemberRef -> GroupMemberRef -> Bool
(GroupMemberRef -> GroupMemberRef -> Bool)
-> (GroupMemberRef -> GroupMemberRef -> Bool) -> Eq GroupMemberRef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupMemberRef -> GroupMemberRef -> Bool
== :: GroupMemberRef -> GroupMemberRef -> Bool
$c/= :: GroupMemberRef -> GroupMemberRef -> Bool
/= :: GroupMemberRef -> GroupMemberRef -> Bool
Eq, Int -> GroupMemberRef -> ShowS
[GroupMemberRef] -> ShowS
GroupMemberRef -> String
(Int -> GroupMemberRef -> ShowS)
-> (GroupMemberRef -> String)
-> ([GroupMemberRef] -> ShowS)
-> Show GroupMemberRef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupMemberRef -> ShowS
showsPrec :: Int -> GroupMemberRef -> ShowS
$cshow :: GroupMemberRef -> String
show :: GroupMemberRef -> String
$cshowList :: [GroupMemberRef] -> ShowS
showList :: [GroupMemberRef] -> ShowS
Show)
groupMemberRef :: GroupMember -> GroupMemberRef
groupMemberRef :: GroupMember -> GroupMemberRef
groupMemberRef GroupMember {CommandId
groupMemberId :: GroupMember -> CommandId
groupMemberId :: CommandId
groupMemberId, memberProfile :: GroupMember -> LocalProfile
memberProfile = LocalProfile
p} =
GroupMemberRef {CommandId
groupMemberId :: CommandId
groupMemberId :: CommandId
groupMemberId, profile :: Profile
profile = LocalProfile -> Profile
fromLocalProfile LocalProfile
p}
isMemberRelay :: GroupMember -> Bool
isMemberRelay :: GroupMember -> Bool
isMemberRelay GroupMember {GroupMemberRole
memberRole :: GroupMember -> GroupMemberRole
memberRole :: GroupMemberRole
memberRole} = GroupMemberRole
memberRole GroupMemberRole -> GroupMemberRole -> Bool
forall a. Eq a => a -> a -> Bool
== GroupMemberRole
GRAdmin
memberConn :: GroupMember -> Maybe Connection
memberConn :: GroupMember -> Maybe Connection
memberConn GroupMember {Maybe Connection
activeConn :: GroupMember -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = Maybe Connection
activeConn
memberConnId :: GroupMember -> Maybe ConnId
memberConnId :: GroupMember -> Maybe ByteString
memberConnId GroupMember {Maybe Connection
activeConn :: GroupMember -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = Connection -> ByteString
aConnId (Connection -> ByteString) -> Maybe Connection -> Maybe ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Connection
activeConn
sameMemberId :: MemberId -> GroupMember -> Bool
sameMemberId :: MemberId -> GroupMember -> Bool
sameMemberId MemberId
memId GroupMember {MemberId
memberId :: GroupMember -> MemberId
memberId :: MemberId
memberId} = MemberId
memId MemberId -> MemberId -> Bool
forall a. Eq a => a -> a -> Bool
== MemberId
memberId
memberChatVRange' :: GroupMember -> VersionRangeChat
memberChatVRange' :: GroupMember -> VersionRangeChat
memberChatVRange' GroupMember {Maybe Connection
activeConn :: GroupMember -> Maybe Connection
activeConn :: Maybe Connection
activeConn, VersionRangeChat
memberChatVRange :: GroupMember -> VersionRangeChat
memberChatVRange :: VersionRangeChat
memberChatVRange} = case Maybe Connection
activeConn of
Just Connection {VersionRangeChat
peerChatVRange :: VersionRangeChat
peerChatVRange :: Connection -> VersionRangeChat
peerChatVRange} -> VersionRangeChat
peerChatVRange
Maybe Connection
Nothing -> VersionRangeChat
memberChatVRange
supportsVersion :: GroupMember -> VersionChat -> Bool
supportsVersion :: GroupMember -> Version ChatVersion -> Bool
supportsVersion GroupMember
m Version ChatVersion
v = VersionRangeChat -> Version ChatVersion
forall v. VersionRange v -> Version v
maxVersion (GroupMember -> VersionRangeChat
memberChatVRange' GroupMember
m) Version ChatVersion -> Version ChatVersion -> Bool
forall a. Ord a => a -> a -> Bool
>= Version ChatVersion
v
groupMemberId' :: GroupMember -> GroupMemberId
groupMemberId' :: GroupMember -> CommandId
groupMemberId' GroupMember {CommandId
groupMemberId :: GroupMember -> CommandId
groupMemberId :: CommandId
groupMemberId} = CommandId
groupMemberId
memberId' :: GroupMember -> MemberId
memberId' :: GroupMember -> MemberId
memberId' GroupMember {MemberId
memberId :: GroupMember -> MemberId
memberId :: MemberId
memberId} = MemberId
memberId
memberIncognito :: GroupMember -> IncognitoEnabled
memberIncognito :: GroupMember -> Bool
memberIncognito GroupMember {LocalProfile
memberProfile :: GroupMember -> LocalProfile
memberProfile :: LocalProfile
memberProfile, CommandId
memberContactProfileId :: GroupMember -> CommandId
memberContactProfileId :: CommandId
memberContactProfileId} = LocalProfile -> CommandId
localProfileId LocalProfile
memberProfile CommandId -> CommandId -> Bool
forall a. Eq a => a -> a -> Bool
/= CommandId
memberContactProfileId
incognitoMembership :: GroupInfo -> IncognitoEnabled
incognitoMembership :: GroupInfo -> Bool
incognitoMembership GroupInfo {GroupMember
membership :: GroupInfo -> GroupMember
membership :: GroupMember
membership} = GroupMember -> Bool
memberIncognito GroupMember
membership
incognitoMembershipProfile :: GroupInfo -> Maybe LocalProfile
incognitoMembershipProfile :: GroupInfo -> Maybe LocalProfile
incognitoMembershipProfile GroupInfo {membership :: GroupInfo -> GroupMember
membership = m :: GroupMember
m@GroupMember {LocalProfile
memberProfile :: GroupMember -> LocalProfile
memberProfile :: LocalProfile
memberProfile}}
| GroupMember -> Bool
memberIncognito GroupMember
m = LocalProfile -> Maybe LocalProfile
forall a. a -> Maybe a
Just LocalProfile
memberProfile
| Bool
otherwise = Maybe LocalProfile
forall a. Maybe a
Nothing
memberSecurityCode :: GroupMember -> Maybe SecurityCode
memberSecurityCode :: GroupMember -> Maybe SecurityCode
memberSecurityCode GroupMember {Maybe Connection
activeConn :: GroupMember -> Maybe Connection
activeConn :: Maybe Connection
activeConn} = Connection -> Maybe SecurityCode
connectionCode (Connection -> Maybe SecurityCode)
-> Maybe Connection -> Maybe SecurityCode
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Maybe Connection
activeConn
memberBlocked :: GroupMember -> Bool
memberBlocked :: GroupMember -> Bool
memberBlocked GroupMember
m = GroupMember -> Bool
blockedByAdmin GroupMember
m Bool -> Bool -> Bool
|| Bool -> Bool
not (GroupMemberSettings -> Bool
showMessages (GroupMemberSettings -> Bool) -> GroupMemberSettings -> Bool
forall a b. (a -> b) -> a -> b
$ GroupMember -> GroupMemberSettings
memberSettings GroupMember
m)
data NewGroupMember = NewGroupMember
{ NewGroupMember -> MemberInfo
memInfo :: MemberInfo,
NewGroupMember -> GroupMemberCategory
memCategory :: GroupMemberCategory,
NewGroupMember -> GroupMemberStatus
memStatus :: GroupMemberStatus,
NewGroupMember -> Maybe MemberRestrictionStatus
memRestriction :: Maybe MemberRestrictionStatus,
NewGroupMember -> InvitedBy
memInvitedBy :: InvitedBy,
NewGroupMember -> Maybe CommandId
memInvitedByGroupMemberId :: Maybe GroupMemberId,
NewGroupMember -> Text
localDisplayName :: ContactName,
NewGroupMember -> CommandId
memProfileId :: Int64,
NewGroupMember -> Maybe CommandId
memContactId :: Maybe Int64
}
newtype MemberId = MemberId {MemberId -> ByteString
unMemberId :: ByteString}
deriving (MemberId -> MemberId -> Bool
(MemberId -> MemberId -> Bool)
-> (MemberId -> MemberId -> Bool) -> Eq MemberId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MemberId -> MemberId -> Bool
== :: MemberId -> MemberId -> Bool
$c/= :: MemberId -> MemberId -> Bool
/= :: MemberId -> MemberId -> Bool
Eq, Eq MemberId
Eq MemberId =>
(MemberId -> MemberId -> Ordering)
-> (MemberId -> MemberId -> Bool)
-> (MemberId -> MemberId -> Bool)
-> (MemberId -> MemberId -> Bool)
-> (MemberId -> MemberId -> Bool)
-> (MemberId -> MemberId -> MemberId)
-> (MemberId -> MemberId -> MemberId)
-> Ord MemberId
MemberId -> MemberId -> Bool
MemberId -> MemberId -> Ordering
MemberId -> MemberId -> MemberId
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: MemberId -> MemberId -> Ordering
compare :: MemberId -> MemberId -> Ordering
$c< :: MemberId -> MemberId -> Bool
< :: MemberId -> MemberId -> Bool
$c<= :: MemberId -> MemberId -> Bool
<= :: MemberId -> MemberId -> Bool
$c> :: MemberId -> MemberId -> Bool
> :: MemberId -> MemberId -> Bool
$c>= :: MemberId -> MemberId -> Bool
>= :: MemberId -> MemberId -> Bool
$cmax :: MemberId -> MemberId -> MemberId
max :: MemberId -> MemberId -> MemberId
$cmin :: MemberId -> MemberId -> MemberId
min :: MemberId -> MemberId -> MemberId
Ord, Int -> MemberId -> ShowS
[MemberId] -> ShowS
MemberId -> String
(Int -> MemberId -> ShowS)
-> (MemberId -> String) -> ([MemberId] -> ShowS) -> Show MemberId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MemberId -> ShowS
showsPrec :: Int -> MemberId -> ShowS
$cshow :: MemberId -> String
show :: MemberId -> String
$cshowList :: [MemberId] -> ShowS
showList :: [MemberId] -> ShowS
Show)
deriving newtype (FieldParser MemberId
FieldParser MemberId -> FromField MemberId
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser MemberId
fromField :: FieldParser MemberId
FromField)
instance ToField MemberId where toField :: MemberId -> SQLData
toField (MemberId ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding MemberId where
strEncode :: MemberId -> ByteString
strEncode (MemberId ByteString
m) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
m
strDecode :: ByteString -> Either String MemberId
strDecode ByteString
s = ByteString -> MemberId
MemberId (ByteString -> MemberId)
-> Either String ByteString -> Either String MemberId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser MemberId
strP = ByteString -> MemberId
MemberId (ByteString -> MemberId)
-> Parser ByteString ByteString -> Parser MemberId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON MemberId where
parseJSON :: Value -> Parser MemberId
parseJSON = String -> Value -> Parser MemberId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"MemberId"
instance ToJSON MemberId where
toJSON :: MemberId -> Value
toJSON = MemberId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: MemberId -> Encoding
toEncoding = MemberId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
nameFromMemberId :: MemberId -> ContactName
nameFromMemberId :: MemberId -> Text
nameFromMemberId = Int -> Text -> Text
T.take Int
7 (Text -> Text) -> (MemberId -> Text) -> MemberId -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
safeDecodeUtf8 (ByteString -> Text)
-> (MemberId -> ByteString) -> MemberId -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
B64.encode (ByteString -> ByteString)
-> (MemberId -> ByteString) -> MemberId -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MemberId -> ByteString
unMemberId
data InvitedBy = IBContact {InvitedBy -> CommandId
byContactId :: Int64} | IBUser | IBUnknown
deriving (InvitedBy -> InvitedBy -> Bool
(InvitedBy -> InvitedBy -> Bool)
-> (InvitedBy -> InvitedBy -> Bool) -> Eq InvitedBy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InvitedBy -> InvitedBy -> Bool
== :: InvitedBy -> InvitedBy -> Bool
$c/= :: InvitedBy -> InvitedBy -> Bool
/= :: InvitedBy -> InvitedBy -> Bool
Eq, Int -> InvitedBy -> ShowS
[InvitedBy] -> ShowS
InvitedBy -> String
(Int -> InvitedBy -> ShowS)
-> (InvitedBy -> String)
-> ([InvitedBy] -> ShowS)
-> Show InvitedBy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InvitedBy -> ShowS
showsPrec :: Int -> InvitedBy -> ShowS
$cshow :: InvitedBy -> String
show :: InvitedBy -> String
$cshowList :: [InvitedBy] -> ShowS
showList :: [InvitedBy] -> ShowS
Show)
toInvitedBy :: Int64 -> Maybe Int64 -> InvitedBy
toInvitedBy :: CommandId -> Maybe CommandId -> InvitedBy
toInvitedBy CommandId
userCtId (Just CommandId
ctId)
| CommandId
userCtId CommandId -> CommandId -> Bool
forall a. Eq a => a -> a -> Bool
== CommandId
ctId = InvitedBy
IBUser
| Bool
otherwise = CommandId -> InvitedBy
IBContact CommandId
ctId
toInvitedBy CommandId
_ Maybe CommandId
Nothing = InvitedBy
IBUnknown
fromInvitedBy :: Int64 -> InvitedBy -> Maybe Int64
fromInvitedBy :: CommandId -> InvitedBy -> Maybe CommandId
fromInvitedBy CommandId
userCtId = \case
InvitedBy
IBUnknown -> Maybe CommandId
forall a. Maybe a
Nothing
IBContact CommandId
ctId -> CommandId -> Maybe CommandId
forall a. a -> Maybe a
Just CommandId
ctId
InvitedBy
IBUser -> CommandId -> Maybe CommandId
forall a. a -> Maybe a
Just CommandId
userCtId
data GroupMemberSettings = GroupMemberSettings
{ GroupMemberSettings -> Bool
showMessages :: Bool
}
deriving (GroupMemberSettings -> GroupMemberSettings -> Bool
(GroupMemberSettings -> GroupMemberSettings -> Bool)
-> (GroupMemberSettings -> GroupMemberSettings -> Bool)
-> Eq GroupMemberSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupMemberSettings -> GroupMemberSettings -> Bool
== :: GroupMemberSettings -> GroupMemberSettings -> Bool
$c/= :: GroupMemberSettings -> GroupMemberSettings -> Bool
/= :: GroupMemberSettings -> GroupMemberSettings -> Bool
Eq, Int -> GroupMemberSettings -> ShowS
[GroupMemberSettings] -> ShowS
GroupMemberSettings -> String
(Int -> GroupMemberSettings -> ShowS)
-> (GroupMemberSettings -> String)
-> ([GroupMemberSettings] -> ShowS)
-> Show GroupMemberSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupMemberSettings -> ShowS
showsPrec :: Int -> GroupMemberSettings -> ShowS
$cshow :: GroupMemberSettings -> String
show :: GroupMemberSettings -> String
$cshowList :: [GroupMemberSettings] -> ShowS
showList :: [GroupMemberSettings] -> ShowS
Show)
defaultMemberSettings :: GroupMemberSettings
defaultMemberSettings :: GroupMemberSettings
defaultMemberSettings = GroupMemberSettings {showMessages :: Bool
showMessages = Bool
True}
newtype Probe = Probe {Probe -> ByteString
unProbe :: ByteString}
deriving (Probe -> Probe -> Bool
(Probe -> Probe -> Bool) -> (Probe -> Probe -> Bool) -> Eq Probe
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Probe -> Probe -> Bool
== :: Probe -> Probe -> Bool
$c/= :: Probe -> Probe -> Bool
/= :: Probe -> Probe -> Bool
Eq, Int -> Probe -> ShowS
[Probe] -> ShowS
Probe -> String
(Int -> Probe -> ShowS)
-> (Probe -> String) -> ([Probe] -> ShowS) -> Show Probe
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Probe -> ShowS
showsPrec :: Int -> Probe -> ShowS
$cshow :: Probe -> String
show :: Probe -> String
$cshowList :: [Probe] -> ShowS
showList :: [Probe] -> ShowS
Show)
instance StrEncoding Probe where
strEncode :: Probe -> ByteString
strEncode (Probe ByteString
p) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
p
strDecode :: ByteString -> Either String Probe
strDecode ByteString
s = ByteString -> Probe
Probe (ByteString -> Probe)
-> Either String ByteString -> Either String Probe
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser Probe
strP = ByteString -> Probe
Probe (ByteString -> Probe)
-> Parser ByteString ByteString -> Parser Probe
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON Probe where
parseJSON :: Value -> Parser Probe
parseJSON = String -> Value -> Parser Probe
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"Probe"
instance ToJSON Probe where
toJSON :: Probe -> Value
toJSON = Probe -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: Probe -> Encoding
toEncoding = Probe -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
newtype ProbeHash = ProbeHash {ProbeHash -> ByteString
unProbeHash :: ByteString}
deriving (ProbeHash -> ProbeHash -> Bool
(ProbeHash -> ProbeHash -> Bool)
-> (ProbeHash -> ProbeHash -> Bool) -> Eq ProbeHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProbeHash -> ProbeHash -> Bool
== :: ProbeHash -> ProbeHash -> Bool
$c/= :: ProbeHash -> ProbeHash -> Bool
/= :: ProbeHash -> ProbeHash -> Bool
Eq, Int -> ProbeHash -> ShowS
[ProbeHash] -> ShowS
ProbeHash -> String
(Int -> ProbeHash -> ShowS)
-> (ProbeHash -> String)
-> ([ProbeHash] -> ShowS)
-> Show ProbeHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProbeHash -> ShowS
showsPrec :: Int -> ProbeHash -> ShowS
$cshow :: ProbeHash -> String
show :: ProbeHash -> String
$cshowList :: [ProbeHash] -> ShowS
showList :: [ProbeHash] -> ShowS
Show)
instance StrEncoding ProbeHash where
strEncode :: ProbeHash -> ByteString
strEncode (ProbeHash ByteString
p) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
p
strDecode :: ByteString -> Either String ProbeHash
strDecode ByteString
s = ByteString -> ProbeHash
ProbeHash (ByteString -> ProbeHash)
-> Either String ByteString -> Either String ProbeHash
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser ProbeHash
strP = ByteString -> ProbeHash
ProbeHash (ByteString -> ProbeHash)
-> Parser ByteString ByteString -> Parser ProbeHash
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON ProbeHash where
parseJSON :: Value -> Parser ProbeHash
parseJSON = String -> Value -> Parser ProbeHash
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"ProbeHash"
instance ToJSON ProbeHash where
toJSON :: ProbeHash -> Value
toJSON = ProbeHash -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: ProbeHash -> Encoding
toEncoding = ProbeHash -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
data GroupMemberCategory
= GCUserMember
| GCInviteeMember
| GCHostMember
| GCPreMember
| GCPostMember
deriving (GroupMemberCategory -> GroupMemberCategory -> Bool
(GroupMemberCategory -> GroupMemberCategory -> Bool)
-> (GroupMemberCategory -> GroupMemberCategory -> Bool)
-> Eq GroupMemberCategory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupMemberCategory -> GroupMemberCategory -> Bool
== :: GroupMemberCategory -> GroupMemberCategory -> Bool
$c/= :: GroupMemberCategory -> GroupMemberCategory -> Bool
/= :: GroupMemberCategory -> GroupMemberCategory -> Bool
Eq, Int -> GroupMemberCategory -> ShowS
[GroupMemberCategory] -> ShowS
GroupMemberCategory -> String
(Int -> GroupMemberCategory -> ShowS)
-> (GroupMemberCategory -> String)
-> ([GroupMemberCategory] -> ShowS)
-> Show GroupMemberCategory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupMemberCategory -> ShowS
showsPrec :: Int -> GroupMemberCategory -> ShowS
$cshow :: GroupMemberCategory -> String
show :: GroupMemberCategory -> String
$cshowList :: [GroupMemberCategory] -> ShowS
showList :: [GroupMemberCategory] -> ShowS
Show)
instance FromField GroupMemberCategory where fromField :: FieldParser GroupMemberCategory
fromField = (Text -> Maybe GroupMemberCategory)
-> FieldParser GroupMemberCategory
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe GroupMemberCategory
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField GroupMemberCategory where toField :: GroupMemberCategory -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (GroupMemberCategory -> Text) -> GroupMemberCategory -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberCategory -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromJSON GroupMemberCategory where
parseJSON :: Value -> Parser GroupMemberCategory
parseJSON = String -> Value -> Parser GroupMemberCategory
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"GroupMemberCategory"
instance ToJSON GroupMemberCategory where
toJSON :: GroupMemberCategory -> Value
toJSON = Text -> Value
J.String (Text -> Value)
-> (GroupMemberCategory -> Text) -> GroupMemberCategory -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberCategory -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: GroupMemberCategory -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding)
-> (GroupMemberCategory -> Text) -> GroupMemberCategory -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberCategory -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding GroupMemberCategory where
textDecode :: Text -> Maybe GroupMemberCategory
textDecode = \case
Text
"user" -> GroupMemberCategory -> Maybe GroupMemberCategory
forall a. a -> Maybe a
Just GroupMemberCategory
GCUserMember
Text
"invitee" -> GroupMemberCategory -> Maybe GroupMemberCategory
forall a. a -> Maybe a
Just GroupMemberCategory
GCInviteeMember
Text
"host" -> GroupMemberCategory -> Maybe GroupMemberCategory
forall a. a -> Maybe a
Just GroupMemberCategory
GCHostMember
Text
"pre" -> GroupMemberCategory -> Maybe GroupMemberCategory
forall a. a -> Maybe a
Just GroupMemberCategory
GCPreMember
Text
"post" -> GroupMemberCategory -> Maybe GroupMemberCategory
forall a. a -> Maybe a
Just GroupMemberCategory
GCPostMember
Text
_ -> Maybe GroupMemberCategory
forall a. Maybe a
Nothing
textEncode :: GroupMemberCategory -> Text
textEncode = \case
GroupMemberCategory
GCUserMember -> Text
"user"
GroupMemberCategory
GCInviteeMember -> Text
"invitee"
GroupMemberCategory
GCHostMember -> Text
"host"
GroupMemberCategory
GCPreMember -> Text
"pre"
GroupMemberCategory
GCPostMember -> Text
"post"
data GroupMemberStatus
= GSMemRejected
| GSMemRemoved
| GSMemLeft
| GSMemGroupDeleted
| GSMemUnknown
| GSMemInvited
| GSMemPendingApproval
| GSMemPendingReview
| GSMemIntroduced
| GSMemIntroInvited
| GSMemAccepted
| GSMemAnnounced
| GSMemConnected
| GSMemComplete
| GSMemCreator
deriving (GroupMemberStatus -> GroupMemberStatus -> Bool
(GroupMemberStatus -> GroupMemberStatus -> Bool)
-> (GroupMemberStatus -> GroupMemberStatus -> Bool)
-> Eq GroupMemberStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupMemberStatus -> GroupMemberStatus -> Bool
== :: GroupMemberStatus -> GroupMemberStatus -> Bool
$c/= :: GroupMemberStatus -> GroupMemberStatus -> Bool
/= :: GroupMemberStatus -> GroupMemberStatus -> Bool
Eq, Int -> GroupMemberStatus -> ShowS
[GroupMemberStatus] -> ShowS
GroupMemberStatus -> String
(Int -> GroupMemberStatus -> ShowS)
-> (GroupMemberStatus -> String)
-> ([GroupMemberStatus] -> ShowS)
-> Show GroupMemberStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupMemberStatus -> ShowS
showsPrec :: Int -> GroupMemberStatus -> ShowS
$cshow :: GroupMemberStatus -> String
show :: GroupMemberStatus -> String
$cshowList :: [GroupMemberStatus] -> ShowS
showList :: [GroupMemberStatus] -> ShowS
Show, Eq GroupMemberStatus
Eq GroupMemberStatus =>
(GroupMemberStatus -> GroupMemberStatus -> Ordering)
-> (GroupMemberStatus -> GroupMemberStatus -> Bool)
-> (GroupMemberStatus -> GroupMemberStatus -> Bool)
-> (GroupMemberStatus -> GroupMemberStatus -> Bool)
-> (GroupMemberStatus -> GroupMemberStatus -> Bool)
-> (GroupMemberStatus -> GroupMemberStatus -> GroupMemberStatus)
-> (GroupMemberStatus -> GroupMemberStatus -> GroupMemberStatus)
-> Ord GroupMemberStatus
GroupMemberStatus -> GroupMemberStatus -> Bool
GroupMemberStatus -> GroupMemberStatus -> Ordering
GroupMemberStatus -> GroupMemberStatus -> GroupMemberStatus
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: GroupMemberStatus -> GroupMemberStatus -> Ordering
compare :: GroupMemberStatus -> GroupMemberStatus -> Ordering
$c< :: GroupMemberStatus -> GroupMemberStatus -> Bool
< :: GroupMemberStatus -> GroupMemberStatus -> Bool
$c<= :: GroupMemberStatus -> GroupMemberStatus -> Bool
<= :: GroupMemberStatus -> GroupMemberStatus -> Bool
$c> :: GroupMemberStatus -> GroupMemberStatus -> Bool
> :: GroupMemberStatus -> GroupMemberStatus -> Bool
$c>= :: GroupMemberStatus -> GroupMemberStatus -> Bool
>= :: GroupMemberStatus -> GroupMemberStatus -> Bool
$cmax :: GroupMemberStatus -> GroupMemberStatus -> GroupMemberStatus
max :: GroupMemberStatus -> GroupMemberStatus -> GroupMemberStatus
$cmin :: GroupMemberStatus -> GroupMemberStatus -> GroupMemberStatus
min :: GroupMemberStatus -> GroupMemberStatus -> GroupMemberStatus
Ord)
instance FromField GroupMemberStatus where fromField :: FieldParser GroupMemberStatus
fromField = (Text -> Maybe GroupMemberStatus) -> FieldParser GroupMemberStatus
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe GroupMemberStatus
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField GroupMemberStatus where toField :: GroupMemberStatus -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (GroupMemberStatus -> Text) -> GroupMemberStatus -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromJSON GroupMemberStatus where
parseJSON :: Value -> Parser GroupMemberStatus
parseJSON = String -> Value -> Parser GroupMemberStatus
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"GroupMemberStatus"
instance ToJSON GroupMemberStatus where
toJSON :: GroupMemberStatus -> Value
toJSON = Text -> Value
J.String (Text -> Value)
-> (GroupMemberStatus -> Text) -> GroupMemberStatus -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: GroupMemberStatus -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding)
-> (GroupMemberStatus -> Text) -> GroupMemberStatus -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
acceptanceToStatus :: Maybe GroupMemberAdmission -> GroupAcceptance -> GroupMemberStatus
acceptanceToStatus :: Maybe GroupMemberAdmission -> GroupAcceptance -> GroupMemberStatus
acceptanceToStatus Maybe GroupMemberAdmission
memberAdmission GroupAcceptance
groupAcceptance
| GroupAcceptance
groupAcceptance GroupAcceptance -> GroupAcceptance -> Bool
forall a. Eq a => a -> a -> Bool
== GroupAcceptance
GAPendingApproval = GroupMemberStatus
GSMemPendingApproval
| GroupAcceptance
groupAcceptance GroupAcceptance -> GroupAcceptance -> Bool
forall a. Eq a => a -> a -> Bool
== GroupAcceptance
GAPendingReview = GroupMemberStatus
GSMemPendingReview
| (Maybe GroupMemberAdmission
memberAdmission Maybe GroupMemberAdmission
-> (GroupMemberAdmission -> Maybe MemberCriteria)
-> Maybe MemberCriteria
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= GroupMemberAdmission -> Maybe MemberCriteria
review) Maybe MemberCriteria -> Maybe MemberCriteria -> Bool
forall a. Eq a => a -> a -> Bool
== MemberCriteria -> Maybe MemberCriteria
forall a. a -> Maybe a
Just MemberCriteria
MCAll = GroupMemberStatus
GSMemPendingReview
| Bool
otherwise = GroupMemberStatus
GSMemAccepted
memberActive :: GroupMember -> Bool
memberActive :: GroupMember -> Bool
memberActive GroupMember
m = case GroupMember -> GroupMemberStatus
memberStatus GroupMember
m of
GroupMemberStatus
GSMemRejected -> Bool
False
GroupMemberStatus
GSMemRemoved -> Bool
False
GroupMemberStatus
GSMemLeft -> Bool
False
GroupMemberStatus
GSMemGroupDeleted -> Bool
False
GroupMemberStatus
GSMemUnknown -> Bool
False
GroupMemberStatus
GSMemInvited -> Bool
False
GroupMemberStatus
GSMemPendingApproval -> Bool
True
GroupMemberStatus
GSMemPendingReview -> Bool
True
GroupMemberStatus
GSMemIntroduced -> Bool
False
GroupMemberStatus
GSMemIntroInvited -> Bool
False
GroupMemberStatus
GSMemAccepted -> Bool
False
GroupMemberStatus
GSMemAnnounced -> Bool
False
GroupMemberStatus
GSMemConnected -> Bool
True
GroupMemberStatus
GSMemComplete -> Bool
True
GroupMemberStatus
GSMemCreator -> Bool
True
memberCurrent :: GroupMember -> Bool
memberCurrent :: GroupMember -> Bool
memberCurrent = GroupMemberStatus -> Bool
memberCurrent' (GroupMemberStatus -> Bool)
-> (GroupMember -> GroupMemberStatus) -> GroupMember -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMember -> GroupMemberStatus
memberStatus
memberPending :: GroupMember -> Bool
memberPending :: GroupMember -> Bool
memberPending GroupMember
m = case GroupMember -> GroupMemberStatus
memberStatus GroupMember
m of
GroupMemberStatus
GSMemPendingApproval -> Bool
True
GroupMemberStatus
GSMemPendingReview -> Bool
True
GroupMemberStatus
_ -> Bool
False
memberCurrentOrPending :: GroupMember -> Bool
memberCurrentOrPending :: GroupMember -> Bool
memberCurrentOrPending GroupMember
m = GroupMember -> Bool
memberCurrent GroupMember
m Bool -> Bool -> Bool
|| GroupMember -> Bool
memberPending GroupMember
m
memberCurrent' :: GroupMemberStatus -> Bool
memberCurrent' :: GroupMemberStatus -> Bool
memberCurrent' = \case
GroupMemberStatus
GSMemRejected -> Bool
False
GroupMemberStatus
GSMemRemoved -> Bool
False
GroupMemberStatus
GSMemLeft -> Bool
False
GroupMemberStatus
GSMemGroupDeleted -> Bool
False
GroupMemberStatus
GSMemUnknown -> Bool
False
GroupMemberStatus
GSMemInvited -> Bool
False
GroupMemberStatus
GSMemPendingApproval -> Bool
False
GroupMemberStatus
GSMemPendingReview -> Bool
False
GroupMemberStatus
GSMemIntroduced -> Bool
True
GroupMemberStatus
GSMemIntroInvited -> Bool
True
GroupMemberStatus
GSMemAccepted -> Bool
True
GroupMemberStatus
GSMemAnnounced -> Bool
True
GroupMemberStatus
GSMemConnected -> Bool
True
GroupMemberStatus
GSMemComplete -> Bool
True
GroupMemberStatus
GSMemCreator -> Bool
True
memberRemoved :: GroupMember -> Bool
memberRemoved :: GroupMember -> Bool
memberRemoved GroupMember
m = case GroupMember -> GroupMemberStatus
memberStatus GroupMember
m of
GroupMemberStatus
GSMemRejected -> Bool
True
GroupMemberStatus
GSMemRemoved -> Bool
True
GroupMemberStatus
GSMemLeft -> Bool
True
GroupMemberStatus
GSMemGroupDeleted -> Bool
True
GroupMemberStatus
GSMemUnknown -> Bool
False
GroupMemberStatus
GSMemInvited -> Bool
False
GroupMemberStatus
GSMemPendingApproval -> Bool
False
GroupMemberStatus
GSMemPendingReview -> Bool
False
GroupMemberStatus
GSMemIntroduced -> Bool
False
GroupMemberStatus
GSMemIntroInvited -> Bool
False
GroupMemberStatus
GSMemAccepted -> Bool
False
GroupMemberStatus
GSMemAnnounced -> Bool
False
GroupMemberStatus
GSMemConnected -> Bool
False
GroupMemberStatus
GSMemComplete -> Bool
False
GroupMemberStatus
GSMemCreator -> Bool
False
instance TextEncoding GroupMemberStatus where
textDecode :: Text -> Maybe GroupMemberStatus
textDecode = \case
Text
"rejected" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemRejected
Text
"removed" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemRemoved
Text
"left" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemLeft
Text
"deleted" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemGroupDeleted
Text
"unknown" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemUnknown
Text
"invited" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemInvited
Text
"pending_approval" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemPendingApproval
Text
"pending_review" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemPendingReview
Text
"introduced" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemIntroduced
Text
"intro-inv" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemIntroInvited
Text
"accepted" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemAccepted
Text
"announced" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemAnnounced
Text
"connected" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemConnected
Text
"complete" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemComplete
Text
"creator" -> GroupMemberStatus -> Maybe GroupMemberStatus
forall a. a -> Maybe a
Just GroupMemberStatus
GSMemCreator
Text
_ -> Maybe GroupMemberStatus
forall a. Maybe a
Nothing
textEncode :: GroupMemberStatus -> Text
textEncode = \case
GroupMemberStatus
GSMemRejected -> Text
"rejected"
GroupMemberStatus
GSMemRemoved -> Text
"removed"
GroupMemberStatus
GSMemLeft -> Text
"left"
GroupMemberStatus
GSMemGroupDeleted -> Text
"deleted"
GroupMemberStatus
GSMemUnknown -> Text
"unknown"
GroupMemberStatus
GSMemInvited -> Text
"invited"
GroupMemberStatus
GSMemPendingApproval -> Text
"pending_approval"
GroupMemberStatus
GSMemPendingReview -> Text
"pending_review"
GroupMemberStatus
GSMemIntroduced -> Text
"introduced"
GroupMemberStatus
GSMemIntroInvited -> Text
"intro-inv"
GroupMemberStatus
GSMemAccepted -> Text
"accepted"
GroupMemberStatus
GSMemAnnounced -> Text
"announced"
GroupMemberStatus
GSMemConnected -> Text
"connected"
GroupMemberStatus
GSMemComplete -> Text
"complete"
GroupMemberStatus
GSMemCreator -> Text
"creator"
data SndFileTransfer = SndFileTransfer
{ SndFileTransfer -> CommandId
fileId :: FileTransferId,
SndFileTransfer -> String
fileName :: String,
SndFileTransfer -> String
filePath :: String,
SndFileTransfer -> Integer
fileSize :: Integer,
SndFileTransfer -> Integer
chunkSize :: Integer,
SndFileTransfer -> Text
recipientDisplayName :: ContactName,
SndFileTransfer -> CommandId
connId :: Int64,
SndFileTransfer -> AgentConnId
agentConnId :: AgentConnId,
SndFileTransfer -> Maybe CommandId
groupMemberId :: Maybe Int64,
SndFileTransfer -> FileStatus
fileStatus :: FileStatus,
SndFileTransfer -> Maybe CommandId
fileDescrId :: Maybe Int64,
SndFileTransfer -> Maybe InlineFileMode
fileInline :: Maybe InlineFileMode
}
deriving (SndFileTransfer -> SndFileTransfer -> Bool
(SndFileTransfer -> SndFileTransfer -> Bool)
-> (SndFileTransfer -> SndFileTransfer -> Bool)
-> Eq SndFileTransfer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SndFileTransfer -> SndFileTransfer -> Bool
== :: SndFileTransfer -> SndFileTransfer -> Bool
$c/= :: SndFileTransfer -> SndFileTransfer -> Bool
/= :: SndFileTransfer -> SndFileTransfer -> Bool
Eq, Int -> SndFileTransfer -> ShowS
[SndFileTransfer] -> ShowS
SndFileTransfer -> String
(Int -> SndFileTransfer -> ShowS)
-> (SndFileTransfer -> String)
-> ([SndFileTransfer] -> ShowS)
-> Show SndFileTransfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SndFileTransfer -> ShowS
showsPrec :: Int -> SndFileTransfer -> ShowS
$cshow :: SndFileTransfer -> String
show :: SndFileTransfer -> String
$cshowList :: [SndFileTransfer] -> ShowS
showList :: [SndFileTransfer] -> ShowS
Show)
type FileTransferId = Int64
data FileInvitation = FileInvitation
{ FileInvitation -> String
fileName :: String,
FileInvitation -> Integer
fileSize :: Integer,
FileInvitation -> Maybe FileDigest
fileDigest :: Maybe FileDigest,
FileInvitation -> Maybe ConnReqInvitation
fileConnReq :: Maybe ConnReqInvitation,
FileInvitation -> Maybe InlineFileMode
fileInline :: Maybe InlineFileMode,
FileInvitation -> Maybe FileDescr
fileDescr :: Maybe FileDescr
}
deriving (FileInvitation -> FileInvitation -> Bool
(FileInvitation -> FileInvitation -> Bool)
-> (FileInvitation -> FileInvitation -> Bool) -> Eq FileInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FileInvitation -> FileInvitation -> Bool
== :: FileInvitation -> FileInvitation -> Bool
$c/= :: FileInvitation -> FileInvitation -> Bool
/= :: FileInvitation -> FileInvitation -> Bool
Eq, Int -> FileInvitation -> ShowS
[FileInvitation] -> ShowS
FileInvitation -> String
(Int -> FileInvitation -> ShowS)
-> (FileInvitation -> String)
-> ([FileInvitation] -> ShowS)
-> Show FileInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileInvitation -> ShowS
showsPrec :: Int -> FileInvitation -> ShowS
$cshow :: FileInvitation -> String
show :: FileInvitation -> String
$cshowList :: [FileInvitation] -> ShowS
showList :: [FileInvitation] -> ShowS
Show)
data FileDescr = FileDescr {FileDescr -> Text
fileDescrText :: Text, FileDescr -> Int
fileDescrPartNo :: Int, FileDescr -> Bool
fileDescrComplete :: Bool}
deriving (FileDescr -> FileDescr -> Bool
(FileDescr -> FileDescr -> Bool)
-> (FileDescr -> FileDescr -> Bool) -> Eq FileDescr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FileDescr -> FileDescr -> Bool
== :: FileDescr -> FileDescr -> Bool
$c/= :: FileDescr -> FileDescr -> Bool
/= :: FileDescr -> FileDescr -> Bool
Eq, Int -> FileDescr -> ShowS
[FileDescr] -> ShowS
FileDescr -> String
(Int -> FileDescr -> ShowS)
-> (FileDescr -> String)
-> ([FileDescr] -> ShowS)
-> Show FileDescr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileDescr -> ShowS
showsPrec :: Int -> FileDescr -> ShowS
$cshow :: FileDescr -> String
show :: FileDescr -> String
$cshowList :: [FileDescr] -> ShowS
showList :: [FileDescr] -> ShowS
Show)
xftpFileInvitation :: FilePath -> Integer -> FileDescr -> FileInvitation
xftpFileInvitation :: String -> Integer -> FileDescr -> FileInvitation
xftpFileInvitation String
fileName Integer
fileSize FileDescr
fileDescr =
FileInvitation
{ String
fileName :: String
fileName :: String
fileName,
Integer
fileSize :: Integer
fileSize :: Integer
fileSize,
fileDigest :: Maybe FileDigest
fileDigest = Maybe FileDigest
forall a. Maybe a
Nothing,
fileConnReq :: Maybe ConnReqInvitation
fileConnReq = Maybe ConnReqInvitation
forall a. Maybe a
Nothing,
fileInline :: Maybe InlineFileMode
fileInline = Maybe InlineFileMode
forall a. Maybe a
Nothing,
fileDescr :: Maybe FileDescr
fileDescr = FileDescr -> Maybe FileDescr
forall a. a -> Maybe a
Just FileDescr
fileDescr
}
data InlineFileMode
= IFMOffer
| IFMSent
deriving (InlineFileMode -> InlineFileMode -> Bool
(InlineFileMode -> InlineFileMode -> Bool)
-> (InlineFileMode -> InlineFileMode -> Bool) -> Eq InlineFileMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InlineFileMode -> InlineFileMode -> Bool
== :: InlineFileMode -> InlineFileMode -> Bool
$c/= :: InlineFileMode -> InlineFileMode -> Bool
/= :: InlineFileMode -> InlineFileMode -> Bool
Eq, Int -> InlineFileMode -> ShowS
[InlineFileMode] -> ShowS
InlineFileMode -> String
(Int -> InlineFileMode -> ShowS)
-> (InlineFileMode -> String)
-> ([InlineFileMode] -> ShowS)
-> Show InlineFileMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InlineFileMode -> ShowS
showsPrec :: Int -> InlineFileMode -> ShowS
$cshow :: InlineFileMode -> String
show :: InlineFileMode -> String
$cshowList :: [InlineFileMode] -> ShowS
showList :: [InlineFileMode] -> ShowS
Show)
instance TextEncoding InlineFileMode where
textEncode :: InlineFileMode -> Text
textEncode = \case
InlineFileMode
IFMOffer -> Text
"offer"
InlineFileMode
IFMSent -> Text
"sent"
textDecode :: Text -> Maybe InlineFileMode
textDecode = \case
Text
"offer" -> InlineFileMode -> Maybe InlineFileMode
forall a. a -> Maybe a
Just InlineFileMode
IFMOffer
Text
"sent" -> InlineFileMode -> Maybe InlineFileMode
forall a. a -> Maybe a
Just InlineFileMode
IFMSent
Text
_ -> Maybe InlineFileMode
forall a. Maybe a
Nothing
instance FromField InlineFileMode where fromField :: FieldParser InlineFileMode
fromField = (Text -> Maybe InlineFileMode) -> FieldParser InlineFileMode
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe InlineFileMode
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField InlineFileMode where toField :: InlineFileMode -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (InlineFileMode -> Text) -> InlineFileMode -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlineFileMode -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromJSON InlineFileMode where
parseJSON :: Value -> Parser InlineFileMode
parseJSON = String -> Value -> Parser InlineFileMode
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"InlineFileMode"
instance ToJSON InlineFileMode where
toJSON :: InlineFileMode -> Value
toJSON = Text -> Value
J.String (Text -> Value)
-> (InlineFileMode -> Text) -> InlineFileMode -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlineFileMode -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: InlineFileMode -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding)
-> (InlineFileMode -> Text) -> InlineFileMode -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InlineFileMode -> Text
forall a. TextEncoding a => a -> Text
textEncode
data RcvFileTransfer = RcvFileTransfer
{ RcvFileTransfer -> CommandId
fileId :: FileTransferId,
RcvFileTransfer -> Maybe XFTPRcvFile
xftpRcvFile :: Maybe XFTPRcvFile,
RcvFileTransfer -> FileInvitation
fileInvitation :: FileInvitation,
RcvFileTransfer -> RcvFileStatus
fileStatus :: RcvFileStatus,
RcvFileTransfer -> Maybe InlineFileMode
rcvFileInline :: Maybe InlineFileMode,
RcvFileTransfer -> Text
senderDisplayName :: ContactName,
RcvFileTransfer -> Integer
chunkSize :: Integer,
RcvFileTransfer -> Bool
cancelled :: Bool,
RcvFileTransfer -> Maybe CommandId
grpMemberId :: Maybe Int64,
RcvFileTransfer -> Maybe CryptoFileArgs
cryptoArgs :: Maybe CryptoFileArgs
}
deriving (RcvFileTransfer -> RcvFileTransfer -> Bool
(RcvFileTransfer -> RcvFileTransfer -> Bool)
-> (RcvFileTransfer -> RcvFileTransfer -> Bool)
-> Eq RcvFileTransfer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RcvFileTransfer -> RcvFileTransfer -> Bool
== :: RcvFileTransfer -> RcvFileTransfer -> Bool
$c/= :: RcvFileTransfer -> RcvFileTransfer -> Bool
/= :: RcvFileTransfer -> RcvFileTransfer -> Bool
Eq, Int -> RcvFileTransfer -> ShowS
[RcvFileTransfer] -> ShowS
RcvFileTransfer -> String
(Int -> RcvFileTransfer -> ShowS)
-> (RcvFileTransfer -> String)
-> ([RcvFileTransfer] -> ShowS)
-> Show RcvFileTransfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RcvFileTransfer -> ShowS
showsPrec :: Int -> RcvFileTransfer -> ShowS
$cshow :: RcvFileTransfer -> String
show :: RcvFileTransfer -> String
$cshowList :: [RcvFileTransfer] -> ShowS
showList :: [RcvFileTransfer] -> ShowS
Show)
data XFTPRcvFile = XFTPRcvFile
{ XFTPRcvFile -> RcvFileDescr
rcvFileDescription :: RcvFileDescr,
XFTPRcvFile -> Maybe AgentRcvFileId
agentRcvFileId :: Maybe AgentRcvFileId,
XFTPRcvFile -> Bool
agentRcvFileDeleted :: Bool,
XFTPRcvFile -> Bool
userApprovedRelays :: Bool
}
deriving (XFTPRcvFile -> XFTPRcvFile -> Bool
(XFTPRcvFile -> XFTPRcvFile -> Bool)
-> (XFTPRcvFile -> XFTPRcvFile -> Bool) -> Eq XFTPRcvFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XFTPRcvFile -> XFTPRcvFile -> Bool
== :: XFTPRcvFile -> XFTPRcvFile -> Bool
$c/= :: XFTPRcvFile -> XFTPRcvFile -> Bool
/= :: XFTPRcvFile -> XFTPRcvFile -> Bool
Eq, Int -> XFTPRcvFile -> ShowS
[XFTPRcvFile] -> ShowS
XFTPRcvFile -> String
(Int -> XFTPRcvFile -> ShowS)
-> (XFTPRcvFile -> String)
-> ([XFTPRcvFile] -> ShowS)
-> Show XFTPRcvFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XFTPRcvFile -> ShowS
showsPrec :: Int -> XFTPRcvFile -> ShowS
$cshow :: XFTPRcvFile -> String
show :: XFTPRcvFile -> String
$cshowList :: [XFTPRcvFile] -> ShowS
showList :: [XFTPRcvFile] -> ShowS
Show)
type RcvFileDescrText = Text
data RcvFileDescr = RcvFileDescr
{ RcvFileDescr -> CommandId
fileDescrId :: Int64,
RcvFileDescr -> Text
fileDescrText :: RcvFileDescrText,
RcvFileDescr -> Int
fileDescrPartNo :: Int,
RcvFileDescr -> Bool
fileDescrComplete :: Bool
}
deriving (RcvFileDescr -> RcvFileDescr -> Bool
(RcvFileDescr -> RcvFileDescr -> Bool)
-> (RcvFileDescr -> RcvFileDescr -> Bool) -> Eq RcvFileDescr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RcvFileDescr -> RcvFileDescr -> Bool
== :: RcvFileDescr -> RcvFileDescr -> Bool
$c/= :: RcvFileDescr -> RcvFileDescr -> Bool
/= :: RcvFileDescr -> RcvFileDescr -> Bool
Eq, Int -> RcvFileDescr -> ShowS
[RcvFileDescr] -> ShowS
RcvFileDescr -> String
(Int -> RcvFileDescr -> ShowS)
-> (RcvFileDescr -> String)
-> ([RcvFileDescr] -> ShowS)
-> Show RcvFileDescr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RcvFileDescr -> ShowS
showsPrec :: Int -> RcvFileDescr -> ShowS
$cshow :: RcvFileDescr -> String
show :: RcvFileDescr -> String
$cshowList :: [RcvFileDescr] -> ShowS
showList :: [RcvFileDescr] -> ShowS
Show)
data RcvFileStatus
= RFSNew
| RFSAccepted {RcvFileStatus -> String
filePath :: FilePath}
| RFSConnected {filePath :: FilePath}
| RFSComplete {filePath :: FilePath}
| RFSCancelled {RcvFileStatus -> Maybe String
filePath_ :: Maybe FilePath}
deriving (RcvFileStatus -> RcvFileStatus -> Bool
(RcvFileStatus -> RcvFileStatus -> Bool)
-> (RcvFileStatus -> RcvFileStatus -> Bool) -> Eq RcvFileStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RcvFileStatus -> RcvFileStatus -> Bool
== :: RcvFileStatus -> RcvFileStatus -> Bool
$c/= :: RcvFileStatus -> RcvFileStatus -> Bool
/= :: RcvFileStatus -> RcvFileStatus -> Bool
Eq, Int -> RcvFileStatus -> ShowS
[RcvFileStatus] -> ShowS
RcvFileStatus -> String
(Int -> RcvFileStatus -> ShowS)
-> (RcvFileStatus -> String)
-> ([RcvFileStatus] -> ShowS)
-> Show RcvFileStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RcvFileStatus -> ShowS
showsPrec :: Int -> RcvFileStatus -> ShowS
$cshow :: RcvFileStatus -> String
show :: RcvFileStatus -> String
$cshowList :: [RcvFileStatus] -> ShowS
showList :: [RcvFileStatus] -> ShowS
Show)
rcvFileComplete :: RcvFileStatus -> Bool
rcvFileComplete :: RcvFileStatus -> Bool
rcvFileComplete = \case
RFSComplete String
_ -> Bool
True
RcvFileStatus
_ -> Bool
False
rcvFileCompleteOrCancelled :: RcvFileTransfer -> Bool
rcvFileCompleteOrCancelled :: RcvFileTransfer -> Bool
rcvFileCompleteOrCancelled RcvFileTransfer {RcvFileStatus
fileStatus :: RcvFileTransfer -> RcvFileStatus
fileStatus :: RcvFileStatus
fileStatus, Bool
cancelled :: RcvFileTransfer -> Bool
cancelled :: Bool
cancelled} = RcvFileStatus -> Bool
rcvFileComplete RcvFileStatus
fileStatus Bool -> Bool -> Bool
|| Bool
cancelled
liveRcvFileTransferPath :: RcvFileTransfer -> Maybe FilePath
liveRcvFileTransferPath :: RcvFileTransfer -> Maybe String
liveRcvFileTransferPath RcvFileTransfer {RcvFileStatus
fileStatus :: RcvFileTransfer -> RcvFileStatus
fileStatus :: RcvFileStatus
fileStatus} = case RcvFileStatus
fileStatus of
RFSAccepted String
filePath -> String -> Maybe String
forall a. a -> Maybe a
Just String
filePath
RFSConnected String
filePath -> String -> Maybe String
forall a. a -> Maybe a
Just String
filePath
RcvFileStatus
_ -> Maybe String
forall a. Maybe a
Nothing
newtype AgentConnId = AgentConnId ConnId
deriving (AgentConnId -> AgentConnId -> Bool
(AgentConnId -> AgentConnId -> Bool)
-> (AgentConnId -> AgentConnId -> Bool) -> Eq AgentConnId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AgentConnId -> AgentConnId -> Bool
== :: AgentConnId -> AgentConnId -> Bool
$c/= :: AgentConnId -> AgentConnId -> Bool
/= :: AgentConnId -> AgentConnId -> Bool
Eq, Eq AgentConnId
Eq AgentConnId =>
(AgentConnId -> AgentConnId -> Ordering)
-> (AgentConnId -> AgentConnId -> Bool)
-> (AgentConnId -> AgentConnId -> Bool)
-> (AgentConnId -> AgentConnId -> Bool)
-> (AgentConnId -> AgentConnId -> Bool)
-> (AgentConnId -> AgentConnId -> AgentConnId)
-> (AgentConnId -> AgentConnId -> AgentConnId)
-> Ord AgentConnId
AgentConnId -> AgentConnId -> Bool
AgentConnId -> AgentConnId -> Ordering
AgentConnId -> AgentConnId -> AgentConnId
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: AgentConnId -> AgentConnId -> Ordering
compare :: AgentConnId -> AgentConnId -> Ordering
$c< :: AgentConnId -> AgentConnId -> Bool
< :: AgentConnId -> AgentConnId -> Bool
$c<= :: AgentConnId -> AgentConnId -> Bool
<= :: AgentConnId -> AgentConnId -> Bool
$c> :: AgentConnId -> AgentConnId -> Bool
> :: AgentConnId -> AgentConnId -> Bool
$c>= :: AgentConnId -> AgentConnId -> Bool
>= :: AgentConnId -> AgentConnId -> Bool
$cmax :: AgentConnId -> AgentConnId -> AgentConnId
max :: AgentConnId -> AgentConnId -> AgentConnId
$cmin :: AgentConnId -> AgentConnId -> AgentConnId
min :: AgentConnId -> AgentConnId -> AgentConnId
Ord, Int -> AgentConnId -> ShowS
[AgentConnId] -> ShowS
AgentConnId -> String
(Int -> AgentConnId -> ShowS)
-> (AgentConnId -> String)
-> ([AgentConnId] -> ShowS)
-> Show AgentConnId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AgentConnId -> ShowS
showsPrec :: Int -> AgentConnId -> ShowS
$cshow :: AgentConnId -> String
show :: AgentConnId -> String
$cshowList :: [AgentConnId] -> ShowS
showList :: [AgentConnId] -> ShowS
Show)
deriving newtype (FieldParser AgentConnId
FieldParser AgentConnId -> FromField AgentConnId
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser AgentConnId
fromField :: FieldParser AgentConnId
FromField)
instance ToField AgentConnId where toField :: AgentConnId -> SQLData
toField (AgentConnId ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding AgentConnId where
strEncode :: AgentConnId -> ByteString
strEncode (AgentConnId ByteString
connId) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
connId
strDecode :: ByteString -> Either String AgentConnId
strDecode ByteString
s = ByteString -> AgentConnId
AgentConnId (ByteString -> AgentConnId)
-> Either String ByteString -> Either String AgentConnId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser AgentConnId
strP = ByteString -> AgentConnId
AgentConnId (ByteString -> AgentConnId)
-> Parser ByteString ByteString -> Parser AgentConnId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP Parser ByteString ByteString
-> Parser ByteString ByteString -> Parser ByteString ByteString
forall a.
Parser ByteString a -> Parser ByteString a -> Parser ByteString a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ByteString -> Parser ByteString ByteString
forall a. a -> Parser ByteString a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ByteString
B.empty)
instance FromJSON AgentConnId where
parseJSON :: Value -> Parser AgentConnId
parseJSON = String -> Value -> Parser AgentConnId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"AgentConnId"
instance ToJSON AgentConnId where
toJSON :: AgentConnId -> Value
toJSON = AgentConnId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: AgentConnId -> Encoding
toEncoding = AgentConnId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
newtype AgentSndFileId = AgentSndFileId SndFileId
deriving (AgentSndFileId -> AgentSndFileId -> Bool
(AgentSndFileId -> AgentSndFileId -> Bool)
-> (AgentSndFileId -> AgentSndFileId -> Bool) -> Eq AgentSndFileId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AgentSndFileId -> AgentSndFileId -> Bool
== :: AgentSndFileId -> AgentSndFileId -> Bool
$c/= :: AgentSndFileId -> AgentSndFileId -> Bool
/= :: AgentSndFileId -> AgentSndFileId -> Bool
Eq, Int -> AgentSndFileId -> ShowS
[AgentSndFileId] -> ShowS
AgentSndFileId -> String
(Int -> AgentSndFileId -> ShowS)
-> (AgentSndFileId -> String)
-> ([AgentSndFileId] -> ShowS)
-> Show AgentSndFileId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AgentSndFileId -> ShowS
showsPrec :: Int -> AgentSndFileId -> ShowS
$cshow :: AgentSndFileId -> String
show :: AgentSndFileId -> String
$cshowList :: [AgentSndFileId] -> ShowS
showList :: [AgentSndFileId] -> ShowS
Show)
deriving newtype (FieldParser AgentSndFileId
FieldParser AgentSndFileId -> FromField AgentSndFileId
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser AgentSndFileId
fromField :: FieldParser AgentSndFileId
FromField)
instance ToField AgentSndFileId where toField :: AgentSndFileId -> SQLData
toField (AgentSndFileId ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding AgentSndFileId where
strEncode :: AgentSndFileId -> ByteString
strEncode (AgentSndFileId ByteString
connId) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
connId
strDecode :: ByteString -> Either String AgentSndFileId
strDecode ByteString
s = ByteString -> AgentSndFileId
AgentSndFileId (ByteString -> AgentSndFileId)
-> Either String ByteString -> Either String AgentSndFileId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser AgentSndFileId
strP = ByteString -> AgentSndFileId
AgentSndFileId (ByteString -> AgentSndFileId)
-> Parser ByteString ByteString -> Parser AgentSndFileId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON AgentSndFileId where
parseJSON :: Value -> Parser AgentSndFileId
parseJSON = String -> Value -> Parser AgentSndFileId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"AgentSndFileId"
instance ToJSON AgentSndFileId where
toJSON :: AgentSndFileId -> Value
toJSON = AgentSndFileId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: AgentSndFileId -> Encoding
toEncoding = AgentSndFileId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
newtype AgentRcvFileId = AgentRcvFileId RcvFileId
deriving (AgentRcvFileId -> AgentRcvFileId -> Bool
(AgentRcvFileId -> AgentRcvFileId -> Bool)
-> (AgentRcvFileId -> AgentRcvFileId -> Bool) -> Eq AgentRcvFileId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AgentRcvFileId -> AgentRcvFileId -> Bool
== :: AgentRcvFileId -> AgentRcvFileId -> Bool
$c/= :: AgentRcvFileId -> AgentRcvFileId -> Bool
/= :: AgentRcvFileId -> AgentRcvFileId -> Bool
Eq, Int -> AgentRcvFileId -> ShowS
[AgentRcvFileId] -> ShowS
AgentRcvFileId -> String
(Int -> AgentRcvFileId -> ShowS)
-> (AgentRcvFileId -> String)
-> ([AgentRcvFileId] -> ShowS)
-> Show AgentRcvFileId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AgentRcvFileId -> ShowS
showsPrec :: Int -> AgentRcvFileId -> ShowS
$cshow :: AgentRcvFileId -> String
show :: AgentRcvFileId -> String
$cshowList :: [AgentRcvFileId] -> ShowS
showList :: [AgentRcvFileId] -> ShowS
Show)
deriving newtype (FieldParser AgentRcvFileId
FieldParser AgentRcvFileId -> FromField AgentRcvFileId
forall a. FieldParser a -> FromField a
$cfromField :: FieldParser AgentRcvFileId
fromField :: FieldParser AgentRcvFileId
FromField)
instance ToField AgentRcvFileId where toField :: AgentRcvFileId -> SQLData
toField (AgentRcvFileId ByteString
m) = Binary ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField (Binary ByteString -> SQLData) -> Binary ByteString -> SQLData
forall a b. (a -> b) -> a -> b
$ ByteString -> Binary ByteString
forall a. a -> Binary a
Binary ByteString
m
instance StrEncoding AgentRcvFileId where
strEncode :: AgentRcvFileId -> ByteString
strEncode (AgentRcvFileId ByteString
connId) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
connId
strDecode :: ByteString -> Either String AgentRcvFileId
strDecode ByteString
s = ByteString -> AgentRcvFileId
AgentRcvFileId (ByteString -> AgentRcvFileId)
-> Either String ByteString -> Either String AgentRcvFileId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser AgentRcvFileId
strP = ByteString -> AgentRcvFileId
AgentRcvFileId (ByteString -> AgentRcvFileId)
-> Parser ByteString ByteString -> Parser AgentRcvFileId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON AgentRcvFileId where
parseJSON :: Value -> Parser AgentRcvFileId
parseJSON = String -> Value -> Parser AgentRcvFileId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"AgentRcvFileId"
instance ToJSON AgentRcvFileId where
toJSON :: AgentRcvFileId -> Value
toJSON = AgentRcvFileId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: AgentRcvFileId -> Encoding
toEncoding = AgentRcvFileId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
newtype AgentInvId = AgentInvId InvitationId
deriving (AgentInvId -> AgentInvId -> Bool
(AgentInvId -> AgentInvId -> Bool)
-> (AgentInvId -> AgentInvId -> Bool) -> Eq AgentInvId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AgentInvId -> AgentInvId -> Bool
== :: AgentInvId -> AgentInvId -> Bool
$c/= :: AgentInvId -> AgentInvId -> Bool
/= :: AgentInvId -> AgentInvId -> Bool
Eq, Int -> AgentInvId -> ShowS
[AgentInvId] -> ShowS
AgentInvId -> String
(Int -> AgentInvId -> ShowS)
-> (AgentInvId -> String)
-> ([AgentInvId] -> ShowS)
-> Show AgentInvId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AgentInvId -> ShowS
showsPrec :: Int -> AgentInvId -> ShowS
$cshow :: AgentInvId -> String
show :: AgentInvId -> String
$cshowList :: [AgentInvId] -> ShowS
showList :: [AgentInvId] -> ShowS
Show)
instance StrEncoding AgentInvId where
strEncode :: AgentInvId -> ByteString
strEncode (AgentInvId ByteString
connId) = ByteString -> ByteString
forall a. StrEncoding a => a -> ByteString
strEncode ByteString
connId
strDecode :: ByteString -> Either String AgentInvId
strDecode ByteString
s = ByteString -> AgentInvId
AgentInvId (ByteString -> AgentInvId)
-> Either String ByteString -> Either String AgentInvId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Either String ByteString
forall a. StrEncoding a => ByteString -> Either String a
strDecode ByteString
s
strP :: Parser AgentInvId
strP = ByteString -> AgentInvId
AgentInvId (ByteString -> AgentInvId)
-> Parser ByteString ByteString -> Parser AgentInvId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString ByteString
forall a. StrEncoding a => Parser a
strP
instance FromJSON AgentInvId where
parseJSON :: Value -> Parser AgentInvId
parseJSON = String -> Value -> Parser AgentInvId
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"AgentInvId"
instance ToJSON AgentInvId where
toJSON :: AgentInvId -> Value
toJSON = AgentInvId -> Value
forall a. StrEncoding a => a -> Value
strToJSON
toEncoding :: AgentInvId -> Encoding
toEncoding = AgentInvId -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding
deriving newtype instance FromField AgentInvId
instance ToField AgentInvId where toField :: AgentInvId -> SQLData
toField (AgentInvId ByteString
m) = ByteString -> SQLData
forall a. ToField a => a -> SQLData
toField ByteString
m
data FileTransfer
= FTSnd
{ FileTransfer -> FileTransferMeta
fileTransferMeta :: FileTransferMeta,
FileTransfer -> [SndFileTransfer]
sndFileTransfers :: [SndFileTransfer]
}
| FTRcv {FileTransfer -> RcvFileTransfer
rcvFileTransfer :: RcvFileTransfer}
deriving (Int -> FileTransfer -> ShowS
[FileTransfer] -> ShowS
FileTransfer -> String
(Int -> FileTransfer -> ShowS)
-> (FileTransfer -> String)
-> ([FileTransfer] -> ShowS)
-> Show FileTransfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileTransfer -> ShowS
showsPrec :: Int -> FileTransfer -> ShowS
$cshow :: FileTransfer -> String
show :: FileTransfer -> String
$cshowList :: [FileTransfer] -> ShowS
showList :: [FileTransfer] -> ShowS
Show)
data FileTransferMeta = FileTransferMeta
{ FileTransferMeta -> CommandId
fileId :: FileTransferId,
FileTransferMeta -> Maybe XFTPSndFile
xftpSndFile :: Maybe XFTPSndFile,
FileTransferMeta -> Maybe CommandId
xftpRedirectFor :: Maybe FileTransferId,
FileTransferMeta -> String
fileName :: String,
FileTransferMeta -> String
filePath :: String,
FileTransferMeta -> Integer
fileSize :: Integer,
FileTransferMeta -> Maybe InlineFileMode
fileInline :: Maybe InlineFileMode,
FileTransferMeta -> Integer
chunkSize :: Integer,
FileTransferMeta -> Bool
cancelled :: Bool
}
deriving (FileTransferMeta -> FileTransferMeta -> Bool
(FileTransferMeta -> FileTransferMeta -> Bool)
-> (FileTransferMeta -> FileTransferMeta -> Bool)
-> Eq FileTransferMeta
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FileTransferMeta -> FileTransferMeta -> Bool
== :: FileTransferMeta -> FileTransferMeta -> Bool
$c/= :: FileTransferMeta -> FileTransferMeta -> Bool
/= :: FileTransferMeta -> FileTransferMeta -> Bool
Eq, Int -> FileTransferMeta -> ShowS
[FileTransferMeta] -> ShowS
FileTransferMeta -> String
(Int -> FileTransferMeta -> ShowS)
-> (FileTransferMeta -> String)
-> ([FileTransferMeta] -> ShowS)
-> Show FileTransferMeta
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileTransferMeta -> ShowS
showsPrec :: Int -> FileTransferMeta -> ShowS
$cshow :: FileTransferMeta -> String
show :: FileTransferMeta -> String
$cshowList :: [FileTransferMeta] -> ShowS
showList :: [FileTransferMeta] -> ShowS
Show)
data LocalFileMeta = LocalFileMeta
{ LocalFileMeta -> CommandId
fileId :: FileTransferId,
LocalFileMeta -> String
fileName :: String,
LocalFileMeta -> String
filePath :: String,
LocalFileMeta -> Integer
fileSize :: Integer,
LocalFileMeta -> Maybe CryptoFileArgs
fileCryptoArgs :: Maybe CryptoFileArgs
}
deriving (LocalFileMeta -> LocalFileMeta -> Bool
(LocalFileMeta -> LocalFileMeta -> Bool)
-> (LocalFileMeta -> LocalFileMeta -> Bool) -> Eq LocalFileMeta
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LocalFileMeta -> LocalFileMeta -> Bool
== :: LocalFileMeta -> LocalFileMeta -> Bool
$c/= :: LocalFileMeta -> LocalFileMeta -> Bool
/= :: LocalFileMeta -> LocalFileMeta -> Bool
Eq, Int -> LocalFileMeta -> ShowS
[LocalFileMeta] -> ShowS
LocalFileMeta -> String
(Int -> LocalFileMeta -> ShowS)
-> (LocalFileMeta -> String)
-> ([LocalFileMeta] -> ShowS)
-> Show LocalFileMeta
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LocalFileMeta -> ShowS
showsPrec :: Int -> LocalFileMeta -> ShowS
$cshow :: LocalFileMeta -> String
show :: LocalFileMeta -> String
$cshowList :: [LocalFileMeta] -> ShowS
showList :: [LocalFileMeta] -> ShowS
Show)
data XFTPSndFile = XFTPSndFile
{ XFTPSndFile -> AgentSndFileId
agentSndFileId :: AgentSndFileId,
XFTPSndFile -> Maybe Text
privateSndFileDescr :: Maybe Text,
XFTPSndFile -> Bool
agentSndFileDeleted :: Bool,
XFTPSndFile -> Maybe CryptoFileArgs
cryptoArgs :: Maybe CryptoFileArgs
}
deriving (XFTPSndFile -> XFTPSndFile -> Bool
(XFTPSndFile -> XFTPSndFile -> Bool)
-> (XFTPSndFile -> XFTPSndFile -> Bool) -> Eq XFTPSndFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XFTPSndFile -> XFTPSndFile -> Bool
== :: XFTPSndFile -> XFTPSndFile -> Bool
$c/= :: XFTPSndFile -> XFTPSndFile -> Bool
/= :: XFTPSndFile -> XFTPSndFile -> Bool
Eq, Int -> XFTPSndFile -> ShowS
[XFTPSndFile] -> ShowS
XFTPSndFile -> String
(Int -> XFTPSndFile -> ShowS)
-> (XFTPSndFile -> String)
-> ([XFTPSndFile] -> ShowS)
-> Show XFTPSndFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XFTPSndFile -> ShowS
showsPrec :: Int -> XFTPSndFile -> ShowS
$cshow :: XFTPSndFile -> String
show :: XFTPSndFile -> String
$cshowList :: [XFTPSndFile] -> ShowS
showList :: [XFTPSndFile] -> ShowS
Show)
fileTransferCancelled :: FileTransfer -> Bool
fileTransferCancelled :: FileTransfer -> Bool
fileTransferCancelled (FTSnd FileTransferMeta {Bool
cancelled :: FileTransferMeta -> Bool
cancelled :: Bool
cancelled} [SndFileTransfer]
_) = Bool
cancelled
fileTransferCancelled (FTRcv RcvFileTransfer {Bool
cancelled :: RcvFileTransfer -> Bool
cancelled :: Bool
cancelled}) = Bool
cancelled
data FileStatus = FSNew | FSAccepted | FSConnected | FSComplete | FSCancelled deriving (FileStatus -> FileStatus -> Bool
(FileStatus -> FileStatus -> Bool)
-> (FileStatus -> FileStatus -> Bool) -> Eq FileStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FileStatus -> FileStatus -> Bool
== :: FileStatus -> FileStatus -> Bool
$c/= :: FileStatus -> FileStatus -> Bool
/= :: FileStatus -> FileStatus -> Bool
Eq, Eq FileStatus
Eq FileStatus =>
(FileStatus -> FileStatus -> Ordering)
-> (FileStatus -> FileStatus -> Bool)
-> (FileStatus -> FileStatus -> Bool)
-> (FileStatus -> FileStatus -> Bool)
-> (FileStatus -> FileStatus -> Bool)
-> (FileStatus -> FileStatus -> FileStatus)
-> (FileStatus -> FileStatus -> FileStatus)
-> Ord FileStatus
FileStatus -> FileStatus -> Bool
FileStatus -> FileStatus -> Ordering
FileStatus -> FileStatus -> FileStatus
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FileStatus -> FileStatus -> Ordering
compare :: FileStatus -> FileStatus -> Ordering
$c< :: FileStatus -> FileStatus -> Bool
< :: FileStatus -> FileStatus -> Bool
$c<= :: FileStatus -> FileStatus -> Bool
<= :: FileStatus -> FileStatus -> Bool
$c> :: FileStatus -> FileStatus -> Bool
> :: FileStatus -> FileStatus -> Bool
$c>= :: FileStatus -> FileStatus -> Bool
>= :: FileStatus -> FileStatus -> Bool
$cmax :: FileStatus -> FileStatus -> FileStatus
max :: FileStatus -> FileStatus -> FileStatus
$cmin :: FileStatus -> FileStatus -> FileStatus
min :: FileStatus -> FileStatus -> FileStatus
Ord, Int -> FileStatus -> ShowS
[FileStatus] -> ShowS
FileStatus -> String
(Int -> FileStatus -> ShowS)
-> (FileStatus -> String)
-> ([FileStatus] -> ShowS)
-> Show FileStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileStatus -> ShowS
showsPrec :: Int -> FileStatus -> ShowS
$cshow :: FileStatus -> String
show :: FileStatus -> String
$cshowList :: [FileStatus] -> ShowS
showList :: [FileStatus] -> ShowS
Show)
instance FromField FileStatus where fromField :: FieldParser FileStatus
fromField = (Text -> Maybe FileStatus) -> FieldParser FileStatus
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe FileStatus
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField FileStatus where toField :: FileStatus -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData) -> (FileStatus -> Text) -> FileStatus -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromJSON FileStatus where
parseJSON :: Value -> Parser FileStatus
parseJSON = String -> Value -> Parser FileStatus
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"FileStatus"
instance ToJSON FileStatus where
toJSON :: FileStatus -> Value
toJSON = Text -> Value
J.String (Text -> Value) -> (FileStatus -> Text) -> FileStatus -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: FileStatus -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding)
-> (FileStatus -> Text) -> FileStatus -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding FileStatus where
textDecode :: Text -> Maybe FileStatus
textDecode = \case
Text
"new" -> FileStatus -> Maybe FileStatus
forall a. a -> Maybe a
Just FileStatus
FSNew
Text
"accepted" -> FileStatus -> Maybe FileStatus
forall a. a -> Maybe a
Just FileStatus
FSAccepted
Text
"connected" -> FileStatus -> Maybe FileStatus
forall a. a -> Maybe a
Just FileStatus
FSConnected
Text
"complete" -> FileStatus -> Maybe FileStatus
forall a. a -> Maybe a
Just FileStatus
FSComplete
Text
"cancelled" -> FileStatus -> Maybe FileStatus
forall a. a -> Maybe a
Just FileStatus
FSCancelled
Text
_ -> Maybe FileStatus
forall a. Maybe a
Nothing
textEncode :: FileStatus -> Text
textEncode = \case
FileStatus
FSNew -> Text
"new"
FileStatus
FSAccepted -> Text
"accepted"
FileStatus
FSConnected -> Text
"connected"
FileStatus
FSComplete -> Text
"complete"
FileStatus
FSCancelled -> Text
"cancelled"
data RcvChunkStatus = RcvChunkOk | RcvChunkFinal | RcvChunkDuplicate | RcvChunkError
deriving (RcvChunkStatus -> RcvChunkStatus -> Bool
(RcvChunkStatus -> RcvChunkStatus -> Bool)
-> (RcvChunkStatus -> RcvChunkStatus -> Bool) -> Eq RcvChunkStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RcvChunkStatus -> RcvChunkStatus -> Bool
== :: RcvChunkStatus -> RcvChunkStatus -> Bool
$c/= :: RcvChunkStatus -> RcvChunkStatus -> Bool
/= :: RcvChunkStatus -> RcvChunkStatus -> Bool
Eq, Int -> RcvChunkStatus -> ShowS
[RcvChunkStatus] -> ShowS
RcvChunkStatus -> String
(Int -> RcvChunkStatus -> ShowS)
-> (RcvChunkStatus -> String)
-> ([RcvChunkStatus] -> ShowS)
-> Show RcvChunkStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RcvChunkStatus -> ShowS
showsPrec :: Int -> RcvChunkStatus -> ShowS
$cshow :: RcvChunkStatus -> String
show :: RcvChunkStatus -> String
$cshowList :: [RcvChunkStatus] -> ShowS
showList :: [RcvChunkStatus] -> ShowS
Show)
type ConnReqInvitation = ConnectionRequestUri 'CMInvitation
type ConnReqContact = ConnectionRequestUri 'CMContact
type CreatedLinkInvitation = CreatedConnLink 'CMInvitation
type CreatedLinkContact = CreatedConnLink 'CMContact
type ConnLinkContact = ConnectionLink 'CMContact
type ShortLinkInvitation = ConnShortLink 'CMInvitation
type ShortLinkContact = ConnShortLink 'CMContact
data Connection = Connection
{ Connection -> CommandId
connId :: Int64,
Connection -> AgentConnId
agentConnId :: AgentConnId,
Connection -> Version ChatVersion
connChatVersion :: VersionChat,
Connection -> VersionRangeChat
peerChatVRange :: VersionRangeChat,
Connection -> Int
connLevel :: Int,
Connection -> Maybe CommandId
viaContact :: Maybe Int64,
Connection -> Maybe CommandId
viaUserContactLink :: Maybe Int64,
Connection -> Bool
viaGroupLink :: Bool,
Connection -> Maybe GroupLinkId
groupLinkId :: Maybe GroupLinkId,
Connection -> Maybe XContactId
xContactId :: Maybe XContactId,
Connection -> Maybe CommandId
customUserProfileId :: Maybe Int64,
Connection -> ConnType
connType :: ConnType,
Connection -> ConnStatus
connStatus :: ConnStatus,
Connection -> Bool
contactConnInitiated :: Bool,
Connection -> Text
localAlias :: Text,
Connection -> Maybe CommandId
entityId :: Maybe Int64,
Connection -> Maybe SecurityCode
connectionCode :: Maybe SecurityCode,
Connection -> PQSupport
pqSupport :: PQSupport,
Connection -> PQEncryption
pqEncryption :: PQEncryption,
Connection -> Maybe PQEncryption
pqSndEnabled :: Maybe PQEncryption,
Connection -> Maybe PQEncryption
pqRcvEnabled :: Maybe PQEncryption,
Connection -> Int
authErrCounter :: Int,
Connection -> Int
quotaErrCounter :: Int,
Connection -> UTCTime
createdAt :: UTCTime
}
deriving (Connection -> Connection -> Bool
(Connection -> Connection -> Bool)
-> (Connection -> Connection -> Bool) -> Eq Connection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Connection -> Connection -> Bool
== :: Connection -> Connection -> Bool
$c/= :: Connection -> Connection -> Bool
/= :: Connection -> Connection -> Bool
Eq, Int -> Connection -> ShowS
[Connection] -> ShowS
Connection -> String
(Int -> Connection -> ShowS)
-> (Connection -> String)
-> ([Connection] -> ShowS)
-> Show Connection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Connection -> ShowS
showsPrec :: Int -> Connection -> ShowS
$cshow :: Connection -> String
show :: Connection -> String
$cshowList :: [Connection] -> ShowS
showList :: [Connection] -> ShowS
Show)
dbConnId :: Connection -> Int64
dbConnId :: Connection -> CommandId
dbConnId Connection {CommandId
connId :: Connection -> CommandId
connId :: CommandId
connId} = CommandId
connId
connReady :: Connection -> Bool
connReady :: Connection -> Bool
connReady Connection {ConnStatus
connStatus :: Connection -> ConnStatus
connStatus :: ConnStatus
connStatus} = ConnStatus
connStatus ConnStatus -> ConnStatus -> Bool
forall a. Eq a => a -> a -> Bool
== ConnStatus
ConnReady Bool -> Bool -> Bool
|| ConnStatus
connStatus ConnStatus -> ConnStatus -> Bool
forall a. Eq a => a -> a -> Bool
== ConnStatus
ConnSndReady
authErrDisableCount :: Int
authErrDisableCount :: Int
authErrDisableCount = Int
10
connDisabled :: Connection -> Bool
connDisabled :: Connection -> Bool
connDisabled Connection {Int
authErrCounter :: Connection -> Int
authErrCounter :: Int
authErrCounter} = Int
authErrCounter Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
authErrDisableCount
quotaErrInactiveCount :: Int
quotaErrInactiveCount :: Int
quotaErrInactiveCount = Int
5
quotaErrSetOnMERR :: Int
quotaErrSetOnMERR :: Int
quotaErrSetOnMERR = Int
999
connInactive :: Connection -> Bool
connInactive :: Connection -> Bool
connInactive Connection {Int
quotaErrCounter :: Connection -> Int
quotaErrCounter :: Int
quotaErrCounter} = Int
quotaErrCounter Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
quotaErrInactiveCount
data SecurityCode = SecurityCode {SecurityCode -> Text
securityCode :: Text, SecurityCode -> UTCTime
verifiedAt :: UTCTime}
deriving (SecurityCode -> SecurityCode -> Bool
(SecurityCode -> SecurityCode -> Bool)
-> (SecurityCode -> SecurityCode -> Bool) -> Eq SecurityCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SecurityCode -> SecurityCode -> Bool
== :: SecurityCode -> SecurityCode -> Bool
$c/= :: SecurityCode -> SecurityCode -> Bool
/= :: SecurityCode -> SecurityCode -> Bool
Eq, Int -> SecurityCode -> ShowS
[SecurityCode] -> ShowS
SecurityCode -> String
(Int -> SecurityCode -> ShowS)
-> (SecurityCode -> String)
-> ([SecurityCode] -> ShowS)
-> Show SecurityCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SecurityCode -> ShowS
showsPrec :: Int -> SecurityCode -> ShowS
$cshow :: SecurityCode -> String
show :: SecurityCode -> String
$cshowList :: [SecurityCode] -> ShowS
showList :: [SecurityCode] -> ShowS
Show)
verificationCode :: ByteString -> Text
verificationCode :: ByteString -> Text
verificationCode = String -> Text
T.pack (String -> Text) -> (ByteString -> String) -> ByteString -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
unwords ([String] -> String)
-> (ByteString -> [String]) -> ByteString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> [String]
forall {a}. Int -> [a] -> [[a]]
chunks Int
5 (String -> [String])
-> (ByteString -> String) -> ByteString -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> String
forall a. Show a => a -> String
show (Integer -> String)
-> (ByteString -> Integer) -> ByteString -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Integer
forall ba. ByteArrayAccess ba => ba -> Integer
os2ip
where
chunks :: Int -> [a] -> [[a]]
chunks Int
_ [] = []
chunks Int
n [a]
xs = let ([a]
h, [a]
t) = Int -> [a] -> ([a], [a])
forall a. Int -> [a] -> ([a], [a])
splitAt Int
n [a]
xs in [a]
h [a] -> [[a]] -> [[a]]
forall a. a -> [a] -> [a]
: Int -> [a] -> [[a]]
chunks Int
n [a]
t
sameVerificationCode :: Text -> Text -> Bool
sameVerificationCode :: Text -> Text -> Bool
sameVerificationCode Text
c1 Text
c2 = Text -> Text
noSpaces Text
c1 Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text -> Text
noSpaces Text
c2
where
noSpaces :: Text -> Text
noSpaces = (Char -> Bool) -> Text -> Text
T.filter (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
' ')
aConnId :: Connection -> ConnId
aConnId :: Connection -> ByteString
aConnId Connection {agentConnId :: Connection -> AgentConnId
agentConnId = AgentConnId ByteString
cId} = ByteString
cId
connIncognito :: Connection -> Bool
connIncognito :: Connection -> Bool
connIncognito Connection {Maybe CommandId
customUserProfileId :: Connection -> Maybe CommandId
customUserProfileId :: Maybe CommandId
customUserProfileId} = Maybe CommandId -> Bool
forall a. Maybe a -> Bool
isJust Maybe CommandId
customUserProfileId
connPQEnabled :: Connection -> PQEncryption
connPQEnabled :: Connection -> PQEncryption
connPQEnabled Connection {pqSndEnabled :: Connection -> Maybe PQEncryption
pqSndEnabled = Just (PQEncryption Bool
s), pqRcvEnabled :: Connection -> Maybe PQEncryption
pqRcvEnabled = Just (PQEncryption Bool
r)} = Bool -> PQEncryption
PQEncryption (Bool -> PQEncryption) -> Bool -> PQEncryption
forall a b. (a -> b) -> a -> b
$ Bool
s Bool -> Bool -> Bool
&& Bool
r
connPQEnabled Connection
_ = PQEncryption
PQEncOff
data PendingContactConnection = PendingContactConnection
{ PendingContactConnection -> CommandId
pccConnId :: Int64,
PendingContactConnection -> AgentConnId
pccAgentConnId :: AgentConnId,
PendingContactConnection -> ConnStatus
pccConnStatus :: ConnStatus,
PendingContactConnection -> Bool
viaContactUri :: Bool,
PendingContactConnection -> Maybe CommandId
viaUserContactLink :: Maybe Int64,
PendingContactConnection -> Maybe GroupLinkId
groupLinkId :: Maybe GroupLinkId,
PendingContactConnection -> Maybe CommandId
customUserProfileId :: Maybe Int64,
PendingContactConnection -> Maybe CreatedLinkInvitation
connLinkInv :: Maybe CreatedLinkInvitation,
PendingContactConnection -> Text
localAlias :: Text,
PendingContactConnection -> UTCTime
createdAt :: UTCTime,
PendingContactConnection -> UTCTime
updatedAt :: UTCTime
}
deriving (PendingContactConnection -> PendingContactConnection -> Bool
(PendingContactConnection -> PendingContactConnection -> Bool)
-> (PendingContactConnection -> PendingContactConnection -> Bool)
-> Eq PendingContactConnection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PendingContactConnection -> PendingContactConnection -> Bool
== :: PendingContactConnection -> PendingContactConnection -> Bool
$c/= :: PendingContactConnection -> PendingContactConnection -> Bool
/= :: PendingContactConnection -> PendingContactConnection -> Bool
Eq, Int -> PendingContactConnection -> ShowS
[PendingContactConnection] -> ShowS
PendingContactConnection -> String
(Int -> PendingContactConnection -> ShowS)
-> (PendingContactConnection -> String)
-> ([PendingContactConnection] -> ShowS)
-> Show PendingContactConnection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PendingContactConnection -> ShowS
showsPrec :: Int -> PendingContactConnection -> ShowS
$cshow :: PendingContactConnection -> String
show :: PendingContactConnection -> String
$cshowList :: [PendingContactConnection] -> ShowS
showList :: [PendingContactConnection] -> ShowS
Show)
mkPendingContactConnection :: Connection -> Maybe CreatedLinkInvitation -> PendingContactConnection
mkPendingContactConnection :: Connection
-> Maybe CreatedLinkInvitation -> PendingContactConnection
mkPendingContactConnection Connection {CommandId
connId :: Connection -> CommandId
connId :: CommandId
connId, AgentConnId
agentConnId :: Connection -> AgentConnId
agentConnId :: AgentConnId
agentConnId, ConnStatus
connStatus :: Connection -> ConnStatus
connStatus :: ConnStatus
connStatus, Maybe XContactId
xContactId :: Connection -> Maybe XContactId
xContactId :: Maybe XContactId
xContactId, Maybe CommandId
viaUserContactLink :: Connection -> Maybe CommandId
viaUserContactLink :: Maybe CommandId
viaUserContactLink, Maybe GroupLinkId
groupLinkId :: Connection -> Maybe GroupLinkId
groupLinkId :: Maybe GroupLinkId
groupLinkId, Maybe CommandId
customUserProfileId :: Connection -> Maybe CommandId
customUserProfileId :: Maybe CommandId
customUserProfileId, Text
localAlias :: Connection -> Text
localAlias :: Text
localAlias, UTCTime
createdAt :: Connection -> UTCTime
createdAt :: UTCTime
createdAt} Maybe CreatedLinkInvitation
connLinkInv =
PendingContactConnection
{ pccConnId :: CommandId
pccConnId = CommandId
connId,
pccAgentConnId :: AgentConnId
pccAgentConnId = AgentConnId
agentConnId,
pccConnStatus :: ConnStatus
pccConnStatus = ConnStatus
connStatus,
viaContactUri :: Bool
viaContactUri = Maybe XContactId -> Bool
forall a. Maybe a -> Bool
isJust Maybe XContactId
xContactId,
Maybe CommandId
viaUserContactLink :: Maybe CommandId
viaUserContactLink :: Maybe CommandId
viaUserContactLink,
Maybe GroupLinkId
groupLinkId :: Maybe GroupLinkId
groupLinkId :: Maybe GroupLinkId
groupLinkId,
Maybe CommandId
customUserProfileId :: Maybe CommandId
customUserProfileId :: Maybe CommandId
customUserProfileId,
Maybe CreatedLinkInvitation
connLinkInv :: Maybe CreatedLinkInvitation
connLinkInv :: Maybe CreatedLinkInvitation
connLinkInv,
Text
localAlias :: Text
localAlias :: Text
localAlias,
UTCTime
createdAt :: UTCTime
createdAt :: UTCTime
createdAt,
updatedAt :: UTCTime
updatedAt = UTCTime
createdAt
}
aConnId' :: PendingContactConnection -> ConnId
aConnId' :: PendingContactConnection -> ByteString
aConnId' PendingContactConnection {pccAgentConnId :: PendingContactConnection -> AgentConnId
pccAgentConnId = AgentConnId ByteString
cId} = ByteString
cId
data ConnStatus
=
ConnNew
|
ConnPrepared
|
ConnJoined
|
ConnRequested
|
ConnAccepted
|
ConnSndReady
|
ConnReady
|
ConnDeleted
deriving (ConnStatus -> ConnStatus -> Bool
(ConnStatus -> ConnStatus -> Bool)
-> (ConnStatus -> ConnStatus -> Bool) -> Eq ConnStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnStatus -> ConnStatus -> Bool
== :: ConnStatus -> ConnStatus -> Bool
$c/= :: ConnStatus -> ConnStatus -> Bool
/= :: ConnStatus -> ConnStatus -> Bool
Eq, Int -> ConnStatus -> ShowS
[ConnStatus] -> ShowS
ConnStatus -> String
(Int -> ConnStatus -> ShowS)
-> (ConnStatus -> String)
-> ([ConnStatus] -> ShowS)
-> Show ConnStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnStatus -> ShowS
showsPrec :: Int -> ConnStatus -> ShowS
$cshow :: ConnStatus -> String
show :: ConnStatus -> String
$cshowList :: [ConnStatus] -> ShowS
showList :: [ConnStatus] -> ShowS
Show, ReadPrec [ConnStatus]
ReadPrec ConnStatus
Int -> ReadS ConnStatus
ReadS [ConnStatus]
(Int -> ReadS ConnStatus)
-> ReadS [ConnStatus]
-> ReadPrec ConnStatus
-> ReadPrec [ConnStatus]
-> Read ConnStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ConnStatus
readsPrec :: Int -> ReadS ConnStatus
$creadList :: ReadS [ConnStatus]
readList :: ReadS [ConnStatus]
$creadPrec :: ReadPrec ConnStatus
readPrec :: ReadPrec ConnStatus
$creadListPrec :: ReadPrec [ConnStatus]
readListPrec :: ReadPrec [ConnStatus]
Read)
instance FromField ConnStatus where fromField :: FieldParser ConnStatus
fromField = (Text -> Maybe ConnStatus) -> FieldParser ConnStatus
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe ConnStatus
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField ConnStatus where toField :: ConnStatus -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData) -> (ConnStatus -> Text) -> ConnStatus -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromJSON ConnStatus where
parseJSON :: Value -> Parser ConnStatus
parseJSON = String -> Value -> Parser ConnStatus
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"ConnStatus"
instance ToJSON ConnStatus where
toJSON :: ConnStatus -> Value
toJSON = Text -> Value
J.String (Text -> Value) -> (ConnStatus -> Text) -> ConnStatus -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: ConnStatus -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding)
-> (ConnStatus -> Text) -> ConnStatus -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding ConnStatus where
textDecode :: Text -> Maybe ConnStatus
textDecode = \case
Text
"new" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnNew
Text
"prepared" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnPrepared
Text
"joined" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnJoined
Text
"requested" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnRequested
Text
"accepted" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnAccepted
Text
"snd-ready" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnSndReady
Text
"ready" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnReady
Text
"deleted" -> ConnStatus -> Maybe ConnStatus
forall a. a -> Maybe a
Just ConnStatus
ConnDeleted
Text
_ -> Maybe ConnStatus
forall a. Maybe a
Nothing
textEncode :: ConnStatus -> Text
textEncode = \case
ConnStatus
ConnNew -> Text
"new"
ConnStatus
ConnPrepared -> Text
"prepared"
ConnStatus
ConnJoined -> Text
"joined"
ConnStatus
ConnRequested -> Text
"requested"
ConnStatus
ConnAccepted -> Text
"accepted"
ConnStatus
ConnSndReady -> Text
"snd-ready"
ConnStatus
ConnReady -> Text
"ready"
ConnStatus
ConnDeleted -> Text
"deleted"
data ConnType = ConnContact | ConnMember | ConnUserContact
deriving (ConnType -> ConnType -> Bool
(ConnType -> ConnType -> Bool)
-> (ConnType -> ConnType -> Bool) -> Eq ConnType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnType -> ConnType -> Bool
== :: ConnType -> ConnType -> Bool
$c/= :: ConnType -> ConnType -> Bool
/= :: ConnType -> ConnType -> Bool
Eq, Int -> ConnType -> ShowS
[ConnType] -> ShowS
ConnType -> String
(Int -> ConnType -> ShowS)
-> (ConnType -> String) -> ([ConnType] -> ShowS) -> Show ConnType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnType -> ShowS
showsPrec :: Int -> ConnType -> ShowS
$cshow :: ConnType -> String
show :: ConnType -> String
$cshowList :: [ConnType] -> ShowS
showList :: [ConnType] -> ShowS
Show)
instance FromField ConnType where fromField :: FieldParser ConnType
fromField = (Text -> Maybe ConnType) -> FieldParser ConnType
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe ConnType
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField ConnType where toField :: ConnType -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData) -> (ConnType -> Text) -> ConnType -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnType -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance FromJSON ConnType where
parseJSON :: Value -> Parser ConnType
parseJSON = String -> Value -> Parser ConnType
forall a. TextEncoding a => String -> Value -> Parser a
textParseJSON String
"ConnType"
instance ToJSON ConnType where
toJSON :: ConnType -> Value
toJSON = Text -> Value
J.String (Text -> Value) -> (ConnType -> Text) -> ConnType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnType -> Text
forall a. TextEncoding a => a -> Text
textEncode
toEncoding :: ConnType -> Encoding
toEncoding = Text -> Encoding
forall a. Text -> Encoding' a
JE.text (Text -> Encoding) -> (ConnType -> Text) -> ConnType -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConnType -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding ConnType where
textDecode :: Text -> Maybe ConnType
textDecode = \case
Text
"contact" -> ConnType -> Maybe ConnType
forall a. a -> Maybe a
Just ConnType
ConnContact
Text
"member" -> ConnType -> Maybe ConnType
forall a. a -> Maybe a
Just ConnType
ConnMember
Text
"user_contact" -> ConnType -> Maybe ConnType
forall a. a -> Maybe a
Just ConnType
ConnUserContact
Text
_ -> Maybe ConnType
forall a. Maybe a
Nothing
textEncode :: ConnType -> Text
textEncode = \case
ConnType
ConnContact -> Text
"contact"
ConnType
ConnMember -> Text
"member"
ConnType
ConnUserContact -> Text
"user_contact"
type CommandId = Int64
aCorrId :: CommandId -> ACorrId
aCorrId :: CommandId -> ByteString
aCorrId = String -> ByteString
pack (String -> ByteString)
-> (CommandId -> String) -> CommandId -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommandId -> String
forall a. Show a => a -> String
show
commandId :: ACorrId -> String
commandId :: ByteString -> String
commandId = ByteString -> String
unpack
data CommandStatus
= CSCreated
| CSCompleted
| CSError
deriving (Int -> CommandStatus -> ShowS
[CommandStatus] -> ShowS
CommandStatus -> String
(Int -> CommandStatus -> ShowS)
-> (CommandStatus -> String)
-> ([CommandStatus] -> ShowS)
-> Show CommandStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommandStatus -> ShowS
showsPrec :: Int -> CommandStatus -> ShowS
$cshow :: CommandStatus -> String
show :: CommandStatus -> String
$cshowList :: [CommandStatus] -> ShowS
showList :: [CommandStatus] -> ShowS
Show)
instance FromField CommandStatus where fromField :: FieldParser CommandStatus
fromField = (Text -> Maybe CommandStatus) -> FieldParser CommandStatus
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe CommandStatus
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField CommandStatus where toField :: CommandStatus -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (CommandStatus -> Text) -> CommandStatus -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommandStatus -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding CommandStatus where
textDecode :: Text -> Maybe CommandStatus
textDecode = \case
Text
"created" -> CommandStatus -> Maybe CommandStatus
forall a. a -> Maybe a
Just CommandStatus
CSCreated
Text
"completed" -> CommandStatus -> Maybe CommandStatus
forall a. a -> Maybe a
Just CommandStatus
CSCompleted
Text
"error" -> CommandStatus -> Maybe CommandStatus
forall a. a -> Maybe a
Just CommandStatus
CSError
Text
_ -> Maybe CommandStatus
forall a. Maybe a
Nothing
textEncode :: CommandStatus -> Text
textEncode = \case
CommandStatus
CSCreated -> Text
"created"
CommandStatus
CSCompleted -> Text
"completed"
CommandStatus
CSError -> Text
"error"
data CommandFunction
= CFCreateConnGrpMemInv
| CFCreateConnGrpInv
| CFCreateConnFileInvDirect
| CFCreateConnFileInvGroup
| CFJoinConn
| CFAllowConn
| CFAcceptContact
| CFAckMessage
| CFDeleteConn
deriving (CommandFunction -> CommandFunction -> Bool
(CommandFunction -> CommandFunction -> Bool)
-> (CommandFunction -> CommandFunction -> Bool)
-> Eq CommandFunction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommandFunction -> CommandFunction -> Bool
== :: CommandFunction -> CommandFunction -> Bool
$c/= :: CommandFunction -> CommandFunction -> Bool
/= :: CommandFunction -> CommandFunction -> Bool
Eq, Int -> CommandFunction -> ShowS
[CommandFunction] -> ShowS
CommandFunction -> String
(Int -> CommandFunction -> ShowS)
-> (CommandFunction -> String)
-> ([CommandFunction] -> ShowS)
-> Show CommandFunction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommandFunction -> ShowS
showsPrec :: Int -> CommandFunction -> ShowS
$cshow :: CommandFunction -> String
show :: CommandFunction -> String
$cshowList :: [CommandFunction] -> ShowS
showList :: [CommandFunction] -> ShowS
Show)
instance FromField CommandFunction where fromField :: FieldParser CommandFunction
fromField = (Text -> Maybe CommandFunction) -> FieldParser CommandFunction
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe CommandFunction
forall a. TextEncoding a => Text -> Maybe a
textDecode
instance ToField CommandFunction where toField :: CommandFunction -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (CommandFunction -> Text) -> CommandFunction -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommandFunction -> Text
forall a. TextEncoding a => a -> Text
textEncode
instance TextEncoding CommandFunction where
textDecode :: Text -> Maybe CommandFunction
textDecode = \case
Text
"create_conn" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFCreateConnGrpMemInv
Text
"create_conn_grp_inv" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFCreateConnGrpInv
Text
"create_conn_file_inv_direct" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFCreateConnFileInvDirect
Text
"create_conn_file_inv_group" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFCreateConnFileInvGroup
Text
"join_conn" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFJoinConn
Text
"allow_conn" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFAllowConn
Text
"accept_contact" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFAcceptContact
Text
"ack_message" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFAckMessage
Text
"delete_conn" -> CommandFunction -> Maybe CommandFunction
forall a. a -> Maybe a
Just CommandFunction
CFDeleteConn
Text
_ -> Maybe CommandFunction
forall a. Maybe a
Nothing
textEncode :: CommandFunction -> Text
textEncode = \case
CommandFunction
CFCreateConnGrpMemInv -> Text
"create_conn"
CommandFunction
CFCreateConnGrpInv -> Text
"create_conn_grp_inv"
CommandFunction
CFCreateConnFileInvDirect -> Text
"create_conn_file_inv_direct"
CommandFunction
CFCreateConnFileInvGroup -> Text
"create_conn_file_inv_group"
CommandFunction
CFJoinConn -> Text
"join_conn"
CommandFunction
CFAllowConn -> Text
"allow_conn"
CommandFunction
CFAcceptContact -> Text
"accept_contact"
CommandFunction
CFAckMessage -> Text
"ack_message"
CommandFunction
CFDeleteConn -> Text
"delete_conn"
commandExpectedResponse :: CommandFunction -> AEvtTag
commandExpectedResponse :: CommandFunction -> AEvtTag
commandExpectedResponse = \case
CommandFunction
CFCreateConnGrpMemInv -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
INV_
CommandFunction
CFCreateConnGrpInv -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
INV_
CommandFunction
CFCreateConnFileInvDirect -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
INV_
CommandFunction
CFCreateConnFileInvGroup -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
INV_
CommandFunction
CFJoinConn -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
JOINED_
CommandFunction
CFAllowConn -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
OK_
CommandFunction
CFAcceptContact -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
JOINED_
CommandFunction
CFAckMessage -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
OK_
CommandFunction
CFDeleteConn -> AEventTag 'AEConn -> AEvtTag
t AEventTag 'AEConn
OK_
where
t :: AEventTag 'AEConn -> AEvtTag
t = SAEntity 'AEConn -> AEventTag 'AEConn -> AEvtTag
forall (e :: AEntity).
AEntityI e =>
SAEntity e -> AEventTag e -> AEvtTag
AEvtTag SAEntity 'AEConn
SAEConn
data CommandData = CommandData
{ CommandData -> CommandId
cmdId :: CommandId,
CommandData -> Maybe CommandId
cmdConnId :: Maybe Int64,
CommandData -> CommandFunction
cmdFunction :: CommandFunction,
CommandData -> CommandStatus
cmdStatus :: CommandStatus
}
deriving (Int -> CommandData -> ShowS
[CommandData] -> ShowS
CommandData -> String
(Int -> CommandData -> ShowS)
-> (CommandData -> String)
-> ([CommandData] -> ShowS)
-> Show CommandData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommandData -> ShowS
showsPrec :: Int -> CommandData -> ShowS
$cshow :: CommandData -> String
show :: CommandData -> String
$cshowList :: [CommandData] -> ShowS
showList :: [CommandData] -> ShowS
Show)
data ChatTag = ChatTag
{ ChatTag -> CommandId
chatTagId :: Int64,
ChatTag -> Text
chatTagText :: Text,
ChatTag -> Maybe Text
chatTagEmoji :: Maybe Text
}
deriving (Int -> ChatTag -> ShowS
[ChatTag] -> ShowS
ChatTag -> String
(Int -> ChatTag -> ShowS)
-> (ChatTag -> String) -> ([ChatTag] -> ShowS) -> Show ChatTag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatTag -> ShowS
showsPrec :: Int -> ChatTag -> ShowS
$cshow :: ChatTag -> String
show :: ChatTag -> String
$cshowList :: [ChatTag] -> ShowS
showList :: [ChatTag] -> ShowS
Show)
data XGrpMemIntroCont = XGrpMemIntroCont
{ XGrpMemIntroCont -> CommandId
groupId :: GroupId,
XGrpMemIntroCont -> CommandId
groupMemberId :: GroupMemberId,
XGrpMemIntroCont -> MemberId
memberId :: MemberId,
XGrpMemIntroCont -> ConnReqInvitation
groupConnReq :: ConnReqInvitation
}
deriving (Int -> XGrpMemIntroCont -> ShowS
[XGrpMemIntroCont] -> ShowS
XGrpMemIntroCont -> String
(Int -> XGrpMemIntroCont -> ShowS)
-> (XGrpMemIntroCont -> String)
-> ([XGrpMemIntroCont] -> ShowS)
-> Show XGrpMemIntroCont
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XGrpMemIntroCont -> ShowS
showsPrec :: Int -> XGrpMemIntroCont -> ShowS
$cshow :: XGrpMemIntroCont -> String
show :: XGrpMemIntroCont -> String
$cshowList :: [XGrpMemIntroCont] -> ShowS
showList :: [XGrpMemIntroCont] -> ShowS
Show)
data NoteFolder = NoteFolder
{ NoteFolder -> CommandId
noteFolderId :: NoteFolderId,
NoteFolder -> CommandId
userId :: UserId,
NoteFolder -> UTCTime
createdAt :: UTCTime,
NoteFolder -> UTCTime
updatedAt :: UTCTime,
NoteFolder -> UTCTime
chatTs :: UTCTime,
NoteFolder -> Bool
favorite :: Bool,
NoteFolder -> Bool
unread :: Bool
}
deriving (NoteFolder -> NoteFolder -> Bool
(NoteFolder -> NoteFolder -> Bool)
-> (NoteFolder -> NoteFolder -> Bool) -> Eq NoteFolder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NoteFolder -> NoteFolder -> Bool
== :: NoteFolder -> NoteFolder -> Bool
$c/= :: NoteFolder -> NoteFolder -> Bool
/= :: NoteFolder -> NoteFolder -> Bool
Eq, Int -> NoteFolder -> ShowS
[NoteFolder] -> ShowS
NoteFolder -> String
(Int -> NoteFolder -> ShowS)
-> (NoteFolder -> String)
-> ([NoteFolder] -> ShowS)
-> Show NoteFolder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NoteFolder -> ShowS
showsPrec :: Int -> NoteFolder -> ShowS
$cshow :: NoteFolder -> String
show :: NoteFolder -> String
$cshowList :: [NoteFolder] -> ShowS
showList :: [NoteFolder] -> ShowS
Show)
type NoteFolderId = Int64
data ChatVersion
instance VersionScope ChatVersion
type VersionChat = Version ChatVersion
type VersionRangeChat = VersionRange ChatVersion
pattern VersionChat :: Word16 -> VersionChat
pattern $mVersionChat :: forall {r}.
Version ChatVersion -> (Word16 -> r) -> ((# #) -> r) -> r
$bVersionChat :: Word16 -> Version ChatVersion
VersionChat v = Version v
newtype ChatVersionRange = ChatVersionRange {ChatVersionRange -> VersionRangeChat
fromChatVRange :: VersionRangeChat} deriving (ChatVersionRange -> ChatVersionRange -> Bool
(ChatVersionRange -> ChatVersionRange -> Bool)
-> (ChatVersionRange -> ChatVersionRange -> Bool)
-> Eq ChatVersionRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatVersionRange -> ChatVersionRange -> Bool
== :: ChatVersionRange -> ChatVersionRange -> Bool
$c/= :: ChatVersionRange -> ChatVersionRange -> Bool
/= :: ChatVersionRange -> ChatVersionRange -> Bool
Eq, Int -> ChatVersionRange -> ShowS
[ChatVersionRange] -> ShowS
ChatVersionRange -> String
(Int -> ChatVersionRange -> ShowS)
-> (ChatVersionRange -> String)
-> ([ChatVersionRange] -> ShowS)
-> Show ChatVersionRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatVersionRange -> ShowS
showsPrec :: Int -> ChatVersionRange -> ShowS
$cshow :: ChatVersionRange -> String
show :: ChatVersionRange -> String
$cshowList :: [ChatVersionRange] -> ShowS
showList :: [ChatVersionRange] -> ShowS
Show)
peerConnChatVersion :: VersionRangeChat -> VersionRangeChat -> VersionChat
peerConnChatVersion :: VersionRangeChat -> VersionRangeChat -> Version ChatVersion
peerConnChatVersion _local :: VersionRangeChat
_local@(VersionRange Version ChatVersion
lmin Version ChatVersion
lmax) _peer :: VersionRangeChat
_peer@(VersionRange Version ChatVersion
rmin Version ChatVersion
rmax)
| Version ChatVersion
lmin Version ChatVersion -> Version ChatVersion -> Bool
forall a. Ord a => a -> a -> Bool
<= Version ChatVersion
rmax Bool -> Bool -> Bool
&& Version ChatVersion
rmin Version ChatVersion -> Version ChatVersion -> Bool
forall a. Ord a => a -> a -> Bool
<= Version ChatVersion
lmax = Version ChatVersion -> Version ChatVersion -> Version ChatVersion
forall a. Ord a => a -> a -> a
min Version ChatVersion
lmax Version ChatVersion
rmax
| Version ChatVersion
rmin Version ChatVersion -> Version ChatVersion -> Bool
forall a. Ord a => a -> a -> Bool
> Version ChatVersion
lmax = Version ChatVersion
rmin
| Bool
otherwise = Version ChatVersion
rmax
initialChatVersion :: VersionChat
initialChatVersion :: Version ChatVersion
initialChatVersion = Word16 -> Version ChatVersion
VersionChat Word16
1
chatInitialVRange :: VersionRangeChat
chatInitialVRange :: VersionRangeChat
chatInitialVRange = Version ChatVersion -> VersionRangeChat
forall v. Version v -> VersionRange v
versionToRange Version ChatVersion
initialChatVersion
instance FromJSON ChatVersionRange where
parseJSON :: Value -> Parser ChatVersionRange
parseJSON Value
v = VersionRangeChat -> ChatVersionRange
ChatVersionRange (VersionRangeChat -> ChatVersionRange)
-> Parser VersionRangeChat -> Parser ChatVersionRange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Value -> Parser VersionRangeChat
forall a. StrEncoding a => String -> Value -> Parser a
strParseJSON String
"ChatVersionRange" Value
v
instance ToJSON ChatVersionRange where
toJSON :: ChatVersionRange -> Value
toJSON (ChatVersionRange VersionRangeChat
vr) = VersionRangeChat -> Value
forall a. StrEncoding a => a -> Value
strToJSON VersionRangeChat
vr
toEncoding :: ChatVersionRange -> Encoding
toEncoding (ChatVersionRange VersionRangeChat
vr) = VersionRangeChat -> Encoding
forall a. StrEncoding a => a -> Encoding
strToJEncoding VersionRangeChat
vr
newtype BoolDef = BoolDef {BoolDef -> Bool
isTrue :: Bool}
deriving newtype (BoolDef -> BoolDef -> Bool
(BoolDef -> BoolDef -> Bool)
-> (BoolDef -> BoolDef -> Bool) -> Eq BoolDef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BoolDef -> BoolDef -> Bool
== :: BoolDef -> BoolDef -> Bool
$c/= :: BoolDef -> BoolDef -> Bool
/= :: BoolDef -> BoolDef -> Bool
Eq, Int -> BoolDef -> ShowS
[BoolDef] -> ShowS
BoolDef -> String
(Int -> BoolDef -> ShowS)
-> (BoolDef -> String) -> ([BoolDef] -> ShowS) -> Show BoolDef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BoolDef -> ShowS
showsPrec :: Int -> BoolDef -> ShowS
$cshow :: BoolDef -> String
show :: BoolDef -> String
$cshowList :: [BoolDef] -> ShowS
showList :: [BoolDef] -> ShowS
Show, [BoolDef] -> Encoding
[BoolDef] -> Value
BoolDef -> Bool
BoolDef -> Encoding
BoolDef -> Value
(BoolDef -> Value)
-> (BoolDef -> Encoding)
-> ([BoolDef] -> Value)
-> ([BoolDef] -> Encoding)
-> (BoolDef -> Bool)
-> ToJSON BoolDef
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: BoolDef -> Value
toJSON :: BoolDef -> Value
$ctoEncoding :: BoolDef -> Encoding
toEncoding :: BoolDef -> Encoding
$ctoJSONList :: [BoolDef] -> Value
toJSONList :: [BoolDef] -> Value
$ctoEncodingList :: [BoolDef] -> Encoding
toEncodingList :: [BoolDef] -> Encoding
$comitField :: BoolDef -> Bool
omitField :: BoolDef -> Bool
ToJSON)
instance FromJSON BoolDef where
parseJSON :: Value -> Parser BoolDef
parseJSON Value
v = Bool -> BoolDef
BoolDef (Bool -> BoolDef) -> Parser Bool -> Parser BoolDef
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Bool
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
omittedField :: Maybe BoolDef
omittedField = BoolDef -> Maybe BoolDef
forall a. a -> Maybe a
Just (Bool -> BoolDef
BoolDef Bool
False)
$(JQ.deriveJSON defaultJSON ''UserContact)
$(JQ.deriveJSON defaultJSON ''Profile)
$(JQ.deriveJSON defaultJSON ''LocalProfile)
$(JQ.deriveJSON defaultJSON ''UserContactRequest)
$(JQ.deriveJSON (enumJSON $ dropPrefix "MC") {J.tagSingleConstructors = True} ''MemberCriteria)
$(JQ.deriveJSON defaultJSON ''GroupMemberAdmission)
instance ToField GroupMemberAdmission where
toField :: GroupMemberAdmission -> SQLData
toField = Text -> SQLData
forall a. ToField a => a -> SQLData
toField (Text -> SQLData)
-> (GroupMemberAdmission -> Text)
-> GroupMemberAdmission
-> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GroupMemberAdmission -> Text
forall a. ToJSON a => a -> Text
encodeJSON
instance FromField GroupMemberAdmission where
fromField :: FieldParser GroupMemberAdmission
fromField = (Text -> Maybe GroupMemberAdmission)
-> FieldParser GroupMemberAdmission
forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a
fromTextField_ Text -> Maybe GroupMemberAdmission
forall a. FromJSON a => Text -> Maybe a
decodeJSON
$(JQ.deriveJSON defaultJSON ''GroupProfile)
$(JQ.deriveJSON (sumTypeJSON $ dropPrefix "IB") ''InvitedBy)
$(JQ.deriveJSON defaultJSON ''GroupMemberSettings)
$(JQ.deriveJSON defaultJSON ''SecurityCode)
$(JQ.deriveJSON defaultJSON ''Connection)
$(JQ.deriveJSON defaultJSON ''PendingContactConnection)
$(JQ.deriveJSON defaultJSON ''GroupSupportChat)
$(JQ.deriveJSON defaultJSON ''GroupMember)
$(JQ.deriveJSON (enumJSON $ dropPrefix "MF") ''MsgFilter)
$(JQ.deriveJSON defaultJSON ''ChatSettings)
$(JQ.deriveJSON (enumJSON $ dropPrefix "BC") ''BusinessChatType)
$(JQ.deriveJSON defaultJSON ''BusinessChatInfo)
$(JQ.deriveJSON defaultJSON ''PreparedGroup)
$(JQ.deriveToJSON defaultJSON ''GroupSummary)
instance FromJSON GroupSummary where
parseJSON :: Value -> Parser GroupSummary
parseJSON = $(JQ.mkParseJSON defaultJSON ''GroupSummary)
omittedField :: Maybe GroupSummary
omittedField = GroupSummary -> Maybe GroupSummary
forall a. a -> Maybe a
Just GroupSummary {currentMembers :: CommandId
currentMembers = CommandId
0}
$(JQ.deriveJSON defaultJSON ''GroupInfo)
$(JQ.deriveJSON defaultJSON ''Group)
$(JQ.deriveJSON defaultJSON ''GroupLink)
instance FromField MsgFilter where fromField :: FieldParser MsgFilter
fromField = (CommandId -> Maybe MsgFilter) -> FieldParser MsgFilter
forall a. Typeable a => (CommandId -> Maybe a) -> FieldParser a
fromIntField_ CommandId -> Maybe MsgFilter
msgFilterIntP
instance ToField MsgFilter where toField :: MsgFilter -> SQLData
toField = Int -> SQLData
forall a. ToField a => a -> SQLData
toField (Int -> SQLData) -> (MsgFilter -> Int) -> MsgFilter -> SQLData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MsgFilter -> Int
msgFilterInt
$(JQ.deriveJSON defaultJSON ''CReqClientData)
$(JQ.deriveJSON defaultJSON ''MemberIdRole)
$(JQ.deriveJSON defaultJSON ''MemberInfo)
$(JQ.deriveJSON defaultJSON ''GroupInvitation)
$(JQ.deriveJSON defaultJSON ''GroupLinkInvitation)
$(JQ.deriveJSON defaultJSON ''GroupLinkRejection)
$(JQ.deriveJSON defaultJSON ''IntroInvitation)
$(JQ.deriveJSON defaultJSON ''MemberRestrictions)
$(JQ.deriveJSON defaultJSON ''GroupMemberRef)
$(JQ.deriveJSON defaultJSON ''FileDescr)
$(JQ.deriveJSON defaultJSON ''FileInvitation)
$(JQ.deriveJSON defaultJSON ''SndFileTransfer)
$(JQ.deriveJSON defaultJSON ''RcvFileDescr)
$(JQ.deriveJSON defaultJSON ''XFTPRcvFile)
$(JQ.deriveJSON (sumTypeJSON $ dropPrefix "RFS") ''RcvFileStatus)
$(JQ.deriveJSON defaultJSON ''RcvFileTransfer)
$(JQ.deriveJSON defaultJSON ''XFTPSndFile)
$(JQ.deriveJSON defaultJSON ''FileTransferMeta)
$(JQ.deriveJSON defaultJSON ''PreparedContact)
$(JQ.deriveJSON defaultJSON ''GroupDirectInvitation)
$(JQ.deriveJSON defaultJSON ''LocalFileMeta)
$(JQ.deriveJSON (sumTypeJSON $ dropPrefix "FT") ''FileTransfer)
$(JQ.deriveJSON defaultJSON ''UserPwdHash)
$(JQ.deriveJSON defaultJSON ''User)
$(JQ.deriveJSON defaultJSON ''NewUser)
$(JQ.deriveJSON defaultJSON ''UserInfo)
$(JQ.deriveJSON defaultJSON ''Contact)
$(JQ.deriveJSON defaultJSON ''ContactRef)
$(JQ.deriveJSON defaultJSON ''NoteFolder)
$(JQ.deriveJSON defaultJSON ''ChatTag)