aboutsummaryrefslogtreecommitdiff
path: root/lib/database.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-12-10 17:01:05 +0100
committerTobias Fella <fella@posteo.de>2021-12-10 17:01:05 +0100
commit6b29d759a47012eef74948e72c0d0395eb6bf282 (patch)
tree69e6512eb984a5d71055fcdb441e95d06ecae5bb /lib/database.cpp
parent4a17403f9adad9b4390f7e0010c0f7e23a718f7b (diff)
downloadlibquotient-6b29d759a47012eef74948e72c0d0395eb6bf282.tar.gz
libquotient-6b29d759a47012eef74948e72c0d0395eb6bf282.zip
Remove data from database when leaving room
Diffstat (limited to 'lib/database.cpp')
-rw-r--r--lib/database.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/database.cpp b/lib/database.cpp
index 41e62935..665b931a 100644
--- a/lib/database.cpp
+++ b/lib/database.cpp
@@ -14,8 +14,6 @@
#include "e2ee/qolmsession.h"
#include "e2ee/qolminboundsession.h"
-//TODO: delete room specific data when leaving room
-
using namespace Quotient;
Database::Database(const QString& matrixId, QObject* parent)
: QObject(parent)
@@ -229,3 +227,15 @@ QSqlQuery Database::prepareQuery(const QString& queryString)
query.prepare(queryString);
return query;
}
+
+void Database::clearRoomData(const QString& roomId)
+{
+ auto query = prepareQuery(QStringLiteral("DELETE FROM inbound_megolm_sessions WHERE roomId=:roomId;"));
+ auto query2 = prepareQuery(QStringLiteral("DELETE FROM outbound_megolm_sessions WHERE roomId=:roomId;"));
+ auto query3 = prepareQuery(QStringLiteral("DELETE FROM group_session_record_index WHERE roomId=:roomId;"));
+ transaction();
+ execute(query);
+ execute(query2);
+ execute(query3);
+ commit();
+}