-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Galley.Cassandra.SubConversation (interpretSubConversationStoreToCassandra) where

import Cassandra
import Cassandra.Util
import Control.Monad.Trans.Maybe
import Data.Id
import Data.Map qualified as Map
import Galley.API.MLS.Types
import Galley.Cassandra.Conversation.MLS
import Galley.Cassandra.Queries qualified as Cql
import Galley.Cassandra.Store (embedClient)
import Galley.Cassandra.Util
import Galley.Effects.SubConversationStore (SubConversationStore (..))
import Imports
import Polysemy
import Polysemy.Input
import Polysemy.TinyLog
import Wire.API.Conversation.Protocol
import Wire.API.MLS.CipherSuite
import Wire.API.MLS.Group
import Wire.API.MLS.GroupInfo
import Wire.API.MLS.SubConversation

selectSubConversation :: ConvId -> SubConvId -> Client (Maybe SubConversation)
selectSubConversation :: ConvId -> SubConvId -> Client (Maybe SubConversation)
selectSubConversation ConvId
convId SubConvId
subConvId = MaybeT Client SubConversation -> Client (Maybe SubConversation)
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT (MaybeT Client SubConversation -> Client (Maybe SubConversation))
-> MaybeT Client SubConversation -> Client (Maybe SubConversation)
forall a b. (a -> b) -> a -> b
$ do
  (Maybe CipherSuiteTag
mSuite, Maybe Epoch
mEpoch, Maybe (Writetime Epoch)
mEpochWritetime, Maybe GroupId
mGroupId) <-
    Client
  (Maybe
     (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
      Maybe GroupId))
-> MaybeT
     Client
     (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
      Maybe GroupId)
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (Client
   (Maybe
      (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
       Maybe GroupId))
 -> MaybeT
      Client
      (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
       Maybe GroupId))
-> Client
     (Maybe
        (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
         Maybe GroupId))
-> MaybeT
     Client
     (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
      Maybe GroupId)
forall a b. (a -> b) -> a -> b
$
      RetrySettings
-> Client
     (Maybe
        (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
         Maybe GroupId))
-> Client
     (Maybe
        (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
         Maybe GroupId))
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x5 (PrepQuery
  R
  (ConvId, SubConvId)
  (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
   Maybe GroupId)
-> QueryParams (ConvId, SubConvId)
-> Client
     (Maybe
        (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
         Maybe GroupId))
forall (m :: * -> *) a b (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, Tuple b, RunQ q) =>
q R a b -> QueryParams a -> m (Maybe b)
query1 PrepQuery
  R
  (ConvId, SubConvId)
  (Maybe CipherSuiteTag, Maybe Epoch, Maybe (Writetime Epoch),
   Maybe GroupId)
Cql.selectSubConversation (Consistency
-> (ConvId, SubConvId) -> QueryParams (ConvId, SubConvId)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (ConvId
convId, SubConvId
subConvId)))
  let activeData :: Maybe ActiveMLSConversationData
activeData =
        Epoch -> UTCTime -> CipherSuiteTag -> ActiveMLSConversationData
ActiveMLSConversationData
          (Epoch -> UTCTime -> CipherSuiteTag -> ActiveMLSConversationData)
-> Maybe Epoch
-> Maybe (UTCTime -> CipherSuiteTag -> ActiveMLSConversationData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Epoch
mEpoch
          Maybe (UTCTime -> CipherSuiteTag -> ActiveMLSConversationData)
-> Maybe UTCTime
-> Maybe (CipherSuiteTag -> ActiveMLSConversationData)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Writetime Epoch -> UTCTime)
-> Maybe (Writetime Epoch) -> Maybe UTCTime
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Writetime Epoch -> UTCTime
forall {k} (a :: k). Writetime a -> UTCTime
writetimeToUTC Maybe (Writetime Epoch)
mEpochWritetime
          Maybe (CipherSuiteTag -> ActiveMLSConversationData)
-> Maybe CipherSuiteTag -> Maybe ActiveMLSConversationData
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe CipherSuiteTag
mSuite
  GroupId
groupId <- Maybe GroupId -> MaybeT Client GroupId
forall (m :: * -> *) b. Applicative m => Maybe b -> MaybeT m b
hoistMaybe Maybe GroupId
mGroupId
  (ClientMap
cm, IndexMap
im) <- Client (ClientMap, IndexMap) -> MaybeT Client (ClientMap, IndexMap)
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Client (ClientMap, IndexMap)
 -> MaybeT Client (ClientMap, IndexMap))
