diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index a7ce0b6f1..b88324077 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -397,7 +397,9 @@ acceptContact' c connId enableNtfs invId ownConnInfo = do withStore c (`getConn` contactConnId) >>= \case SomeConn _ ContactConnection {} -> do withStore' c $ \db -> acceptInvitation db invId ownConnInfo - joinConn c connId enableNtfs connReq ownConnInfo + joinConn c connId enableNtfs connReq ownConnInfo `catchError` \err -> do + withStore' c (`unacceptInvitation` invId) + throwError err _ -> throwError $ CMD PROHIBITED -- | Reject contact (RJCT command) in Reader monad diff --git a/src/Simplex/Messaging/Agent/Store/SQLite.hs b/src/Simplex/Messaging/Agent/Store/SQLite.hs index b7e6efae1..b1ca57618 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite.hs @@ -51,6 +51,7 @@ module Simplex.Messaging.Agent.Store.SQLite createInvitation, getInvitation, acceptInvitation, + unacceptInvitation, deleteInvitation, -- Messages updateRcvIds, @@ -548,6 +549,10 @@ acceptInvitation db invitationId ownConnInfo = ":invitation_id" := invitationId ] +unacceptInvitation :: DB.Connection -> InvitationId -> IO () +unacceptInvitation db invitationId = + DB.execute db "UPDATE conn_invitations SET accepted = 0, own_conn_info = NULL WHERE invitation_id = ?" (Only invitationId) + deleteInvitation :: DB.Connection -> ConnId -> InvitationId -> IO (Either StoreError ()) deleteInvitation db contactConnId invId = getConn db contactConnId $>>= \case