From 189aa0617e84fb45a12e6c30224647492ccba9ae Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Wed, 1 Jul 2026 21:29:43 +0100 Subject: [PATCH] remove unused --- .../src/Directory/Service.hs | 6 ++--- bots/api/COMMANDS.md | 8 +++---- bots/api/TYPES.md | 18 -------------- bots/src/API/Docs/Types.hs | 2 -- bots/src/API/TypeInfo.hs | 1 + .../types/typescript/src/commands.ts | 4 ++-- .../types/typescript/src/types.ts | 21 ---------------- .../src/simplex_chat/types/_commands.py | 8 +++---- .../src/simplex_chat/types/_types.py | 14 ----------- src/Simplex/Chat/Library/Internal.hs | 2 +- src/Simplex/Chat/Library/Subscriber.hs | 18 +++++++------- src/Simplex/Chat/Store/Direct.hs | 5 ++-- src/Simplex/Chat/Store/Groups.hs | 3 +-- src/Simplex/Chat/Store/Profiles.hs | 2 +- src/Simplex/Chat/Store/Shared.hs | 2 -- src/Simplex/Chat/Types.hs | 24 +++++++------------ 16 files changed, 36 insertions(+), 102 deletions(-) diff --git a/apps/simplex-directory-service/src/Directory/Service.hs b/apps/simplex-directory-service/src/Directory/Service.hs index 1bc3eef0f8..8cd1422f78 100644 --- a/apps/simplex-directory-service/src/Directory/Service.hs +++ b/apps/simplex-directory-service/src/Directory/Service.hs @@ -552,7 +552,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName <> ".\nIt is hidden from the directory until approved." notifyAdminUsers $ "The " <> gt <> " " <> groupRef <> " is updated" <> byMember <> "." sendToApprove g' gr' n' - sendChatCmd cc (APIConnectPlan userId (Just (aConnectTargetLink link)) True Nothing) >>= \case + sendChatCmd cc (APIConnectPlan userId (Just (aConnectTarget link)) True Nothing) >>= \case Right (CRConnectionPlan _ _ (CPGroupLink (GLPKnown {groupInfo = g'}))) -> case dbOwnerMemberId gr of Just ownerGMId -> @@ -797,7 +797,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName forM_ pg_ $ \pg@PublicGroupProfile {groupLink} -> when (groupRegStatus == GRSActive || pendingApproval groupRegStatus) $ do let link = ACL SCMContact $ CLShort groupLink - sendChatCmd cc (APIConnectPlan userId (Just (aConnectTargetLink link)) True Nothing) >>= \case + sendChatCmd cc (APIConnectPlan userId (Just (aConnectTarget link)) True Nothing) >>= \case Right (CRConnectionPlan _ _ (CPGroupLink (GLPKnown {groupInfo = g', groupUpdated = BoolDef updated, linkOwners = ListDef owners}))) -> checkValidOwner dbOwnerMemberId owners $ do when updated $ reapprove pg gr groupRegStatus g' @@ -933,7 +933,7 @@ directoryServiceEvent st opts@DirectoryOpts {adminUsers, superUsers, serviceName let link = ACL SCMContact $ CLShort connLink mId = MemberId oIdBytes gt' = groupTypeStr gt - sendChatCmd cc (APIConnectPlan userId (Just (aConnectTargetLink link)) True (Just ownerSig)) >>= \case + sendChatCmd cc (APIConnectPlan userId (Just (aConnectTarget link)) True (Just ownerSig)) >>= \case Right (CRConnectionPlan _ (ACCL SCMContact ccLink) plan) -> handleGroupLinkPlan ct ccLink mId ownerSig gt' plan _ -> sendMessage cc ct "Error: could not connect. Please report it to directory admins." diff --git a/bots/api/COMMANDS.md b/bots/api/COMMANDS.md index c264997d94..8dc57dbfc7 100644 --- a/bots/api/COMMANDS.md +++ b/bots/api/COMMANDS.md @@ -1369,7 +1369,7 @@ Determine SimpleX link type and if the bot is already connected via this link or **Parameters**: - userId: int64 -- connectTarget: [AConnectTarget](./TYPES.md#aconnecttarget)? +- connectTarget: string? - resolveKnown: bool - linkOwnerSig: [LinkOwnerSig](./TYPES.md#linkownersig)? @@ -1384,7 +1384,7 @@ Determine SimpleX link type and if the bot is already connected via this link or ``` ```python -'/_connect plan ' + str(userId) + ' ' + str(connectTarget) # Python +'/_connect plan ' + str(userId) + ' ' + connectTarget # Python ``` **Responses**: @@ -1461,7 +1461,7 @@ Connect via SimpleX link or name as string in the active user profile. **Parameters**: - incognito: bool -- connTarget_: [AConnectTarget](./TYPES.md#aconnecttarget)? +- connTarget_: string? **Syntax**: @@ -1474,7 +1474,7 @@ Connect via SimpleX link or name as string in the active user profile. ``` ```python -'/connect' + ((' ' + str(connTarget_)) if connTarget_ is not None else '') # Python +'/connect' + ((' ' + connTarget_) if connTarget_ is not None else '') # Python ``` **Responses**: diff --git a/bots/api/TYPES.md b/bots/api/TYPES.md index d5a23a33af..00c7e24575 100644 --- a/bots/api/TYPES.md +++ b/bots/api/TYPES.md @@ -5,7 +5,6 @@ This file is generated automatically. - [ACIReaction](#acireaction) - [AChat](#achat) - [AChatItem](#achatitem) -- [AConnectTarget](#aconnecttarget) - [AddRelayResult](#addrelayresult) - [AddressSettings](#addresssettings) - [AgentCryptoError](#agentcryptoerror) @@ -242,23 +241,6 @@ This file is generated automatically. - chatItem: [ChatItem](#chatitem) ---- - -## AConnectTarget - -Connect target: SimpleX link (`CTLink`) or SimpleX name (`CTName`). Wire form is the bare string returned by `strEncode` — `simplex:/...` for links, `#name.simplex` / `@name.simplex` for names. - -**Discriminated union type**: - -Name: -- type: "name" -- : [SimplexNameInfo](#simplexnameinfo) - -Link: -- type: "link" -- : string - - --- ## AddRelayResult diff --git a/bots/src/API/Docs/Types.hs b/bots/src/API/Docs/Types.hs index d51912cdec..eba5454181 100644 --- a/bots/src/API/Docs/Types.hs +++ b/bots/src/API/Docs/Types.hs @@ -251,7 +251,6 @@ chatTypesDocsData = (sti @ConnectionErrorType, STUnion, "", [], "", ""), (sti @ConnectionMode, (STEnum' $ take 3 . consLower "CM"), "", [], "", ""), (sti @ConnectionPlan, STUnion, "CP", [], "", ""), - ((sti @ContactNameOrLink) {typeName = "AConnectTarget"}, STUnion, "CT", [], "", "Connect target: SimpleX link (`CTLink`) or SimpleX name (`CTName`). Wire form is the bare string returned by `strEncode` — `simplex:/...` for links, `#name.simplex` / `@name.simplex` for names."), (sti @ConnStatus, STUnion, "Conn", [], "", ""), (sti @ConnType, (STEnum' $ consSep "Conn" '_'), "", [], "", ""), (sti @Contact, STRecord, "", [], "", ""), @@ -476,7 +475,6 @@ deriving instance Generic ConnectionEntity deriving instance Generic ConnectionErrorType deriving instance Generic ConnectionMode deriving instance Generic ConnectionPlan -deriving instance Generic ContactNameOrLink deriving instance Generic ConnStatus deriving instance Generic ConnType deriving instance Generic Contact diff --git a/bots/src/API/TypeInfo.hs b/bots/src/API/TypeInfo.hs index 8b2c3974b7..f949a2f92f 100644 --- a/bots/src/API/TypeInfo.hs +++ b/bots/src/API/TypeInfo.hs @@ -194,6 +194,7 @@ toTypeInfo tr = primitiveToLower st@(ST t ps) = let t' = fstToLower t in if t' `elem` primitiveTypes then ST t' ps else st stringTypes = [ "AConnectionLink", + "AConnectTarget", "AProtocolType", "AgentConnId", "AgentInvId", diff --git a/packages/simplex-chat-client/types/typescript/src/commands.ts b/packages/simplex-chat-client/types/typescript/src/commands.ts index 775ff29df3..606b09845d 100644 --- a/packages/simplex-chat-client/types/typescript/src/commands.ts +++ b/packages/simplex-chat-client/types/typescript/src/commands.ts @@ -499,7 +499,7 @@ export namespace APIAddContact { // Network usage: interactive. export interface APIConnectPlan { userId: number // int64 - connectTarget?: T.AConnectTarget + connectTarget?: string resolveKnown: boolean linkOwnerSig?: T.LinkOwnerSig } @@ -532,7 +532,7 @@ export namespace APIConnect { // Network usage: interactive. export interface Connect { incognito: boolean - connTarget_?: T.AConnectTarget + connTarget_?: string } export namespace Connect { diff --git a/packages/simplex-chat-client/types/typescript/src/types.ts b/packages/simplex-chat-client/types/typescript/src/types.ts index bde3c70822..26aa714947 100644 --- a/packages/simplex-chat-client/types/typescript/src/types.ts +++ b/packages/simplex-chat-client/types/typescript/src/types.ts @@ -16,27 +16,6 @@ export interface AChatItem { chatInfo: ChatInfo chatItem: ChatItem } -// Connect target: SimpleX link (`CTLink`) or SimpleX name (`CTName`). Wire form is the bare string returned by `strEncode` — `simplex:/...` for links, `#name.simplex` / `@name.simplex` for names. - -export type AConnectTarget = AConnectTarget.Name | AConnectTarget.Link - -export namespace AConnectTarget { - export type Tag = "name" | "link" - - interface Interface { - type: Tag - } - - export interface Name extends Interface { - type: "name" - : SimplexNameInfo - } - - export interface Link extends Interface { - type: "link" - : string - } -} export interface AddRelayResult { relay: UserChatRelay diff --git a/packages/simplex-chat-python/src/simplex_chat/types/_commands.py b/packages/simplex-chat-python/src/simplex_chat/types/_commands.py index ee914730eb..90f9801b42 100644 --- a/packages/simplex-chat-python/src/simplex_chat/types/_commands.py +++ b/packages/simplex-chat-python/src/simplex_chat/types/_commands.py @@ -438,13 +438,13 @@ APIAddContact_Response = CR.Invitation | CR.ChatCmdError # Network usage: interactive. class APIConnectPlan(TypedDict): userId: int # int64 - connectTarget: NotRequired["T.AConnectTarget"] + connectTarget: NotRequired[str] resolveKnown: bool linkOwnerSig: NotRequired["T.LinkOwnerSig"] def APIConnectPlan_cmd_string(self: APIConnectPlan) -> str: - return '/_connect plan ' + str(self['userId']) + ' ' + str(self.get('connectTarget')) + return '/_connect plan ' + str(self['userId']) + ' ' + self.get('connectTarget') APIConnectPlan_Response = CR.ConnectionPlan | CR.ChatCmdError @@ -467,11 +467,11 @@ APIConnect_Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInv # Network usage: interactive. class Connect(TypedDict): incognito: bool - connTarget_: NotRequired["T.AConnectTarget"] + connTarget_: NotRequired[str] def Connect_cmd_string(self: Connect) -> str: - return '/connect' + ((' ' + str(self.get('connTarget_'))) if self.get('connTarget_') is not None else '') + return '/connect' + ((' ' + self.get('connTarget_')) if self.get('connTarget_') is not None else '') Connect_Response = CR.SentConfirmation | CR.ContactAlreadyExists | CR.SentInvitation | CR.ChatCmdError diff --git a/packages/simplex-chat-python/src/simplex_chat/types/_types.py b/packages/simplex-chat-python/src/simplex_chat/types/_types.py index 88f54211cc..20b18ccfc4 100644 --- a/packages/simplex-chat-python/src/simplex_chat/types/_types.py +++ b/packages/simplex-chat-python/src/simplex_chat/types/_types.py @@ -16,20 +16,6 @@ class AChatItem(TypedDict): chatInfo: "ChatInfo" chatItem: "ChatItem" -# Connect target: SimpleX link (`CTLink`) or SimpleX name (`CTName`). Wire form is the bare string returned by `strEncode` — `simplex:/...` for links, `#name.simplex` / `@name.simplex` for names. - -class AConnectTarget_name(TypedDict): - type: Literal["name"] - : "SimplexNameInfo" - -class AConnectTarget_link(TypedDict): - type: Literal["link"] - : str - -AConnectTarget = AConnectTarget_name | AConnectTarget_link - -AConnectTarget_Tag = Literal["name", "link"] - class AddRelayResult(TypedDict): relay: "UserChatRelay" relayError: NotRequired["ChatError"] diff --git a/src/Simplex/Chat/Library/Internal.hs b/src/Simplex/Chat/Library/Internal.hs index d6fa9937d8..c1996ded9b 100644 --- a/src/Simplex/Chat/Library/Internal.hs +++ b/src/Simplex/Chat/Library/Internal.hs @@ -54,7 +54,7 @@ import Data.Time (addUTCTime) import Data.Time.Calendar (fromGregorian) import Data.Time.Clock (UTCTime (..), diffUTCTime, getCurrentTime, nominalDiffTimeToSeconds, secondsToDiffTime) import Simplex.Chat.Badges (BadgeCredential (..), ProofPresHeader (..), BadgeProof (..), BadgeStatus (..), LocalBadge (..), badgeProof, mkBadgeStatus, verifyBadge) -import Simplex.Chat.Names (SimplexNameClaim (..), claimName, mkSimplexNameClaim) +import Simplex.Chat.Names (claimName, mkSimplexNameClaim) import Simplex.Chat.Call import Simplex.Chat.Controller import Simplex.Chat.Files diff --git a/src/Simplex/Chat/Library/Subscriber.hs b/src/Simplex/Chat/Library/Subscriber.hs index c66da2f58b..90167ccdc2 100644 --- a/src/Simplex/Chat/Library/Subscriber.hs +++ b/src/Simplex/Chat/Library/Subscriber.hs @@ -1397,13 +1397,13 @@ processAgentMessageConn cxt user@User {userId} corrId agentConnId agentMessage = CFSetShortLink -> case (ucGroupId_, auData) of (Just groupId, UserContactLinkData UserContactData {relays = relayLinks}) -> do - (gInfo, gLink, relays, relaysChanged, newlyActiveLinks, newlyActiveGMIds) <- withStore $ \db -> do + (gInfo, gLink, relays, relaysChanged, newlyActiveLinks) <- withStore $ \db -> do gInfo <- getGroupInfo db cxt user groupId gLink <- getGroupLink db user gInfo relays <- liftIO $ getGroupRelays db gInfo - (relays', changed, newlyActiveLinks, newlyActiveGMIds) <- liftIO $ foldrM (updateRelay db) ([], False, [], []) relays + (relays', changed, newlyActiveLinks) <- liftIO $ foldrM (updateRelay db) ([], False, []) relays liftIO $ setGroupInProgressDone db gInfo - pure (gInfo, gLink, relays', changed, newlyActiveLinks, newlyActiveGMIds) + pure (gInfo, gLink, relays', changed, newlyActiveLinks) toView $ CEvtGroupLinkDataUpdated user gInfo gLink relays relaysChanged let GroupSummary {publicMemberCount} = groupSummary gInfo -- Owner is counted in publicMemberCount; > 1 means at least one subscriber. @@ -1421,16 +1421,16 @@ processAgentMessageConn cxt user@User {userId} corrId agentConnId agentMessage = unless (null recipients) $ void $ sendGroupMessages user gInfo Nothing False recipients events where - updateRelay :: DB.Connection -> GroupRelay -> ([GroupRelay], Bool, [ShortLinkContact], [GroupMemberId]) -> IO ([GroupRelay], Bool, [ShortLinkContact], [GroupMemberId]) - updateRelay db relay@GroupRelay {groupMemberId, relayLink, relayStatus} (acc, changed, newlyActiveLinks, newlyActiveGMIds) = + updateRelay :: DB.Connection -> GroupRelay -> ([GroupRelay], Bool, [ShortLinkContact]) -> IO ([GroupRelay], Bool, [ShortLinkContact]) + updateRelay db relay@GroupRelay {groupMemberId, relayLink, relayStatus} (acc, changed, newlyActiveLinks) = case relayLink of Just rLink -- version is gated upstream at publish (getPublishableGroupRelays): an RSAccepted relay -- whose link is in the published data is necessarily pre-roster, so activate it too | rLink `elem` relayLinks && (relayStatus == RSAcknowledgedRoster || relayStatus == RSAccepted) -> do relay' <- updateRelayStatus db relay RSActive - pure (relay' : acc, True, rLink : newlyActiveLinks, groupMemberId : newlyActiveGMIds) - | rLink `elem` relayLinks -> pure (relay : acc, changed, newlyActiveLinks, newlyActiveGMIds) + pure (relay' : acc, True, rLink : newlyActiveLinks) + | rLink `elem` relayLinks -> pure (relay : acc, changed, newlyActiveLinks) | relayStatus == RSActive -> do -- Relay link absent from link data — deactivate. -- RSAccepted relays are not deactivated: their own link data update @@ -1439,8 +1439,8 @@ processAgentMessageConn cxt user@User {userId} corrId agentConnId agentMessage = -- TODO the SMP server, but this owner won't receive a LINK callback for it -- TODO (LINK only fires in response to own setConnShortLink calls). relay' <- updateRelayStatus db relay RSInactive - pure (relay' : acc, True, newlyActiveLinks, newlyActiveGMIds) - _ -> pure (relay : acc, changed, newlyActiveLinks, newlyActiveGMIds) + pure (relay' : acc, True, newlyActiveLinks) + _ -> pure (relay : acc, changed, newlyActiveLinks) _ -> throwChatError $ CECommandError "LINK event expected for a group link only" _ -> throwChatError $ CECommandError "unexpected cmdFunction" MERR _ err -> do diff --git a/src/Simplex/Chat/Store/Direct.hs b/src/Simplex/Chat/Store/Direct.hs index ae96da18d0..1f219868bd 100644 --- a/src/Simplex/Chat/Store/Direct.hs +++ b/src/Simplex/Chat/Store/Direct.hs @@ -110,12 +110,11 @@ import Data.Type.Equality import Simplex.Chat.Badges (badgeToRow) import Simplex.Chat.Messages import Simplex.Chat.Store.Shared -import Simplex.Chat.Names (claimName, claimProof, mkSimplexNameClaim, setClaimProof) +import Simplex.Chat.Names (claimName, claimProof, setClaimProof) import Simplex.Chat.Types import Simplex.Chat.Types.Preferences import Simplex.Chat.Types.UITheme -import Simplex.Messaging.Agent.Protocol (AConnectionLink (..), AConnectionRequestUri (..), ACreatedConnLink (..), ConnId, ConnShortLink, ConnectionLink (..), ConnectionModeI (..), ConnectionRequestUri, CreatedConnLink (..), SConnectionMode (..), SimplexNameInfo, UserId) -import Simplex.Messaging.Encoding.String (StrJSON (..)) +import Simplex.Messaging.Agent.Protocol (AConnectionRequestUri (..), ACreatedConnLink (..), ConnId, ConnShortLink, ConnectionModeI (..), ConnectionRequestUri, CreatedConnLink (..), SConnectionMode (..), UserId) import Simplex.Messaging.Agent.Store.AgentStore (firstRow, maybeFirstRow) import Simplex.Messaging.Agent.Store.DB (BoolInt (..)) import qualified Simplex.Messaging.Agent.Store.DB as DB diff --git a/src/Simplex/Chat/Store/Groups.hs b/src/Simplex/Chat/Store/Groups.hs index 6edf8a32bb..6e76de8623 100644 --- a/src/Simplex/Chat/Store/Groups.hs +++ b/src/Simplex/Chat/Store/Groups.hs @@ -233,11 +233,10 @@ import Simplex.Chat.Types.MemberRelations (IntroductionDirection (..), MemberRel import Simplex.Chat.Types.Preferences import Simplex.Chat.Types.Shared import Simplex.Chat.Types.UITheme -import Simplex.Messaging.Agent.Protocol (AConnectionLink (..), ConfirmationId, ConnId, ConnectionLink (..), CreatedConnLink (..), InvitationId, OwnerAuth (..), SConnectionMode (..), SimplexNameInfo, UserId) +import Simplex.Messaging.Agent.Protocol (ConfirmationId, ConnId, CreatedConnLink (..), InvitationId, OwnerAuth (..), SimplexNameInfo, UserId) import Simplex.Messaging.Agent.Store.AgentStore (firstRow, fromOnlyBI, maybeFirstRow) import qualified Simplex.FileTransfer.Description as FD import Simplex.Messaging.Encoding (smpDecode, smpEncode) -import Simplex.Messaging.Encoding.String (StrJSON (..)) import Simplex.Messaging.Agent.Store.DB (Binary (..), BoolInt (..)) import Simplex.Messaging.Agent.Store.Entity (DBEntityId) import qualified Simplex.Messaging.Agent.Store.DB as DB diff --git a/src/Simplex/Chat/Store/Profiles.hs b/src/Simplex/Chat/Store/Profiles.hs index 08f8db6cfe..c641c5de57 100644 --- a/src/Simplex/Chat/Store/Profiles.hs +++ b/src/Simplex/Chat/Store/Profiles.hs @@ -106,7 +106,7 @@ import Simplex.Chat.Operators import Simplex.Chat.Protocol import Simplex.Chat.Store.Direct import Simplex.Chat.Store.Shared -import Simplex.Chat.Names (SimplexNameClaim (..), claimName, mkSimplexNameClaim) +import Simplex.Chat.Names (claimName, mkSimplexNameClaim) import Simplex.Chat.Types import Simplex.Chat.Types.Preferences import Simplex.Chat.Types.Shared diff --git a/src/Simplex/Chat/Store/Shared.hs b/src/Simplex/Chat/Store/Shared.hs index 5b34273733..f627857cfe 100644 --- a/src/Simplex/Chat/Store/Shared.hs +++ b/src/Simplex/Chat/Store/Shared.hs @@ -30,7 +30,6 @@ import Data.Int (Int64) import Data.Maybe (fromMaybe, isJust, listToMaybe) import Data.Text (Text) import qualified Data.Text as T -import Data.Text.Encoding (encodeUtf8) import Data.Time.Clock (UTCTime (..), getCurrentTime) import Data.Type.Equality import Simplex.Chat.Badges (BadgeRow, badgeToRow, rowToBadge, verifyBadge_) @@ -50,7 +49,6 @@ import qualified Simplex.Messaging.Agent.Store.DB as DB import qualified Simplex.Messaging.Crypto as C import Simplex.Messaging.Crypto.Ratchet (PQEncryption (..), PQSupport (..)) import qualified Simplex.Messaging.Crypto.Ratchet as CR -import Simplex.Messaging.Encoding.String (StrJSON (..)) import Simplex.Messaging.Parsers (dropPrefix, sumTypeJSON) import Simplex.Messaging.Protocol (SubscriptionMode (..)) import Simplex.Messaging.Util (AnyError (..)) diff --git a/src/Simplex/Chat/Types.hs b/src/Simplex/Chat/Types.hs index 5f2b99ce42..f4fdbd578d 100644 --- a/src/Simplex/Chat/Types.hs +++ b/src/Simplex/Chat/Types.hs @@ -4,6 +4,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE DerivingVia #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -1802,6 +1803,7 @@ deriving instance Eq (ConnectTarget m) deriving instance Show (ConnectTarget m) data AConnectTarget = forall m. ConnectionModeI m => ACTarget (SConnectionMode m) (ConnectTarget m) + deriving (ToJSON, FromJSON) via (StrJSON "AConnectTarget" AConnectTarget) instance Eq AConnectTarget where ACTarget m t == ACTarget m' t' = case testEquality m m' of @@ -1818,25 +1820,15 @@ instance StrEncoding AConnectTarget where CTInv l -> strEncode l strP = (ACTarget SCMContact . CTShortContact . CTName <$> (lookAhead nameStart *> strP)) - <|> ((\(ACL m cl) -> aConnectTarget m cl) <$> strP) + <|> (aConnectTarget <$> strP) where nameStart = "@" <|> "#" <|> "simplex:/name" -aConnectTarget :: SConnectionMode m -> ConnectionLink m -> AConnectTarget -aConnectTarget m cl = case (m, cl) of - (SCMContact, CLFull cr) -> ACTarget SCMContact (CTFullContact cr) - (SCMContact, CLShort sl) -> ACTarget SCMContact (CTShortContact (CTLink sl)) - (SCMInvitation, _) -> ACTarget SCMInvitation (CTInv cl) - -aConnectTargetLink :: AConnectionLink -> AConnectTarget -aConnectTargetLink (ACL m cl) = aConnectTarget m cl - -instance ToJSON AConnectTarget where - toEncoding = strToJEncoding - toJSON = strToJSON - -instance FromJSON AConnectTarget where - parseJSON = strParseJSON "AConnectTarget" +aConnectTarget :: AConnectionLink -> AConnectTarget +aConnectTarget (ACL SCMInvitation cl) = ACTarget SCMInvitation (CTInv cl) +aConnectTarget (ACL SCMContact cl) = ACTarget SCMContact $ case cl of + CLFull cr -> CTFullContact cr + CLShort sl -> CTShortContact (CTLink sl) type CreatedLinkInvitation = CreatedConnLink 'CMInvitation