@@ -123,6 +123,7 @@ module Simplex.Messaging.Agent.Protocol
123123 ShortLinkScheme (.. ),
124124 LinkKey (.. ),
125125 sameConnReqContact ,
126+ sameShortLinkContact ,
126127 simplexChat ,
127128 connReqUriP' ,
128129 simplexConnReqUri ,
@@ -1413,6 +1414,11 @@ deriving instance Show ACreatedConnLink
14131414
14141415data AConnectionLink = forall m . ConnectionModeI m => ACL (SConnectionMode m ) (ConnectionLink m )
14151416
1417+ instance Eq AConnectionLink where
1418+ ACL m cl == ACL m' cl' = case testEquality m m' of
1419+ Just Refl -> cl == cl'
1420+ _ -> False
1421+
14161422deriving instance Show AConnectionLink
14171423
14181424instance ConnectionModeI m => StrEncoding (ConnectionLink m ) where
@@ -1436,6 +1442,13 @@ instance ConnectionModeI m => ToJSON (ConnectionLink m) where
14361442instance ConnectionModeI m => FromJSON (ConnectionLink m ) where
14371443 parseJSON = strParseJSON " ConnectionLink"
14381444
1445+ instance ToJSON AConnectionLink where
1446+ toEncoding = strToJEncoding
1447+ toJSON = strToJSON
1448+
1449+ instance FromJSON AConnectionLink where
1450+ parseJSON = strParseJSON " AConnectionLink"
1451+
14391452instance ConnectionModeI m => StrEncoding (ConnShortLink m ) where
14401453 strEncode = \ case
14411454 CSLInvitation sch srv (SMP. EntityId lnkId) (LinkKey k) -> slEncode sch srv ' i' lnkId k
@@ -1569,6 +1582,10 @@ sameConnReqContact (CRContactUri ConnReqUriData {crSmpQueues = qs}) (CRContactUr
15691582 where
15701583 same (q, q') = sameQAddress (qAddress q) (qAddress q')
15711584
1585+ sameShortLinkContact :: ConnShortLink 'CMContact -> ConnShortLink 'CMContact -> Bool
1586+ sameShortLinkContact (CSLContact _ ct srv k) (CSLContact _ ct' srv' k') =
1587+ ct == ct' && sameSrvAddr srv srv' && k == k'
1588+
15721589checkConnMode :: forall t m m' . (ConnectionModeI m , ConnectionModeI m' ) => t m' -> Either String (t m )
15731590checkConnMode c = case testEquality (sConnectionMode @ m ) (sConnectionMode @ m' ) of
15741591 Just Refl -> Right c
0 commit comments