-> Client (ClientMap, IndexMap)
-> MaybeT Client (ClientMap, IndexMap)
forall a b. (a -> b) -> a -> b
$ GroupId -> Client (ClientMap, IndexMap)
lookupMLSClientLeafIndices GroupId
groupId
  SubConversation -> MaybeT Client SubConversation
forall a. a -> MaybeT Client a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SubConversation -> MaybeT Client SubConversation)
-> SubConversation -> MaybeT Client SubConversation
forall a b. (a -> b) -> a -> b
$
    SubConversation
      { $sel:scParentConvId:SubConversation :: ConvId
scParentConvId = ConvId
convId,
        $sel:scSubConvId:SubConversation :: SubConvId
scSubConvId = SubConvId
subConvId,
        $sel:scMLSData:SubConversation :: ConversationMLSData
scMLSData =
          ConversationMLSData
            { $sel:cnvmlsGroupId:ConversationMLSData :: GroupId
cnvmlsGroupId = GroupId
groupId,
              $sel:cnvmlsActiveData:ConversationMLSData :: Maybe ActiveMLSConversationData
cnvmlsActiveData = Maybe ActiveMLSConversationData
activeData
            },
        $sel:scMembers:SubConversation :: ClientMap
scMembers = ClientMap
cm,
        $sel:scIndexMap:SubConversation :: IndexMap
scIndexMap = IndexMap
im
      }

insertSubConversation ::
  ConvId ->
  SubConvId ->
  GroupId ->
  Client SubConversation
insertSubConversation :: ConvId -> SubConvId -> GroupId -> Client SubConversation
insertSubConversation ConvId
convId SubConvId
subConvId GroupId
groupId = do
  RetrySettings -> Client () -> Client ()
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry
    RetrySettings
x5
    ( PrepQuery
  W (ConvId, SubConvId, Epoch, GroupId, Maybe GroupInfoData) ()
-> QueryParams
     (ConvId, SubConvId, Epoch, GroupId, Maybe GroupInfoData)
-> Client ()
forall (m :: * -> *) a (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, RunQ q) =>
q W a () -> QueryParams a -> m ()
write
        PrepQuery
  W (ConvId, SubConvId, Epoch, GroupId, Maybe GroupInfoData) ()
Cql.insertSubConversation
        ( Consistency
-> (ConvId, SubConvId, Epoch, GroupId, Maybe GroupInfoData)
-> QueryParams
     (ConvId, SubConvId, Epoch, GroupId, Maybe GroupInfoData)
forall a. Consistency -> a -> QueryParams a
params
            Consistency
LocalQuorum
            (ConvId
convId, SubConvId
subConvId, Word64 -> Epoch
Epoch Word64
0, GroupId
groupId, Maybe GroupInfoData
forall a. Maybe a
Nothing)
        )
    )
  SubConversation -> Client SubConversation
forall a. a -> Client a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ConvId -> SubConvId -> GroupId -> SubConversation
newSubConversation ConvId
convId SubConvId
subConvId GroupId
groupId)

updateSubConvGroupInfo :: ConvId -> SubConvId -> Maybe GroupInfoData -> Client ()
updateSubConvGroupInfo :: ConvId -> SubConvId -> Maybe GroupInfoData -> Client ()
updateSubConvGroupInfo ConvId
convId SubConvId
subConvId Maybe GroupInfoData
mGroupInfo =
  RetrySettings -> Client () -> Client ()
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x5 (PrepQuery W (ConvId, SubConvId, Maybe GroupInfoData) ()
-> QueryParams (ConvId, SubConvId, Maybe GroupInfoData)
-> Client ()
forall (m :: * -> *) a (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, RunQ q) =>
q W a () -> QueryParams a -> m ()
write PrepQuery W (ConvId, SubConvId, Maybe GroupInfoData) ()
Cql.updateSubConvGroupInfo (Consistency
-> (ConvId, SubConvId, Maybe GroupInfoData)
-> QueryParams (ConvId, SubConvId, Maybe GroupInfoData)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (ConvId
convId, SubConvId
subConvId, Maybe GroupInfoData
mGroupInfo)))

