Skip to content

Commit 6e8a951

Browse files
authored
WPB-16875 team admin creates a channel without joining (#4527)
1 parent 263d1a8 commit 6e8a951

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+670
-316
lines changed

changelog.d/2-features/WBP-16875

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Team admins can create a channel without joining

integration/test/API/Galley.hs

+11-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ data CreateConv = CreateConv
3232
protocol :: String,
3333
groupConvType :: Maybe String,
3434
cells :: Bool,
35-
addPermission :: Maybe String
35+
addPermission :: Maybe String,
36+
skipCreator :: Maybe Bool
3637
}
3738

3839
defProteus :: CreateConv
@@ -49,7 +50,8 @@ defProteus =
4950
protocol = "proteus",
5051
groupConvType = Nothing,
5152
cells = False,
52-
addPermission = Nothing
53+
addPermission = Nothing,
54+
skipCreator = Nothing
5355
}
5456

5557
defMLS :: CreateConv
@@ -84,7 +86,8 @@ instance MakesValue CreateConv where
8486
"message_timer" .=? cc.messageTimer,
8587
"receipt_mode" .=? cc.receiptMode,
8688
"group_conv_type" .=? cc.groupConvType,
87-
"add_permission" .=? cc.addPermission
89+
"add_permission" .=? cc.addPermission,
90+
"skip_creator" .=? cc.skipCreator
8891
]
8992
)
9093

@@ -271,7 +274,7 @@ postMLSCommitBundle cid msg = do
271274
postProteusMessage :: (HasCallStack, MakesValue user, MakesValue conv) => user -> conv -> QualifiedNewOtrMessage -> App Response
272275
postProteusMessage user conv msgs = do
273276
convDomain <- objDomain conv
274-
convId <- objId conv
277+
convId <- objQidObject conv & objId
275278
let bytes = Proto.encodeMessage msgs
276279
req <- baseRequest user Galley Versioned (joinHttpPath ["conversations", convDomain, convId, "proteus", "messages"])
277280
submit "POST" (addProtobuf bytes req)
@@ -443,7 +446,7 @@ postConversationCode ::
443446
Maybe String ->
444447
App Response
445448
postConversationCode user conv mbpassword mbZHost = do
446-
convId <- objId conv
449+
convId <- objQidObject conv & objId
447450
req <- baseRequest user Galley Versioned (joinHttpPath ["conversations", convId, "code"])
448451
submit
449452
"POST"
@@ -459,7 +462,7 @@ getConversationCode ::
459462
Maybe String ->
460463
App Response
461464
getConversationCode user conv mbZHost = do
462-
convId <- objId conv
465+
convId <- objQidObject conv & objId
463466
req <- baseRequest user Galley Versioned (joinHttpPath ["conversations", convId, "code"])
464467
submit
465468
"GET"
@@ -470,7 +473,7 @@ getConversationCode user conv mbZHost = do
470473

471474
deleteConversationCode :: (HasCallStack, MakesValue user, MakesValue conv) => user -> conv -> App Response
472475
deleteConversationCode user conv = do
473-
convId <- objId conv
476+
convId <- objQidObject conv & objId
474477
req <- baseRequest user Galley Versioned (joinHttpPath ["conversations", convId, "code"])
475478
submit "DELETE" req
476479

@@ -804,7 +807,7 @@ getTeamMembersCsv user tid = do
804807
sendTypingStatus :: (HasCallStack, MakesValue user, MakesValue conv) => user -> conv -> String -> App Response
805808
sendTypingStatus user conv status = do
806809
convDomain <- objDomain conv
807-
convId <- objId conv
810+
convId <- objQidObject conv & objId
808811
req <- baseRequest user Galley Versioned (joinHttpPath ["conversations", convDomain, convId, "typing"])
809812
submit "POST"
810813
$ addJSONObject ["status" .= status] req

integration/test/Test/Bot.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ withBotWithSettings settings k = do
111111
$ def {newServiceUrl = "https://" <> host <> ":" <> show port, newServiceKey = cs settings.publicKey}
112112
serviceId <- asString $ service %. "id"
113113
conv <- getJSON 201 =<< postConversation alice defProteus
114-
convId <- conv %. "id" & asString
114+
convId <- conv %. "qualified_id" & objId
115115
assertStatus 200 =<< updateServiceConn OwnDomain providerId serviceId do
116116
object ["enabled" .= True, "password" .= password]
117117
addBot alice providerId serviceId convId >>= k

integration/test/Test/Cells.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ testCellsEvent = do
4040
do
4141
event <- getMessage q %. "payload.0"
4242
event %. "type" `shouldMatch` "conversation.member-join"
43-
event %. "conversation" `shouldMatch` (conv %. "id")
43+
event %. "conversation" `shouldMatch` (conv %. "qualified_id" & objId)
4444
event %. "qualified_from" `shouldMatch` (alice %. "qualified_id")
4545
users <- event %. "data.users" & asList
4646
assertOne users %. "qualified_id" `shouldMatch` chazId
@@ -51,7 +51,7 @@ testCellsEvent = do
5151
do
5252
event <- getMessage q %. "payload.0"
5353
event %. "type" `shouldMatch` "conversation.member-join"
54-
event %. "conversation" `shouldMatch` (conv %. "id")
54+
event %. "conversation" `shouldMatch` (conv %. "qualified_id" & objId)
5555
event %. "qualified_from" `shouldMatch` (alice %. "qualified_id")
5656
users <- event %. "data.users" & asList
5757
assertOne users %. "qualified_id" `shouldMatch` deanId
@@ -72,7 +72,7 @@ testCellsCreationEvent = do
7272

