From 19edf09ae2f62607b6589190348ad67eafce00a4 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Wed, 5 Jan 2022 16:11:52 +0400 Subject: [PATCH] add deleteMsg to agent store interface (#255) --- src/Simplex/Messaging/Agent/Store.hs | 1 + src/Simplex/Messaging/Agent/Store/SQLite.hs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Simplex/Messaging/Agent/Store.hs b/src/Simplex/Messaging/Agent/Store.hs index 97a25ea3a..d891c1e2e 100644 --- a/src/Simplex/Messaging/Agent/Store.hs +++ b/src/Simplex/Messaging/Agent/Store.hs @@ -70,6 +70,7 @@ class Monad m => MonadAgentStore s m where getMsg :: s -> ConnId -> InternalId -> m Msg checkRcvMsg :: s -> ConnId -> InternalId -> m () updateRcvMsgAck :: s -> ConnId -> InternalId -> m () + deleteMsg :: s -> ConnId -> InternalId -> m () -- * Queue types diff --git a/src/Simplex/Messaging/Agent/Store/SQLite.hs b/src/Simplex/Messaging/Agent/Store/SQLite.hs index aba154090..de978d8ea 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite.hs @@ -514,6 +514,11 @@ instance (MonadUnliftIO m, MonadError StoreError m) => MonadAgentStore SQLiteSto |] (RcvMsgAcknowledged, connId, msgId) + deleteMsg :: SQLiteStore -> ConnId -> InternalId -> m () + deleteMsg st connId msgId = + liftIO . withTransaction st $ \db -> + DB.execute db "DELETE FROM messages WHERE conn_alias = ? AND internal_id = ?;" (connId, msgId) + -- * Auxiliary helpers instance ToField QueueStatus where toField = toField . serializeQueueStatus