diff --git a/src/chat/chat-room/abstract-chat-room.h b/src/chat/chat-room/abstract-chat-room.h index 8a259466f..4de1c99d2 100644 --- a/src/chat/chat-room/abstract-chat-room.h +++ b/src/chat/chat-room/abstract-chat-room.h @@ -41,6 +41,7 @@ class LINPHONE_PUBLIC AbstractChatRoom : public Object, public CoreAccessor, pub friend class Core; friend class CorePrivate; friend class MainDb; + friend class MainDbPrivate; friend class ProxyChatRoomPrivate; public: diff --git a/src/chat/chat-room/client-group-chat-room-p.h b/src/chat/chat-room/client-group-chat-room-p.h index e617b517d..c3713e547 100644 --- a/src/chat/chat-room/client-group-chat-room-p.h +++ b/src/chat/chat-room/client-group-chat-room-p.h @@ -38,6 +38,8 @@ public: void setCallSessionListener (CallSessionListener *listener); void setChatRoomListener (ChatRoomListener *listener) { chatRoomListener = listener; } + unsigned int getLastNotifyId () const; + // ChatRoomListener void onChatRoomInsertRequested (const std::shared_ptr &chatRoom) override; void onChatRoomInsertInDatabaseRequested (const std::shared_ptr &chatRoom) override; diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index f200a7f4f..edbad78e1 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -103,6 +103,12 @@ void ClientGroupChatRoomPrivate::setCallSessionListener (CallSessionListener *li } } +unsigned int ClientGroupChatRoomPrivate::getLastNotifyId () const { + L_Q_T(RemoteConference, qConference); + + return qConference->getPrivate()->eventHandler->getLastNotify(); +} + // ----------------------------------------------------------------------------- void ClientGroupChatRoomPrivate::onChatRoomInsertRequested (const shared_ptr &chatRoom) { diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index fa5e63b6a..ebad9d530 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -24,7 +24,7 @@ #include "chat/chat-message/chat-message-p.h" #include "chat/chat-room/chat-room-p.h" -#include "chat/chat-room/client-group-chat-room.h" +#include "chat/chat-room/client-group-chat-room-p.h" #include "chat/chat-room/server-group-chat-room.h" #include "conference/participant-device.h" #include "conference/participant-p.h" @@ -333,13 +333,23 @@ long long MainDbPrivate::insertChatRoom (const shared_ptr &cha // Remove capabilities like `Proxy`. const int &capabilities = chatRoom->getCapabilities() & ~ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::Proxy); + unsigned int lastNotifyId = 0; + if (!linphone_core_conference_server_enabled(chatRoom->getCore()->getCCore()) + && (chatRoom->getCapabilities() & ChatRoom::Capabilities::Conference) + ) + lastNotifyId = static_cast(chatRoom->getPrivate())->getLastNotifyId(); + const string &subject = chatRoom->getSubject(); const int &flags = chatRoom->hasBeenLeft(); *dbSession.getBackendSession() << "INSERT INTO chat_room (" - " peer_sip_address_id, local_sip_address_id, creation_time, last_update_time, capabilities, subject, flags" - ") VALUES (:peerSipAddressId, :localSipAddressId, :creationTime, :lastUpdateTime, :capabilities, :subject, :flags)", - soci::use(peerSipAddressId), soci::use(localSipAddressId), soci::use(creationTime), soci::use(lastUpdateTime), - soci::use(capabilities), soci::use(subject), soci::use(flags); + " peer_sip_address_id, local_sip_address_id, creation_time," + " last_update_time, capabilities, subject, flags, last_notify_id" + ") VALUES (" + " :peerSipAddressId, :localSipAddressId, :creationTime," + " :lastUpdateTime, :capabilities, :subject, :flags, :lastNotifyId" + ")", + soci::use(peerSipAddressId), soci::use(localSipAddressId), soci::use(creationTime), + soci::use(lastUpdateTime), soci::use(capabilities), soci::use(subject), soci::use(flags), soci::use(lastNotifyId); id = dbSession.getLastInsertId(); if (!chatRoom->canHandleParticipants())