mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 07:34:16 +00:00
wip
This commit is contained in:
@@ -87,7 +87,6 @@ module Simplex.Chat.Store.Groups
|
||||
getGroupRelays,
|
||||
getConnectedGroupRelays,
|
||||
setGroupRosterVersion,
|
||||
setGroupRoster,
|
||||
getGroupRoster,
|
||||
getRosterBlob,
|
||||
setRosterPending,
|
||||
@@ -1417,20 +1416,6 @@ setGroupRosterVersion db GroupInfo {groupId} v = do
|
||||
currentTs <- getCurrentTime
|
||||
DB.execute db "UPDATE groups SET roster_version = ?, updated_at = ? WHERE group_id = ?" (v, currentTs, groupId)
|
||||
|
||||
-- Relay saves the verbatim signed roster (parts + sending owner + broker ts) to re-forward to joiners.
|
||||
setGroupRoster :: DB.Connection -> GroupInfo -> VersionRoster -> GroupMemberId -> UTCTime -> SignedMsg -> IO ()
|
||||
setGroupRoster db GroupInfo {groupId} v ownerGMId brokerTs SignedMsg {chatBinding, signatures, signedBody} = do
|
||||
currentTs <- getCurrentTime
|
||||
DB.execute
|
||||
db
|
||||
[sql|
|
||||
UPDATE groups
|
||||
SET roster_version = ?, roster_sending_owner_gm_id = ?, roster_broker_ts = ?,
|
||||
roster_msg_chat_binding = ?, roster_msg_signatures = ?, roster_msg_body = ?, updated_at = ?
|
||||
WHERE group_id = ?
|
||||
|]
|
||||
((v, ownerGMId, brokerTs, chatBinding) :. (Binary (smpEncode signatures), Binary signedBody, currentTs, groupId))
|
||||
|
||||
getGroupRoster :: DB.Connection -> GroupInfo -> IO (Maybe (GroupMemberId, UTCTime, SignedMsg))
|
||||
getGroupRoster db GroupInfo {groupId} =
|
||||
(>>= toRoster)
|
||||
|
||||
@@ -10454,13 +10454,17 @@ testChannelRosterDigestMismatchRejected ps =
|
||||
threadDelay 100000
|
||||
memberJoinChannel "team" [bob] [alice, cath] shortLink fullLink frank
|
||||
threadDelay 100000
|
||||
checkRosterVersionBelow frank 1
|
||||
checkRosterNotApplied frank
|
||||
where
|
||||
checkRosterVersionBelow :: HasCallStack => TestCC -> Int64 -> IO ()
|
||||
checkRosterVersionBelow cc target = do
|
||||
-- frank learns cath via the moderator introduction (XGrpMemIntro) regardless of the roster,
|
||||
-- so checkMemberRow cannot distinguish applied vs rejected. The roster's authoritative effect
|
||||
-- is its version: it must NOT advance to the corrupted roster's version 1, and frank must
|
||||
-- actually hold the group (non-vacuous) so a NULL roster_version cannot pass by emptiness.
|
||||
checkRosterNotApplied :: HasCallStack => TestCC -> IO ()
|
||||
checkRosterNotApplied cc = do
|
||||
vs <- withCCTransaction cc $ \db ->
|
||||
DB.query_ db "SELECT roster_version FROM groups" :: IO [Only (Maybe Int64)]
|
||||
all (< target) [v | Only (Just v) <- vs] `shouldBe` True
|
||||
map (\(Only v) -> v) vs `shouldSatisfy` (\versions -> not (null versions) && Just 1 `notElem` versions)
|
||||
|
||||
testChannelRemoveRelay :: HasCallStack => TestParams -> IO ()
|
||||
testChannelRemoveRelay ps =
|
||||
|
||||
Reference in New Issue
Block a user