Commit 7bb67214 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Remove contents and insert them again until update algorithm is done

parent 2c9dfd6c
......@@ -53,6 +53,7 @@ private:
long long insertSipAddress (const std::string &sipAddress);
void insertContent (long long messageEventId, const Content &content);
void updateContent (long long messageEventId, long long messageContentId, const Content &content);
void removeContentsForChatMessageEvent (long long messageEventId);
long long insertContentType (const std::string &contentType);
long long insertBasicChatRoom (
long long peerSipAddressId,
......
......@@ -187,6 +187,18 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
soci::use(appData.first), soci::use(appData.second), soci::use(messageContentId);
}
void MainDbPrivate::removeContentsForChatMessageEvent (long long eventId) {
soci::session *session = dbSession.getBackendSession<soci::session>();
*session << "DELETE FROM chat_message_content WHERE event_id=:eventId", soci::use(eventId);
//TODO: remove file content if exists
//*session << "DELETE FROM chat_message_file_content WHERE chat_message_content_id=:messageContentId", soci::use(messageContentId);
//TODO: remove contents' app_data
//*session << "DELETE FROM chat_message_content_app_data WHERE chat_message_content_id=:messageContentId", soci::use(messageContentId);
}
long long MainDbPrivate::insertContentType (const string &contentType) {
L_Q();
soci::session *session = dbSession.getBackendSession<soci::session>();
......@@ -704,9 +716,10 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
*session << "UPDATE conference_chat_message_event SET state = :state WHERE event_id = :eventId",
soci::use(state), soci::use(eventId);
/*for (const Content *content : chatMessage->getContents())
updateContent(eventId, *content);*/
//TODO check if content needs to be inserted, updated or removed
//TODO: improve
removeContentsForChatMessageEvent(eventId);
for (const Content *content : chatMessage->getContents())
insertContent(eventId, *content);
}
long long MainDbPrivate::insertConferenceNotifiedEvent (const shared_ptr<EventLog> &eventLog, long long *chatRoomId) {
......
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