diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-09-26 15:20:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-26 15:20:53 +0200 |
commit | 4c8dcbc308eb0f4900e416e698f5f30e71daaad8 (patch) | |
tree | aa5fdaa81234a21c6919fac4958f84d7c26cd397 /lib/database.cpp | |
parent | 5904a61c59f0eef00aef07ef998658fd791ff139 (diff) | |
parent | 15b840d82d4794358fbf1271ea76e446b47db7e5 (diff) | |
download | libquotient-4c8dcbc308eb0f4900e416e698f5f30e71daaad8.tar.gz libquotient-4c8dcbc308eb0f4900e416e698f5f30e71daaad8.zip |
Merge #571: Unify reporting and handling of Olm errors
Diffstat (limited to 'lib/database.cpp')
-rw-r--r-- | lib/database.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/database.cpp b/lib/database.cpp index 4eb82cf5..2b472648 100644 --- a/lib/database.cpp +++ b/lib/database.cpp @@ -323,23 +323,21 @@ void Database::saveCurrentOutboundMegolmSession( const QOlmOutboundGroupSession& session) { const auto pickle = session.pickle(picklingMode); - if (pickle) { - auto deleteQuery = prepareQuery(QStringLiteral("DELETE FROM outbound_megolm_sessions WHERE roomId=:roomId AND sessionId=:sessionId;")); - deleteQuery.bindValue(":roomId", roomId); - deleteQuery.bindValue(":sessionId", session.sessionId()); - - auto insertQuery = prepareQuery(QStringLiteral("INSERT INTO outbound_megolm_sessions(roomId, sessionId, pickle, creationTime, messageCount) VALUES(:roomId, :sessionId, :pickle, :creationTime, :messageCount);")); - insertQuery.bindValue(":roomId", roomId); - insertQuery.bindValue(":sessionId", session.sessionId()); - insertQuery.bindValue(":pickle", pickle.value()); - insertQuery.bindValue(":creationTime", session.creationTime()); - insertQuery.bindValue(":messageCount", session.messageCount()); - - transaction(); - execute(deleteQuery); - execute(insertQuery); - commit(); - } + auto deleteQuery = prepareQuery(QStringLiteral("DELETE FROM outbound_megolm_sessions WHERE roomId=:roomId AND sessionId=:sessionId;")); + deleteQuery.bindValue(":roomId", roomId); + deleteQuery.bindValue(":sessionId", session.sessionId()); + + auto insertQuery = prepareQuery(QStringLiteral("INSERT INTO outbound_megolm_sessions(roomId, sessionId, pickle, creationTime, messageCount) VALUES(:roomId, :sessionId, :pickle, :creationTime, :messageCount);")); + insertQuery.bindValue(":roomId", roomId); + insertQuery.bindValue(":sessionId", session.sessionId()); + insertQuery.bindValue(":pickle", pickle); + insertQuery.bindValue(":creationTime", session.creationTime()); + insertQuery.bindValue(":messageCount", session.messageCount()); + + transaction(); + execute(deleteQuery); + execute(insertQuery); + commit(); } QOlmOutboundGroupSessionPtr Database::loadCurrentOutboundMegolmSession(const QString& roomId, const PicklingMode& picklingMode) |