7373
event <- getMessage q %. "payload.0"
7474
event %. "type" `shouldMatch` "conversation.create"
75-
event %. "conversation" `shouldMatch` (conv %. "id")
75+
event %. "conversation" `shouldMatch` (conv %. "qualified_id" & objId)
7676
event %. "qualified_from" `shouldMatch` (alice %. "qualified_id")
7777

7878
testCellsFeatureCheck :: (HasCallStack) => App ()

integration/test/Test/Channels.hs

+11
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,14 @@ _testAddtermissionExternalPartner addPermission assertion = do
400400
createGroup def ownerClient convId
401401
void $ createAddCommit ownerClient convId [partner] >>= sendAndConsumeCommitBundle
402402
assertion partnerClient convId mems
403+
404+
testTeamAdminCanCreateChannelWithoutJoining :: (HasCallStack) => App ()
405+
testTeamAdminCanCreateChannelWithoutJoining = do
406+
(owner, tid, _) <- createTeam OwnDomain 1
407+
408+
setTeamFeatureLockStatus owner tid "channels" "unlocked"
409+
void $ setTeamFeatureConfig owner tid "channels" (config "everyone")
410+
411+
postConversation owner defMLS {groupConvType = Just "channel", team = Just tid, skipCreator = Just True} `bindResponse` \resp -> do
412+
resp.status `shouldMatchInt` 201
413+
resp.json %. "members" `shouldMatch` ([] :: [Value])

integration/test/Test/Conversation.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ testGuestLinksSuccess = do
862862
pure (k, v)
863863
bindResponse (getJoinCodeConv tm k v) $ \resp -> do
864864
resp.status `shouldMatchInt` 200
865-
resp.json %. "id" `shouldMatch` objId conv
865+
resp.json %. "id" `shouldMatch` (objQidObject conv & objId)
866866

867867
testGuestLinksExpired :: (HasCallStack) => App ()
868868
testGuestLinksExpired = do

integration/test/Test/LegalHold.hs

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import API.Galley
2424
import API.GalleyInternal
2525
import Control.Error (MaybeT (MaybeT), runMaybeT)
2626
import Control.Lens ((.~), (^?), (^?!))
27+
import Control.Monad.Extra (findM)
2728
import Control.Monad.Reader (asks, local)
2829
import Control.Monad.Trans.Class (lift)
2930
import Data.Aeson.Lens
@@ -789,20 +790,24 @@ testLHNoConsentRemoveFromGroup approvedOrPending admin = do
789790
postLegalHoldSettings tidAlice alice (mkLegalHoldSettings lhDomAndPort) >>= assertStatus 201
790791
withWebSockets [alice, bob] \[aws, bws] -> do
791792
connectTwoUsers alice bob
792-
(convId, qConvId) <- do
793+
qConvId <- do
793794
let (inviter, tidInviter, invitee, inviteeRole) = case admin of
794795
LegalholderIsAdmin -> (alice, tidAlice, bob, "wire_member")
795796
BothAreAdmins -> (alice, tidAlice, bob, "wire_admin")
796797
PeerIsAdmin -> (bob, tidBob, alice, "wire_member")
797798

798799
let createConv = defProteus {qualifiedUsers = [invitee], newUsersRole = inviteeRole, team = Just tidInviter}
799800
postConversation inviter createConv `bindResponse` \resp -> do
800-
resp.json %. "members.self.conversation_role" `shouldMatch` "wire_admin"
801-
resp.json %. "members.others.0.conversation_role" `shouldMatch` case admin of
801+
allMembers <- resp.json %. "members" & asList
802+
selfMember <- findM (\m -> (==) <$> m %. "qualified_id" <*> inviter %. "qualified_id") allMembers
803+
otherMember <- findM (\m -> (==) <$> m %. "qualified_id" <*> invitee %. "qualified_id") allMembers
804+
selfMember %. "conversation_role" `shouldMatch` "wire_admin"
805+
otherMember %. "conversation_role" `shouldMatch` case admin of
802806
BothAreAdmins -> "wire_admin"
803807
PeerIsAdmin -> "wire_member"
804808
LegalholderIsAdmin -> "wire_member"
805-
(,) <$> resp.json %. "id" <*> resp.json %. "qualified_id"
809+
resp.json %. "qualified_id"
810+
let convId = objId qConvId
806811
for_ [aws, bws] \ws -> do
807812
awaitMatch isConvCreateNotifNotSelf ws >>= \pl -> pl %. "payload.0.conversation" `shouldMatch` convId
808813

0 commit comments

Comments
 (0)