selectSubConvGroupInfo :: ConvId -> SubConvId -> Client (Maybe GroupInfoData)
selectSubConvGroupInfo :: ConvId -> SubConvId -> Client (Maybe GroupInfoData)
selectSubConvGroupInfo ConvId
convId SubConvId
subConvId =
  (Identity (Maybe GroupInfoData) -> Maybe GroupInfoData
forall a. Identity a -> a
runIdentity =<<) (Maybe (Identity (Maybe GroupInfoData)) -> Maybe GroupInfoData)
-> Client (Maybe (Identity (Maybe GroupInfoData)))
-> Client (Maybe GroupInfoData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RetrySettings
-> Client (Maybe (Identity (Maybe GroupInfoData)))
-> Client (Maybe (Identity (Maybe GroupInfoData)))
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x5 (PrepQuery R (ConvId, SubConvId) (Identity (Maybe GroupInfoData))
-> QueryParams (ConvId, SubConvId)
-> Client (Maybe (Identity (Maybe GroupInfoData)))
forall (m :: * -> *) a b (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, Tuple b, RunQ q) =>
q R a b -> QueryParams a -> m (Maybe b)
query1 PrepQuery R (ConvId, SubConvId) (Identity (Maybe GroupInfoData))
Cql.selectSubConvGroupInfo (Consistency
-> (ConvId, SubConvId) -> QueryParams (ConvId, SubConvId)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (ConvId
convId, SubConvId
subConvId)))

selectSubConvEpoch :: ConvId -> SubConvId -> Client (Maybe Epoch)
selectSubConvEpoch :: ConvId -> SubConvId -> Client (Maybe Epoch)
selectSubConvEpoch ConvId
convId SubConvId
subConvId =
  (Identity (Maybe Epoch) -> Maybe Epoch
forall a. Identity a -> a
runIdentity =<<) (Maybe (Identity (Maybe Epoch)) -> Maybe Epoch)
-> Client (Maybe (Identity (Maybe Epoch))) -> Client (Maybe Epoch)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> RetrySettings
-> Client (Maybe (Identity (Maybe Epoch)))
-> Client (Maybe (Identity (Maybe Epoch)))
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x5 (PrepQuery R (ConvId, SubConvId) (Identity (Maybe Epoch))
-> QueryParams (ConvId, SubConvId)
-> Client (Maybe (Identity (Maybe Epoch)))
forall (m :: * -> *) a b (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, Tuple b, RunQ q) =>
q R a b -> QueryParams a -> m (Maybe b)
query1 PrepQuery R (ConvId, SubConvId) (Identity (Maybe Epoch))
Cql.selectSubConvEpoch (Consistency
-> (ConvId, SubConvId) -> QueryParams (ConvId, SubConvId)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (ConvId
convId, SubConvId
subConvId)))

setEpochForSubConversation :: ConvId -> SubConvId -> Epoch -> Client ()
setEpochForSubConversation :: ConvId -> SubConvId -> Epoch -> Client ()
setEpochForSubConversation ConvId
cid SubConvId
sconv Epoch
epoch =
  RetrySettings -> Client () -> Client ()
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x5 (PrepQuery W (Epoch, ConvId, SubConvId) ()
-> QueryParams (Epoch, ConvId, SubConvId) -> Client ()
forall (m :: * -> *) a (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, RunQ q) =>
q W a () -> QueryParams a -> m ()
write PrepQuery W (Epoch, ConvId, SubConvId) ()
Cql.insertEpochForSubConversation (Consistency
-> (Epoch, ConvId, SubConvId)
-> QueryParams (Epoch, ConvId, SubConvId)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (Epoch
epoch, ConvId
cid, SubConvId
sconv)))

setCipherSuiteForSubConversation :: ConvId -> SubConvId -> CipherSuiteTag -> Client ()
setCipherSuiteForSubConversation :: ConvId -> SubConvId -> CipherSuiteTag -> Client ()
setCipherSuiteForSubConversation ConvId
cid SubConvId
sconv CipherSuiteTag
cs =
  RetrySettings -> Client () -> Client ()
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x5 (PrepQuery W (CipherSuiteTag, ConvId, SubConvId) ()
-> QueryParams (CipherSuiteTag, ConvId, SubConvId) -> Client ()
forall (m :: * -> *) a (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, RunQ q) =>
q W a () -> QueryParams a -> m ()
write PrepQuery W (CipherSuiteTag, ConvId, SubConvId) ()
Cql.insertCipherSuiteForSubConversation (Consistency
-> (CipherSuiteTag, ConvId, SubConvId)
-> QueryParams (CipherSuiteTag, ConvId, SubConvId)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (CipherSuiteTag
cs, ConvId
cid, SubConvId
sconv)))

deleteSubConversation :: ConvId -> SubConvId -> Client ()
deleteSubConversation :: ConvId -> SubConvId -> Client ()
deleteSubConversation ConvId
cid SubConvId
sconv =
  RetrySettings -> Client () -> Client ()
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x5 (Client () -> Client ()) -> Client () -> Client ()
forall a b. (a -> b) -> a -> b
$ PrepQuery W (ConvId, SubConvId) ()
-> QueryParams (ConvId, SubConvId) -> Client ()
forall (m :: * -> *) a (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, RunQ q) =>
q W a () -> QueryParams a -> m ()
write PrepQuery W (ConvId, SubConvId) ()
Cql.deleteSubConversation (Consistency
-> (ConvId, SubConvId) -> QueryParams (ConvId, SubConvId)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (ConvId
cid, SubConvId
sconv))

listSubConversations :: ConvId -> Client (Map SubConvId ConversationMLSData)
listSubConversations :: ConvId -> Client (Map SubConvId ConversationMLSData)
listSubConversations ConvId
cid = do
  [(SubConvId, CipherSuiteTag, Epoch, Writetime Epoch, GroupId)]
subs <- RetrySettings
-> Client
     [(SubConvId, CipherSuiteTag, Epoch, Writetime Epoch, GroupId)]
-> Client
     [(SubConvId, CipherSuiteTag, Epoch, Writetime Epoch, GroupId)]
forall (m :: * -> *) a.
MonadClient m =>
RetrySettings -> m a -> m a
retry RetrySettings
x1 (PrepQuery
  R
  (Identity ConvId)
  (SubConvId, CipherSuiteTag, Epoch, Writetime Epoch, GroupId)
-> QueryParams (Identity ConvId)
-> Client
     [(SubConvId, CipherSuiteTag, Epoch, Writetime Epoch, GroupId)]
forall (m :: * -> *) a b (q :: * -> * -> * -> *).
(MonadClient m, Tuple a, Tuple b, RunQ q) =>
q R a b -> QueryParams a -> m [b]
query PrepQuery
  R
  (Identity ConvId)
  (SubConvId, CipherSuiteTag, Epoch, Writetime Epoch, GroupId)
Cql.listSubConversations (Consistency -> Identity ConvId -> QueryParams (Identity ConvId)
forall a. Consistency -> a -> QueryParams a
params Consistency
LocalQuorum (ConvId -> Identity ConvId
forall a. a -> Identity a
Identity ConvId
cid)))
  Map SubConvId ConversationMLSData
-> Client (Map SubConvId ConversationMLSData)
forall a. a -> Client a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map SubConvId ConversationMLSData
 -> Client (Map SubConvId ConversationMLSData))
