Skip to content
2 changes: 2 additions & 0 deletions changelog.d/1-api-changes/self-member-id-qualified
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The member.self ID in conversation endpoints is qualified and available as
"qualified_id". The old unqualified "id" is still available.
7 changes: 4 additions & 3 deletions libs/api-bot/src/Network/Wire/Bot/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
module Network.Wire.Bot.Assert where

import Data.Id (ConvId, UserId)
import Data.Qualified (qUnqualified)
import Data.Qualified (Local, QualifiedWithTag (qUntagged), qUnqualified, qualifyAs)
import qualified Data.Set as Set
import Imports
import Network.Wire.Bot.Monad
Expand All @@ -31,17 +31,18 @@ import Network.Wire.Client.API.User

assertConvCreated ::
(HasCallStack, MonadBotNet m) =>
Local x ->
ConvId ->
-- | The creator of the conversation.
Bot ->
-- | The other users in the conversation.
[Bot] ->
m ()
assertConvCreated c b bs = do
assertConvCreated loc c b bs = do
let everyone = b : bs
forM_ bs $ \u ->
let others = Set.fromList . filter (/= botId u) . map botId $ everyone
in assertEvent u TConvCreate (convCreate (botId u) others)
in assertEvent u TConvCreate (convCreate (qUntagged (qualifyAs loc (botId u))) others)
where
convCreate self others = \case
EConvCreate e ->
Expand Down
6 changes: 4 additions & 2 deletions libs/wire-api/src/Wire/API/Conversation/Member.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ modelConversationMembers = Doc.defineModel "ConversationMembers" $ do

