From 522a5ffe6326d108801deec69f95a741fdc4a63c Mon Sep 17 00:00:00 2001
From: Andrea Gianarda <andrea.gianarda@belledonne-communications.com>
Date: Thu, 31 Aug 2023 09:54:54 +0200
Subject: [PATCH] Add debug logs

---
 src/chat/chat-room/chat-room.cpp              | 7 +++++--
 src/chat/chat-room/server-group-chat-room.cpp | 2 +-
 src/db/main-db.cpp                            | 5 +----
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/chat/chat-room/chat-room.cpp b/src/chat/chat-room/chat-room.cpp
index abd9eb5380..1e865019cf 100644
--- a/src/chat/chat-room/chat-room.cpp
+++ b/src/chat/chat-room/chat-room.cpp
@@ -95,9 +95,12 @@ void ChatRoomPrivate::sendIsComposingNotification() {
 void ChatRoomPrivate::addEvent(const shared_ptr<EventLog> &eventLog) {
 	L_Q();
 
-	q->getCore()->getPrivate()->mainDb->addEvent(eventLog);
-
 	EventLog::Type type = eventLog->getType();
+
+	if (!q->getCore()->getPrivate()->mainDb->addEvent(eventLog)) {
+		lWarning() << "Failed to add event of type " << type << " to the database";
+	}
+
 	if (type == EventLog::Type::ConferenceParticipantDeviceAdded ||
 	    type == EventLog::Type::ConferenceParticipantDeviceRemoved ||
 	    type == EventLog::Type::ConferenceParticipantDeviceStatusChanged) {
diff --git a/src/chat/chat-room/server-group-chat-room.cpp b/src/chat/chat-room/server-group-chat-room.cpp
index 187af9fb1b..7e5f6b9b6e 100644
--- a/src/chat/chat-room/server-group-chat-room.cpp
+++ b/src/chat/chat-room/server-group-chat-room.cpp
@@ -1165,7 +1165,7 @@ void ServerGroupChatRoomPrivate::queueMessage(const shared_ptr<Message> &msg) {
 	for (const auto &participant : q->getParticipants()) {
 		for (const auto &device : participant->getDevices()) {
 			// Queue the message for all devices except the one that sent it
-			if (!msg->fromAddr->weakEqual(*device->getAddress())) {
+			if (*msg->fromAddr != *device->getAddress()) {
 				queueMessage(msg, device->getAddress());
 			}
 		}
diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp
index f09bbfdbf1..3d0e5b60fb 100644
--- a/src/db/main-db.cpp
+++ b/src/db/main-db.cpp
@@ -1468,9 +1468,7 @@ void MainDbPrivate::updateConferenceChatMessageEvent(const shared_ptr<EventLog>
 		            ? dbState
 		            : state);
 		const int markedAsReadInt = markedAsRead ? 1 : 0;
-		*session << "UPDATE conference_chat_message_event SET state = :state, imdn_message_id = "
-		            ":imdnMessageId, marked_as_read = :markedAsRead"
-		            " WHERE event_id = :eventId",
+		*session << "UPDATE conference_chat_message_event SET state = :state, imdn_message_id = :imdnMessageId, marked_as_read = :markedAsRead WHERE event_id = :eventId",
 		    soci::use(stateInt), soci::use(imdnMessageId), soci::use(markedAsReadInt), soci::use(eventId);
 	}
 
@@ -3659,7 +3657,6 @@ void MainDb::initCleanup() {
 
 bool MainDb::addEvent(const shared_ptr<EventLog> &eventLog) {
 #ifdef HAVE_DB_STORAGE
-
 	if (!isInitialized()) {
 		lWarning() << "Database has not been initialized";
 		return false;
-- 
GitLab