-> ([(SubConvId, ConversationMLSData)]
    -> Map SubConvId ConversationMLSData)
-> [(SubConvId, ConversationMLSData)]
-> Client (Map SubConvId ConversationMLSData)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(SubConvId, ConversationMLSData)]
-> Map SubConvId ConversationMLSData
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(SubConvId, ConversationMLSData)]
 -> Client (Map SubConvId ConversationMLSData))
-> [(SubConvId, ConversationMLSData)]
-> Client (Map SubConvId ConversationMLSData)
forall a b. (a -> b) -> a -> b
$ do
    (SubConvId
subId, CipherSuiteTag
cs, Epoch
epoch, Writetime Epoch
ts, GroupId
gid) <- [(SubConvId, CipherSuiteTag, Epoch, Writetime Epoch, GroupId)]
subs
    let activeData :: Maybe ActiveMLSConversationData
activeData = case (Epoch
epoch, Writetime Epoch
ts) of
          (Epoch Word64
0, Writetime Epoch
_) -> Maybe ActiveMLSConversationData
forall a. Maybe a
Nothing
          (Epoch
_, Writetime UTCTime
t) ->
            ActiveMLSConversationData -> Maybe ActiveMLSConversationData
forall a. a -> Maybe a
Just
              ActiveMLSConversationData
                { $sel:epoch:ActiveMLSConversationData :: Epoch
epoch = Epoch
epoch,
                  $sel:epochTimestamp:ActiveMLSConversationData :: UTCTime
epochTimestamp = UTCTime
t,
                  $sel:ciphersuite:ActiveMLSConversationData :: CipherSuiteTag
ciphersuite = CipherSuiteTag
cs
                }

    (SubConvId, ConversationMLSData)