-- FUTUREWORK: Add a qualified Id here.
Comment thread
mdimjasevic marked this conversation as resolved.
Outdated
data Member = Member
{ memId :: UserId,
{ memId :: Qualified UserId,
memService :: Maybe ServiceRef,
memOtrMutedStatus :: Maybe MutedStatus,
memOtrMutedRef :: Maybe Text,
Expand All @@ -109,7 +109,9 @@ instance ToSchema Member where
schema =
object "Member" $
Member
<$> memId .= field "id" schema
<$> memId .= field "qualified_id" schema
<* (qUnqualified . memId)
.= optional (field "id" (deprecatedSchema "qualified_id" schema))
<*> memService .= lax (field "service" (optWithDefault A.Null schema))
-- Remove ...
<* const () .= optional (field "status" (c (0 :: Int)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"otr_archived_ref": "",
"otr_muted_ref": "",
"otr_muted_status": null,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0001-0000-000100000001"
},
"service": {
"id": "00000001-0000-0000-0000-000000000000",
"provider": "00000000-0000-0000-0000-000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"otr_archived_ref": null,
"otr_muted_ref": "",
"otr_muted_status": null,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0000-0000-000000000000"
},
"service": {
"id": "00000001-0000-0001-0000-000100000001",
"provider": "00000001-0000-0001-0000-000000000001"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"otr_archived_ref": null,
"otr_muted_ref": "",
"otr_muted_status": 0,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0000-0000-000100000000"
},
"service": null,
"status": 0,
"status_ref": "0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"otr_archived_ref": "",
"otr_muted_ref": null,
"otr_muted_status": null,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000001-0000-0001-0000-000100000000"
},
"service": null,
"status": 0,
"status_ref": "0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
"otr_archived_ref": null,
"otr_muted_ref": null,
"otr_muted_status": -1,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0001-0000-000100000001"
},
"service": null,
"status": 0,
"status_ref": "0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"otr_archived_ref": "",
"otr_muted_ref": null,
"otr_muted_status": null,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000001-0000-0001-0000-000100000000"
},
"service": null,
"status": 0,
"status_ref": "0.0",
Expand Down Expand Up @@ -75,6 +79,10 @@
"otr_archived_ref": null,
"otr_muted_ref": null,
"otr_muted_status": -1,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0001-0000-000100000001"
},
"service": null,
"status": 0,
"status_ref": "0.0",
Expand Down
4 changes: 4 additions & 0 deletions libs/wire-api/test/golden/testObject_Event_user_8.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"otr_archived_ref": "",
"otr_muted_ref": "",
"otr_muted_status": 0,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000001-0000-0000-0000-000000000001"
},
"service": {
"id": "00000001-0000-0000-0000-000000000001",
"provider": "00000000-0000-0000-0000-000100000001"
Expand Down
4 changes: 4 additions & 0 deletions libs/wire-api/test/golden/testObject_Member_user_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"otr_archived_ref": "𢖖",
"otr_muted_ref": "ref",
"otr_muted_status": -2,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000002-0000-0001-0000-000100000000"
},
"service": {
"id": "00000000-0000-0000-0000-000000000001",
"provider": "00000000-0000-0001-0000-000000000001"
Expand Down
4 changes: 4 additions & 0 deletions libs/wire-api/test/golden/testObject_Member_user_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"otr_archived_ref": null,
"otr_muted_ref": null,
"otr_muted_status": null,
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0001-0000-000100000002"
},
"service": null,
"status": 0,
"status_ref": "0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ testObject_ConvMembers_user_1 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000001")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000001"))) domain,
memService =
Just
( ServiceRef
Expand Down Expand Up @@ -92,7 +92,7 @@ testObject_ConvMembers_user_2 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000000000000")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000000000000"))) domain,
memService =
Just
( ServiceRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import Imports (Bool (False, True), Maybe (Just, Nothing), fromJust)
import Wire.API.Conversation
import Wire.API.Conversation.Role (parseRoleName)

domain :: Domain
domain = Domain "golden.example.com"

testObject_ConversationList_20Conversation_user_1 :: ConversationList Conversation
testObject_ConversationList_20Conversation_user_1 =
ConversationList
Expand All @@ -48,7 +51,7 @@ testObject_ConversationList_20Conversation_user_1 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000000")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000000"))) domain,
memService = Nothing,
memOtrMutedStatus = Just (MutedStatus {fromMutedStatus = 0}),
memOtrMutedRef = Just "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ domain = Domain "golden.example.com"
testObject_Conversation_user_1 :: Conversation
testObject_Conversation_user_1 =
Conversation
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000001-0000-0000-0000-000000000000"))) (Domain "golden.example.com"),
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000001-0000-0000-0000-000000000000"))) domain,
cnvMetadata =
ConversationMetadata
{ cnvmType = One2OneConv,
Expand All @@ -50,7 +50,7 @@ testObject_Conversation_user_1 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000001-0000-0001-0000-000100000000")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000001-0000-0001-0000-000100000000"))) domain,
memService = Nothing,
memOtrMutedStatus = Nothing,
memOtrMutedRef = Nothing,
Expand All @@ -67,7 +67,7 @@ testObject_Conversation_user_1 =
testObject_Conversation_user_2 :: Conversation
testObject_Conversation_user_2 =
Conversation
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000000000002"))) (Domain "golden.example.com"),
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000000000002"))) domain,
cnvMetadata =
ConversationMetadata
{ cnvmType = SelfConv,
Expand Down Expand Up @@ -96,7 +96,7 @@ testObject_Conversation_user_2 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000001")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000001"))) domain,
memService = Nothing,
memOtrMutedStatus = Just (MutedStatus {fromMutedStatus = -1}),
memOtrMutedRef = Nothing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ testObject_Event_user_8 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000001-0000-0000-0000-000000000001")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000001-0000-0000-0000-000000000001"))) (Domain "golden.example.com"),
memService =
Just
( ServiceRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@
-- with this program. If not, see <https://www.gnu.org/licenses/>.
module Test.Wire.API.Golden.Generated.Member_user where

import Data.Domain (Domain (..))
import Data.Id (Id (Id))
import Data.Qualified (Qualified (..))
import qualified Data.UUID as UUID (fromString)
import Imports (Bool (False, True), Maybe (Just, Nothing), fromJust)
import Wire.API.Conversation (Member (..), MutedStatus (MutedStatus, fromMutedStatus))
import Wire.API.Conversation.Role (parseRoleName)
import Wire.API.Provider.Service (ServiceRef (ServiceRef, _serviceRefId, _serviceRefProvider))

domain :: Domain
domain = Domain "golden.example.com"

testObject_Member_user_1 :: Member
testObject_Member_user_1 =
Member
{ memId = Id (fromJust (UUID.fromString "00000002-0000-0001-0000-000100000000")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000002-0000-0001-0000-000100000000"))) domain,
memService =
Just
( ServiceRef
Expand All @@ -47,7 +52,7 @@ testObject_Member_user_1 =
testObject_Member_user_2 :: Member
testObject_Member_user_2 =
Member
{ memId = Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000002")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000002"))) domain,
memService = Nothing,
memOtrMutedStatus = Nothing,
memOtrMutedRef = Nothing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ import Imports
import Wire.API.Conversation
import Wire.API.Conversation.Role

domain :: Domain
domain = Domain "golden.example.com"

testObject_ConversationsResponse_1 :: ConversationsResponse
testObject_ConversationsResponse_1 =
ConversationsResponse
{ crFound = [conv1, conv2],
crNotFound =
[ Qualified (Id (fromJust (UUID.fromString "00000018-0000-0020-0000-000e00000002"))) (Domain "golden.example.com"),
[ Qualified (Id (fromJust (UUID.fromString "00000018-0000-0020-0000-000e00000002"))) domain,
Qualified (Id (fromJust (UUID.fromString "00000018-0000-0020-0000-111111111112"))) (Domain "golden2.example.com")
],
crFailed =
[ Qualified (Id (fromJust (UUID.fromString "00000018-4444-0020-0000-000e00000002"))) (Domain "golden.example.com"),
[ Qualified (Id (fromJust (UUID.fromString "00000018-4444-0020-0000-000e00000002"))) domain,
Qualified (Id (fromJust (UUID.fromString "99999999-0000-0020-0000-111111111112"))) (Domain "golden3.example.com")
]
}

conv1 :: Conversation
conv1 =
Conversation
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000001-0000-0000-0000-000000000000"))) (Domain "golden.example.com"),
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000001-0000-0000-0000-000000000000"))) domain,
cnvMetadata =
ConversationMetadata
{ cnvmType = One2OneConv,
Expand All @@ -45,7 +48,7 @@ conv1 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000001-0000-0001-0000-000100000000")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000001-0000-0001-0000-000100000000"))) domain,
memService = Nothing,
memOtrMutedStatus = Nothing,
memOtrMutedRef = Nothing,
Expand All @@ -62,7 +65,7 @@ conv1 =
conv2 :: Conversation
conv2 =
Conversation
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000000000002"))) (Domain "golden.example.com"),
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000000000002"))) domain,
cnvMetadata =
ConversationMetadata
{ cnvmType = SelfConv,
Expand Down Expand Up @@ -91,7 +94,7 @@ conv2 =
ConvMembers
{ cmSelf =
Member
{ memId = Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000001")),
{ memId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000100000001"))) domain,
memService = Nothing,
memOtrMutedStatus = Just (MutedStatus {fromMutedStatus = -1}),
memOtrMutedRef = Nothing,
Expand Down
10 changes: 5 additions & 5 deletions services/brig/test/integration/API/Provider.hs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ testDeleteService config db brig galley cannon = withTestService config db brig
WS.bracketR cannon uid1 $ \ws -> do
deleteService brig pid sid defProviderPassword
!!! const 202 === statusCode
_ <- waitFor (5 # Second) not (isMember galley buid1 cid)
_ <- waitFor (5 # Second) not (isMember galley buid2 cid)
_ <- waitFor (5 # Second) not (isMember galley qbuid1 cid)
_ <- waitFor (5 # Second) not (isMember galley qbuid2 cid)
getBotConv galley bid1 cid !!! const 404 === statusCode
getBotConv galley bid2 cid !!! const 404 === statusCode
wsAssertMemberLeave ws qcid qbuid1 [qbuid1]
Expand Down Expand Up @@ -616,7 +616,7 @@ testBotTeamOnlyConv config db brig galley cannon = withTestService config db bri
-- Make the conversation team-only again and check that the bot has been removed
WS.bracketR cannon uid1 $ \ws -> do
setAccessRole uid1 cid TeamAccessRole
_ <- waitFor (5 # Second) not (isMember galley buid cid)
_ <- waitFor (5 # Second) not (isMember galley qbuid cid)
getBotConv galley bid cid
!!! const 404 === statusCode
svcAssertConvAccessUpdate
Expand Down Expand Up @@ -895,7 +895,7 @@ testWhitelistKickout localDomain config db brig galley cannon = do
-- De-whitelist the service; both bots should be kicked out
WS.bracketR cannon owner $ \ws -> do
dewhitelistService brig owner tid pid sid
_ <- waitFor (2 # Second) not (isMember galley buid cid)
_ <- waitFor (2 # Second) not (isMember galley qbuid cid)
getBotConv galley bid cid
!!! const 404 === statusCode
wsAssertMemberLeave ws qcid qowner [qbuid]
Expand Down Expand Up @@ -1981,7 +1981,7 @@ testMessageBotUtil quid uc cid pid sid sref buf brig galley cannon = do
WS.bracketR cannon uid $ \ws -> do
deleteService brig pid sid defProviderPassword
!!! const 202 === statusCode
_ <- waitFor (5 # Second) not (isMember galley buid cid)
_ <- waitFor (5 # Second) not (isMember galley qbuid cid)
getBotConv galley bid cid
!!! const 404 === statusCode
wsAssertMemberLeave ws qcid qbuid [qbuid]
Expand Down
4 changes: 2 additions & 2 deletions services/brig/test/integration/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,12 @@ listConvs galley zusr convs = do
. zConn "conn"
. json (ListConversations convs)

isMember :: Galley -> UserId -> ConvId -> (MonadIO m, MonadHttp m) => m Bool
isMember :: Galley -> Qualified UserId -> ConvId -> (MonadIO m, MonadHttp m) => m Bool
Comment thread
mdimjasevic marked this conversation as resolved.
Outdated
isMember g usr cnv = do
res <-
get $
g
. paths ["i", "conversations", toByteString' cnv, "members", toByteString' usr]
. paths ["i", "conversations", toByteString' cnv, "members", toByteString' (qUnqualified usr)]
. expect2xx
case responseJsonMaybe res of
Nothing -> return False
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/Federation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ onConversationCreated domain rc = do
(qUntagged (FederationAPIGalley.rcRemoteOrigUserId qrcConnected))
(rcTime qrcConnected)
(EdConversation c)
pushConversationEvent Nothing event [Public.memId mem] []
pushConversationEvent Nothing event [qUnqualified . Public.memId $ mem] []

getConversations :: Domain -> GetConversationsRequest -> Galley GetConversationsResponse
getConversations domain (GetConversationsRequest uid cids) = do
Expand Down
Loading