diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index 6206e8ae50..3026e661df 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -93,7 +93,7 @@ import Simplex.Messaging.Crypto.Ratchet (PQEncryption) import Simplex.Messaging.Encoding.String import Simplex.Messaging.Notifications.Protocol (DeviceToken (..), NtfTknStatus) import Simplex.Messaging.Parsers (defaultJSON, dropPrefix, enumJSON, parseAll, parseString, sumTypeJSON) -import Simplex.Messaging.Protocol (AProtoServerWithAuth, AProtocolType (..), MsgId, NMsgMeta (..), NtfServer, ProtocolType (..), QueueId, SMPMsgMeta (..), SubscriptionMode (..), XFTPServer) +import Simplex.Messaging.Protocol (AProtoServerWithAuth, AProtocolType (..), MsgId, NMsgMeta (..), NameRegistration, NameResponse, NtfServer, ProtocolType (..), QueueId, SMPMsgMeta (..), SubscriptionMode (..), XFTPServer) import Simplex.Messaging.Session (SessionVar) import Simplex.Messaging.TMap (TMap) import Simplex.Messaging.Transport (TLS, TransportPeer (..), simplexMQVersion) @@ -711,6 +711,7 @@ data PlanResolveMode = PRMAllGroups -- resolve all known groups and all unknown chats | PRMUnknown -- only resolve if chat is unknown (default) | PRMNever -- do not resolve links and names, only do local search + | PRMAll -- always resolve, also known chats deriving (Eq, Show) planResolveModeP :: A.Parser PlanResolveMode @@ -721,6 +722,7 @@ planResolveModeP = "unknown" -> pure PRMUnknown "off" -> pure PRMUnknown "never" -> pure PRMNever + "all" -> pure PRMAll _ -> fail "bad PlanResolveMode" data CommandSource @@ -882,7 +884,7 @@ data ChatResponse | CRInvitation {user :: User, connLinkInvitation :: CreatedLinkInvitation, connection :: PendingContactConnection} | CRConnectionIncognitoUpdated {user :: User, toConnection :: PendingContactConnection, customUserProfile :: Maybe Profile} | CRConnectionUserChanged {user :: User, fromConnection :: PendingContactConnection, toConnection :: PendingContactConnection, newUser :: User} - | CRConnectionPlan {user :: User, connLink :: ACreatedConnLink, planSimplexName :: Maybe SimplexNameInfo, otherSimplexName :: Maybe SimplexNameInfo, connectionPlan :: ConnectionPlan} + | CRConnectionPlan {user :: User, connLink :: ACreatedConnLink, planSimplexName :: Maybe SimplexNameInfo, otherSimplexName :: Maybe SimplexNameInfo, connectionPlan :: ConnectionPlan, nameStatus :: Maybe NameStatus} | CRNewPreparedChat {user :: User, chat :: AChat} | CRContactUserChanged {user :: User, fromContact :: Contact, newUser :: User, toContact :: Contact} | CRGroupUserChanged {user :: User, fromGroup :: GroupInfo, newUser :: User, toGroup :: GroupInfo} @@ -1471,12 +1473,21 @@ data ChatError | ChatErrorRemoteHost {rhKey :: RHKey, remoteHostError :: RemoteHostError} deriving (Show, Exception) --- why a resolved SimpleX name could not be used (the name itself resolved; an unregistered name is the agent's NAME NOT_FOUND) +-- why a resolved SimpleX name could not be used data SimplexDomainError = SDENoValidLink -- the name's record has no usable contact/channel link - | SDEUnknownDomain -- the resolved link's profile has no name, or a different name + | SDEUnknownDomain {claimedDomain :: Maybe SimplexDomain} -- the resolved link's profile has no name, or a different name + | SDEUnavailable {registration :: NameRegistration} -- the name is not registered deriving (Eq, Show) +-- the registry answer for a resolved name +data NameStatus = NameStatus + { response :: NameResponse, + ownerChanged :: Bool, -- the owner differs from the found chat's stored answer + otherUser :: Maybe User -- another profile on this device the name leads to + } + deriving (Show) + data BadgeRedeemError = BREInvalidCode -- format or check character | BREServiceNotConfigured @@ -1844,6 +1855,8 @@ $(JQ.deriveJSON (sumTypeJSON $ dropPrefix "FC") ''ForwardConfirmation) $(JQ.deriveJSON (sumTypeJSON $ dropPrefix "SDE") ''SimplexDomainError) +$(JQ.deriveJSON defaultJSON ''NameStatus) + $(JQ.deriveJSON (sumTypeJSON $ dropPrefix "BRE") ''BadgeRedeemError) $(JQ.deriveJSON (sumTypeJSON $ dropPrefix "CE") ''ChatErrorType)