Skip to content

Commit f0b65ff

Browse files
committed
ConversationStore.Postgres: Implement IsConversationAlive
1 parent 3b611bf commit f0b65ff

File tree

1 file changed

+8
-8
lines changed
  • libs/wire-subsystems/src/Wire/ConversationStore

1 file changed

+8
-8
lines changed

libs/wire-subsystems/src/Wire/ConversationStore/Postgres.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,14 @@ getGroupInfoImpl cid =
426426
dimapPG
427427
[maybeStatement|SELECT (public_group_state :: bytea?) FROM conversation where id = ($1 :: uuid)|]
428428

429-
isConversationAliveImpl :: ConvId -> Sem r Bool
430-
isConversationAliveImpl _ =
431-
-- In cassandra this checks whether `deleted` is set to True. In postgres, we
432-
-- don't need the `deleted` field as we can delete convs and associated data
433-
-- in a transaction.
434-
--
435-
-- Hence this always returns True.
436-
pure True
429+
isConversationAliveImpl :: (PGConstraints r) => ConvId -> Sem r Bool
430+
isConversationAliveImpl cid =
431+
runStatement cid select
432+
where
433+
select :: Hasql.Statement ConvId Bool
434+
select =
435+
lmapPG
436+
[singletonStatement|SELECT EXISTS (SELECT 1 FROM conversation WHERE id = ($1 :: uuid)) :: boolean|]
437437

438438
getRemoteConversationStatusImpl :: (PGConstraints r) => UserId -> [Remote ConvId] -> Sem r (Map (Remote ConvId) MemberStatus)
439439
getRemoteConversationStatusImpl uid remoteConvs = do

0 commit comments

Comments
 (0)