Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
8 changes: 4 additions & 4 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,7 +31,7 @@ import Network.Wire.Client.API.User

assertConvCreated ::
(HasCallStack, MonadBotNet m) =>
ConvId ->
Local ConvId ->
-- | The creator of the conversation.
Bot ->
-- | The other users in the conversation.
Expand All @@ -41,14 +41,14 @@ assertConvCreated 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 c . botId $ u) others)
where
convCreate self others = \case
EConvCreate e ->
let cnv = convEvtData e
mems = cnvMembers cnv
omems = Set.fromList (map (qUnqualified . omQualifiedId) (cmOthers mems))
in (qUnqualified . cnvQualifiedId $ cnv) == c
in cnvQualifiedId cnv == qUntagged c
&& convEvtFrom e == botId b
&& cnvType cnv == RegularConv
&& memId (cmSelf mems) == self
Expand Down
5 changes: 5 additions & 0 deletions libs/api-bot/src/Network/Wire/Bot/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module Network.Wire.Bot.Monad
BotNetException (..),
BotNetFailure (..),
try,
qualifyLocal,
)
where

Expand All @@ -104,6 +105,7 @@ import Data.Id
import Data.Metrics (Metrics)
import qualified Data.Metrics as Metrics
import Data.Misc (PlainTextPassword (..))
import Data.Qualified (Local, toLocalUnsafe)
import Data.Text (pack, unpack)
import Data.Time.Clock
import Data.Time.Format (defaultTimeLocale, formatTime, parseTimeOrError)
Expand Down Expand Up @@ -525,6 +527,9 @@ withCachedBot t f = do
viewFederationDomain :: MonadBotNet m => m Domain
viewFederationDomain = liftBotNet . BotNet $ asks botNetDomain

qualifyLocal :: MonadBotNet m => a -> m (Local a)
qualifyLocal a = toLocalUnsafe <$> viewFederationDomain <*> pure a

-------------------------------------------------------------------------------
-- Assertions

Expand Down
7 changes: 4 additions & 3 deletions libs/wire-api/src/Wire/API/Conversation/Member.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ modelConversationMembers = Doc.defineModel "ConversationMembers" $ do
--------------------------------------------------------------------------------
-- Members

-- FUTUREWORK: Add a qualified Id here.
data Member = Member
{ memId :: UserId,
{ memId :: Qualified UserId,
memService :: Maybe ServiceRef,
memOtrMutedStatus :: Maybe MutedStatus,
memOtrMutedRef :: Maybe Text,
Expand All @@ -109,7 +108,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
Loading