Skip to content

Commit ccdd8e1

Browse files
committed
agent: additional encodings for short links
1 parent 307a784 commit ccdd8e1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Simplex/Messaging/Agent/Protocol.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

14141415
data 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+
14161422
deriving instance Show AConnectionLink
14171423

14181424
instance ConnectionModeI m => StrEncoding (ConnectionLink m) where
@@ -1436,6 +1442,13 @@ instance ConnectionModeI m => ToJSON (ConnectionLink m) where
14361442
instance 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+
14391452
instance 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+
15721589
checkConnMode :: forall t m m'. (ConnectionModeI m, ConnectionModeI m') => t m' -> Either String (t m)
15731590
checkConnMode c = case testEquality (sConnectionMode @m) (sConnectionMode @m') of
15741591
Just Refl -> Right c

tests/AgentTests/SchemaDump.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
module AgentTests.SchemaDump where
55

66
import Control.DeepSeq
7-
import Control.Exception (bracket_)
87
import Control.Monad (unless, void)
98
import Data.List (dropWhileEnd)
109
import Data.Maybe (fromJust, isJust)
@@ -17,7 +16,7 @@ import Simplex.Messaging.Agent.Store.SQLite.DB (TrackQueries (..))
1716
import qualified Simplex.Messaging.Agent.Store.SQLite.Migrations as Migrations
1817
import Simplex.Messaging.Agent.Store.Shared (Migration (..), MigrationConfirmation (..), MigrationsToRun (..), toDownMigration)
1918
import Simplex.Messaging.Util (ifM)
20-
import System.Directory (createDirectoryIfMissing, doesFileExist, removeDirectoryRecursive, removeFile)
19+
import System.Directory (doesFileExist, removeFile)
2120
import System.Process (readCreateProcess, shell)
2221
import Test.Hspec
2322

0 commit comments

Comments
 (0)