Commit 891df5ff authored by Ronan's avatar Ronan
Browse files

fix(MainDb): add missing transactions on little req, add safety

parent 3b64a06c
......@@ -2012,6 +2012,7 @@ int MainDb::getChatMessageCount (const ChatRoomId &chatRoomId) const {
" SELECT event_id FROM conference_event WHERE chat_room_id = :chatRoomId"
")";
soci::transaction tr(*session);
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
*session << query, soci::use(dbChatRoomId), soci::into(count);
}
......@@ -2045,6 +2046,7 @@ int MainDb::getUnreadChatMessageCount (const ChatRoomId &chatRoomId) const {
if (!chatRoomId.isValid())
*session << query, soci::into(count);
else {
soci::transaction tr(*session);
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
*session << query, soci::use(dbChatRoomId), soci::into(count);
}
......@@ -2079,6 +2081,7 @@ void MainDb::markChatMessagesAsRead (const ChatRoomId &chatRoomId) const {
if (!chatRoomId.isValid())
*session << query;
else {
soci::transaction tr(*session);
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
*session << query, soci::use(dbChatRoomId);
}
......@@ -2280,10 +2283,11 @@ int MainDb::getHistorySize (const ChatRoomId &chatRoomId, FilterMask mask) const
return L_SAFE_TRANSACTION {
L_D();
soci::session *session = d->dbSession.getBackendSession();
soci::transaction tr(*session);
int count;
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
soci::session *session = d->dbSession.getBackendSession();
*session << query, soci::into(count), soci::use(dbChatRoomId);
return count;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment