Commit 2e0dd790 authored by Ronan's avatar Ronan
Browse files

feat(MainDb): enable legacy history import

parent c89611f4
......@@ -6689,8 +6689,12 @@ int linphone_core_get_video_dscp(const LinphoneCore *lc){
return lp_config_get_int(lc->config,"rtp","video_dscp",0);
}
void linphone_core_set_chat_database_path (LinphoneCore *, const char *) {
lError() << "Do not use `linphone_core_set_chat_database_path`. Not necessary.";
void linphone_core_set_chat_database_path (LinphoneCore *lc, const char *path) {
if (
linphone_core_conference_server_enabled(lc) ||
!L_GET_PRIVATE(lc->cppPtr)->mainDb->import(LinphonePrivate::MainDb::Sqlite3, path)
)
lError() << "Do not use `linphone_core_set_chat_database_path`. Not necessary.";
}
const char *linphone_core_get_chat_database_path (const LinphoneCore *) {
......
......@@ -42,6 +42,7 @@
#include "main-db-p.h"
#define DB_MODULE_VERSION_EVENTS L_VERSION(1, 0, 0)
#define DB_MODULE_VERSION_LEGACY_HISTORY_IMPORT L_VERSION(1, 0, 0)
// =============================================================================
......@@ -2242,10 +2243,15 @@ static constexpr string &blobToString (string &in) {
// Import messages.
try {
soci::transaction tr(*d->dbSession.getBackendSession<soci::session>());
unsigned int version = d->getModuleVersion("legacy-history-import");
if (version >= L_VERSION(1, 0, 0))
return false;
d->updateModuleVersion("legacy-history-import", DB_MODULE_VERSION_LEGACY_HISTORY_IMPORT);
soci::rowset<soci::row> messages = (inSession->prepare << "SELECT * FROM history");
try {
soci::transaction tr(*d->dbSession.getBackendSession<soci::session>());
for (const auto &message : messages) {
const int direction = message.get<int>(LEGACY_MESSAGE_COL_DIRECTION);
if (direction != 0 && direction != 1) {
......
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