-> [(SubConvId, ConversationMLSData)]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure
      ( SubConvId
subId,
        ConversationMLSData
          { $sel:cnvmlsGroupId:ConversationMLSData :: GroupId
cnvmlsGroupId = GroupId
gid,
            $sel:cnvmlsActiveData:ConversationMLSData :: Maybe ActiveMLSConversationData
cnvmlsActiveData = Maybe ActiveMLSConversationData
activeData
          }
      )

interpretSubConversationStoreToCassandra ::
  ( Member (Embed IO) r,
    Member (Input ClientState) r,
    Member TinyLog r
  ) =>
  Sem (SubConversationStore ': r) a ->
  Sem r a
interpretSubConversationStoreToCassandra :: forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r,
 Member TinyLog r) =>
Sem (SubConversationStore : r) a -> Sem r a
interpretSubConversationStoreToCassandra = (forall (rInitial :: EffectRow) x.
 SubConversationStore (Sem rInitial) x -> Sem r x)
-> Sem (SubConversationStore : r) a -> Sem r a
forall (e :: (* -> *) -> * -> *) (r :: EffectRow) a.
FirstOrder e "interpret" =>
(forall (rInitial :: EffectRow) x. e (Sem rInitial) x -> Sem r x)
-> Sem (e : r) a -> Sem r a
interpret ((forall (rInitial :: EffectRow) x.
  SubConversationStore (Sem rInitial) x -> Sem r x)
 -> Sem (SubConversationStore : r) a -> Sem r a)
-> (forall (rInitial :: EffectRow) x.
    SubConversationStore (Sem rInitial) x -> Sem r x)
-> Sem (SubConversationStore : r) a
-> Sem r a
forall a b. (a -> b) -> a -> b
$ \case
  CreateSubConversation ConvId
convId SubConvId
subConvId GroupId
groupId -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.CreateSubConversation"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> GroupId -> Client SubConversation
insertSubConversation ConvId
convId SubConvId
subConvId GroupId
groupId)
  GetSubConversation ConvId
convId SubConvId
subConvId -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.GetSubConversation"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> Client (Maybe SubConversation)
selectSubConversation ConvId
convId SubConvId
subConvId)
  GetSubConversationGroupInfo ConvId
convId SubConvId
subConvId -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.GetSubConversationGroupInfo"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> Client (Maybe GroupInfoData)
selectSubConvGroupInfo ConvId
convId SubConvId
subConvId)
  GetSubConversationEpoch ConvId
convId SubConvId
subConvId -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.GetSubConversationEpoch"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> Client (Maybe Epoch)
selectSubConvEpoch ConvId
convId SubConvId
subConvId)
  SetSubConversationGroupInfo ConvId
convId SubConvId
subConvId Maybe GroupInfoData
mPgs -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.SetSubConversationGroupInfo"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> Maybe GroupInfoData -> Client ()
updateSubConvGroupInfo ConvId
convId SubConvId
subConvId Maybe GroupInfoData
mPgs)
  SetSubConversationEpoch ConvId
cid SubConvId
sconv Epoch
epoch -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.SetSubConversationEpoch"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> Epoch -> Client ()
setEpochForSubConversation ConvId
cid SubConvId
sconv Epoch
epoch)
  SetSubConversationCipherSuite ConvId
cid SubConvId
sconv CipherSuiteTag
cs -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.SetSubConversationCipherSuite"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> CipherSuiteTag -> Client ()
setCipherSuiteForSubConversation ConvId
cid SubConvId
sconv CipherSuiteTag
cs)
  ListSubConversations ConvId
cid -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.ListSubConversations"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> Client (Map SubConvId ConversationMLSData)
listSubConversations ConvId
cid)
  DeleteSubConversation ConvId
convId SubConvId
subConvId -> do
    ByteString -> Sem r ()
forall (r :: EffectRow). Member TinyLog r => ByteString -> Sem r ()
logEffect ByteString
"SubConversationStore.DeleteSubConversation"
    Client x -> Sem r x
forall (r :: EffectRow) a.
(Member (Embed IO) r, Member (Input ClientState) r) =>
Client a -> Sem r a
embedClient (ConvId -> SubConvId -> Client ()
deleteSubConversation ConvId
convId SubConvId
subConvId)