diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index fa6b6ca51..0a1f2fbc6 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -2010,12 +2010,16 @@ static constexpr string &blobToString (string &in) { L_BEGIN_LOG_EXCEPTION + soci::session *session = d->dbSession.getBackendSession(); + soci::transaction tr(*session); + const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId); d->invalidConferenceEventsFromQuery(query, dbChatRoomId); - soci::session *session = d->dbSession.getBackendSession(); *session << "DELETE FROM event WHERE id IN (" + query + ")", soci::use(dbChatRoomId); + tr.commit(); + L_END_LOG_EXCEPTION } @@ -2044,6 +2048,7 @@ static constexpr string &blobToString (string &in) { L_BEGIN_LOG_EXCEPTION soci::session *session = d->dbSession.getBackendSession(); + soci::transaction tr(*session); soci::rowset rows = (session->prepare << query); for (const auto &row : rows) { @@ -2152,6 +2157,8 @@ static constexpr string &blobToString (string &in) { chatRooms.push_back(chatRoom); } + tr.commit(); + return chatRooms; L_END_LOG_EXCEPTION @@ -2200,6 +2207,9 @@ static constexpr string &blobToString (string &in) { L_BEGIN_LOG_EXCEPTION + soci::session *session = d->dbSession.getBackendSession(); + soci::transaction tr(*session); + const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId); d->invalidConferenceEventsFromQuery( @@ -2207,9 +2217,10 @@ static constexpr string &blobToString (string &in) { dbChatRoomId ); - soci::session *session = d->dbSession.getBackendSession(); *session << "DELETE FROM chat_room WHERE id = :chatRoomId", soci::use(dbChatRoomId); + tr.commit(); + L_END_LOG_EXCEPTION } @@ -2229,13 +2240,13 @@ static constexpr string &blobToString (string &in) { L_BEGIN_LOG_EXCEPTION - const long long &dbChatRoomId = d->selectChatRoomId(basicChatRoom->getChatRoomId()); - // TODO: Update events and chat messages. (Or wait signals.) soci::session *session = d->dbSession.getBackendSession(); soci::transaction tr(*session); + const long long &dbChatRoomId = d->selectChatRoomId(basicChatRoom->getChatRoomId()); + const ChatRoomId &newChatRoomId = clientGroupChatRoom->getChatRoomId(); const long long &peerSipAddressId = d->insertSipAddress(newChatRoomId.getPeerAddress().asString()); const long long &localSipAddressId = d->insertSipAddress(newChatRoomId.getLocalAddress().asString()); @@ -2282,9 +2293,11 @@ static constexpr string &blobToString (string &in) { L_BEGIN_LOG_EXCEPTION + soci::session *session = d->dbSession.getBackendSession(); + soci::transaction tr(*session); + const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId); - soci::session *session = d->dbSession.getBackendSession(); int capabilities = 0; *session << "SELECT capabilities FROM chat_room WHERE id = :chatRoomId", soci::use(dbChatRoomId), soci::into(capabilities); @@ -2295,6 +2308,8 @@ static constexpr string &blobToString (string &in) { *session << "UPDATE chat_room SET capabilities = :capabilities WHERE id = :chatRoomId", soci::use(capabilities), soci::use(dbChatRoomId); + tr.commit(); + L_END_LOG_EXCEPTION }