From cf559ee43ff30a1996965f944103afefaec70102 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 1 Oct 2024 22:28:01 +0100 Subject: [PATCH] smp server: fix notifiers lost when compacting store log (#1347) --- src/Simplex/FileTransfer/Server/Store.hs | 1 + src/Simplex/FileTransfer/Server/StoreLog.hs | 1 + src/Simplex/Messaging/Notifications/Server/StoreLog.hs | 3 +++ src/Simplex/Messaging/Server/StoreLog.hs | 4 +++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Simplex/FileTransfer/Server/Store.hs b/src/Simplex/FileTransfer/Server/Store.hs index 10c34819f..46513ea96 100644 --- a/src/Simplex/FileTransfer/Server/Store.hs +++ b/src/Simplex/FileTransfer/Server/Store.hs @@ -54,6 +54,7 @@ fileTimePrecision :: Int64 fileTimePrecision = 3600 -- truncate creation time to 1 hour data FileRecipient = FileRecipient RecipientId RcvPublicAuthKey + deriving (Show) instance StrEncoding FileRecipient where strEncode (FileRecipient rId rKey) = strEncode rId <> ":" <> strEncode rKey diff --git a/src/Simplex/FileTransfer/Server/StoreLog.hs b/src/Simplex/FileTransfer/Server/StoreLog.hs index 9d3919c2c..675e4efdb 100644 --- a/src/Simplex/FileTransfer/Server/StoreLog.hs +++ b/src/Simplex/FileTransfer/Server/StoreLog.hs @@ -44,6 +44,7 @@ data FileStoreLogRecord | AddRecipients SenderId (NonEmpty FileRecipient) | DeleteFile SenderId | AckFile RecipientId + deriving (Show) instance StrEncoding FileStoreLogRecord where strEncode = \case diff --git a/src/Simplex/Messaging/Notifications/Server/StoreLog.hs b/src/Simplex/Messaging/Notifications/Server/StoreLog.hs index d43700ad3..d11c01f76 100644 --- a/src/Simplex/Messaging/Notifications/Server/StoreLog.hs +++ b/src/Simplex/Messaging/Notifications/Server/StoreLog.hs @@ -50,6 +50,7 @@ data NtfStoreLogRecord | CreateSubscription NtfSubRec | SubscriptionStatus NtfSubscriptionId NtfSubStatus | DeleteSubscription NtfSubscriptionId + deriving (Show) data NtfTknRec = NtfTknRec { ntfTknId :: NtfTokenId, @@ -61,6 +62,7 @@ data NtfTknRec = NtfTknRec tknRegCode :: NtfRegCode, tknCronInterval :: Word16 } + deriving (Show) mkTknData :: NtfTknRec -> STM NtfTknData mkTknData NtfTknRec {ntfTknId, token, tknStatus = status, tknVerifyKey, tknDhKeys, tknDhSecret, tknRegCode, tknCronInterval = cronInt} = do @@ -81,6 +83,7 @@ data NtfSubRec = NtfSubRec tokenId :: NtfTokenId, subStatus :: NtfSubStatus } + deriving (Show) mkSubData :: NtfSubRec -> STM NtfSubData mkSubData NtfSubRec {ntfSubId, smpQueue, notifierKey, tokenId, subStatus = status} = do diff --git a/src/Simplex/Messaging/Server/StoreLog.hs b/src/Simplex/Messaging/Server/StoreLog.hs index c47b06eb5..cfe2cd82e 100644 --- a/src/Simplex/Messaging/Server/StoreLog.hs +++ b/src/Simplex/Messaging/Server/StoreLog.hs @@ -55,6 +55,7 @@ data StoreLogRecord | DeleteQueue QueueId | DeleteNotifier QueueId | UpdateTime QueueId RoundedSystemTime + deriving (Show) data SLRTag = CreateQueue_ @@ -74,10 +75,11 @@ instance StrEncoding QueueRec where "sid=" <> strEncode senderId, "sk=" <> strEncode senderKey ] - <> if sndSecure then " sndSecure=" <> strEncode sndSecure else "" + <> sndSecureStr <> maybe "" notifierStr notifier <> maybe "" updatedAtStr updatedAt where + sndSecureStr = if sndSecure then " sndSecure=" <> strEncode sndSecure else "" notifierStr ntfCreds = " notifier=" <> strEncode ntfCreds updatedAtStr t = " updated_at=" <> strEncode t