diff --git a/src/chat/chat-room/client-group-chat-room.cpp b/src/chat/chat-room/client-group-chat-room.cpp index 7371bb27c..1d8660966 100644 --- a/src/chat/chat-room/client-group-chat-room.cpp +++ b/src/chat/chat-room/client-group-chat-room.cpp @@ -102,7 +102,8 @@ ClientGroupChatRoom::ClientGroupChatRoom ( const IdentityAddress &peerAddress, shared_ptr &me, const string &subject, - list> &&participants + list> &&participants, + unsigned int lastNotifyId ) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(peerAddress, me->getAddress())), RemoteConference(core, me->getAddress(), nullptr) { L_D(); @@ -117,6 +118,7 @@ RemoteConference(core, me->getAddress(), nullptr) { getMe()->getPrivate()->setAdmin(me->isAdmin()); + dConference->eventHandler->setLastNotify(lastNotifyId); dConference->eventHandler->subscribe(getChatRoomId()); } diff --git a/src/chat/chat-room/client-group-chat-room.h b/src/chat/chat-room/client-group-chat-room.h index 9e55d915f..042d7a59f 100644 --- a/src/chat/chat-room/client-group-chat-room.h +++ b/src/chat/chat-room/client-group-chat-room.h @@ -44,7 +44,8 @@ public: const IdentityAddress &peerAddress, std::shared_ptr &me, const std::string &subject, - std::list> &&participants + std::list> &&participants, + unsigned int lastNotifyId ); std::shared_ptr getCore () const; diff --git a/src/conference/handlers/remote-conference-event-handler.cpp b/src/conference/handlers/remote-conference-event-handler.cpp index c6be552f1..a2791164d 100644 --- a/src/conference/handlers/remote-conference-event-handler.cpp +++ b/src/conference/handlers/remote-conference-event-handler.cpp @@ -170,7 +170,6 @@ Object(*new RemoteConferenceEventHandlerPrivate) { L_D(); xercesc::XMLPlatformUtils::Initialize(); d->conf = remoteConference; - // TODO : d->lastNotify = lastNotify } RemoteConferenceEventHandler::~RemoteConferenceEventHandler () { @@ -182,13 +181,16 @@ RemoteConferenceEventHandler::~RemoteConferenceEventHandler () { void RemoteConferenceEventHandler::subscribe (const ChatRoomId &chatRoomId) { L_D(); d->chatRoomId = chatRoomId; - LinphoneAddress *lAddr = linphone_address_new(d->chatRoomId.getPeerAddress().asString().c_str()); + const string &peerAddress = d->chatRoomId.getPeerAddress().asString(); + LinphoneAddress *lAddr = linphone_address_new(peerAddress.c_str()); d->lev = linphone_core_create_subscribe(d->conf->getCore()->getCCore(), lAddr, "conference", 600); d->lev->op->set_from(d->chatRoomId.getLocalAddress().asString().c_str()); - linphone_event_add_custom_header(d->lev, "Last-Notify-Version", Utils::toString(d->lastNotify).c_str()); + const string &lastNotify = Utils::toString(d->lastNotify); + linphone_event_add_custom_header(d->lev, "Last-Notify-Version", lastNotify.c_str()); linphone_address_unref(lAddr); linphone_event_set_internal(d->lev, TRUE); linphone_event_set_user_data(d->lev, this); + lInfo() << "Subscribing to chat room: " << peerAddress << "with last notify: " << lastNotify; linphone_event_send_subscribe(d->lev, nullptr); } @@ -234,9 +236,14 @@ unsigned int RemoteConferenceEventHandler::getLastNotify () const { return d->lastNotify; }; -void RemoteConferenceEventHandler::resetLastNotify () { +void RemoteConferenceEventHandler::setLastNotify (unsigned int lastNotify) { L_D(); - d->lastNotify = 0; + d->lastNotify = lastNotify; } +void RemoteConferenceEventHandler::resetLastNotify () { + setLastNotify(0); +} + + LINPHONE_END_NAMESPACE diff --git a/src/conference/handlers/remote-conference-event-handler.h b/src/conference/handlers/remote-conference-event-handler.h index ecd443e19..2074d0539 100644 --- a/src/conference/handlers/remote-conference-event-handler.h +++ b/src/conference/handlers/remote-conference-event-handler.h @@ -43,6 +43,7 @@ public: const ChatRoomId &getChatRoomId () const; unsigned int getLastNotify () const; + void setLastNotify (unsigned int lastNotify); void resetLastNotify (); private: diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 02708c15f..d3f4f7802 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -700,7 +700,7 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), soci::session *session = dbSession.getBackendSession(); *session << "INSERT INTO conference_notified_event (event_id, notify_id)" " VALUES (:eventId, :notifyId)", soci::use(eventId), soci::use(lastNotifyId); - *session << "UPDATE chat_room SET last_notify_id = :lastNotifyId WHERE peer_sip_address_id = :chatRoomId", + *session << "UPDATE chat_room SET last_notify_id = :lastNotifyId WHERE id = :chatRoomId", soci::use(lastNotifyId), soci::use(curChatRoomId); if (chatRoomId) @@ -1650,9 +1650,6 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), string subject = row.get(6); unsigned int lastNotifyId = static_cast(row.get(7, 0)); - // TODO: Use me. - (void)lastNotifyId; - if (capabilities & static_cast(ChatRoom::Capabilities::Basic)) { chatRoom = core->getPrivate()->createBasicChatRoom( chatRoomId, @@ -1687,7 +1684,7 @@ MainDb::MainDb (const shared_ptr &core) : AbstractDb(*new MainDbPrivate), continue; } - chatRoom = make_shared(core, chatRoomId.getPeerAddress(), me, subject, move(participants)); + chatRoom = make_shared(core, chatRoomId.getPeerAddress(), me, subject, move(participants), lastNotifyId); } if (!chatRoom)