Store stanzaId and originId of messages
parent
9bb4ab454b
commit
c79e2e843c
|
@ -77,7 +77,7 @@ kde_enable_exceptions()
|
||||||
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Concurrent Qml Quick Svg Sql QuickControls2 Xml Multimedia Positioning Location)
|
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Concurrent Qml Quick Svg Sql QuickControls2 Xml Multimedia Positioning Location)
|
||||||
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} REQUIRED)
|
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} REQUIRED)
|
||||||
find_package(ZXing REQUIRED)
|
find_package(ZXing REQUIRED)
|
||||||
find_package(QXmpp 1.2.0 REQUIRED)
|
find_package(QXmpp 1.3.0 REQUIRED)
|
||||||
|
|
||||||
# Optional QtQuickCompiler
|
# Optional QtQuickCompiler
|
||||||
if(QUICK_COMPILER)
|
if(QUICK_COMPILER)
|
||||||
|
|
|
@ -46,7 +46,7 @@ Kaidan yourself can be found in our [Wiki][wiki].
|
||||||
|
|
||||||
Here are the general dependencies of Kaidan:
|
Here are the general dependencies of Kaidan:
|
||||||
* [Qt][qt-build-sources] (Core Concurrent Qml Quick Svg Sql QuickControls2 Xml Multimedia Positioning Location) (>= 5.14.0)
|
* [Qt][qt-build-sources] (Core Concurrent Qml Quick Svg Sql QuickControls2 Xml Multimedia Positioning Location) (>= 5.14.0)
|
||||||
* [QXmpp][qxmpp] (>= 1.2.0)
|
* [QXmpp][qxmpp] (>= 1.3.0)
|
||||||
* [Kirigami 2][kirigami-repo] (>= 5.67.0)
|
* [Kirigami 2][kirigami-repo] (>= 5.67.0)
|
||||||
* [ECM (extra-cmake-modules)][ecm]
|
* [ECM (extra-cmake-modules)][ecm]
|
||||||
* [ZXing-cpp][zxing-cpp] (>= 1.0.8)
|
* [ZXing-cpp][zxing-cpp] (>= 1.0.8)
|
||||||
|
|
|
@ -288,7 +288,6 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void onConnectionError(QXmppClient::Error error);
|
void onConnectionError(QXmppClient::Error error);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Starts a pending (enqueued) task (e.g. a password change) if the variable (e.g. a
|
* Starts a pending (enqueued) task (e.g. a password change) if the variable (e.g. a
|
||||||
|
|
|
@ -52,8 +52,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both need to be updated on version bump:
|
// Both need to be updated on version bump:
|
||||||
#define DATABASE_LATEST_VERSION 12
|
#define DATABASE_LATEST_VERSION 13
|
||||||
#define DATABASE_CONVERT_TO_LATEST_VERSION() DATABASE_CONVERT_TO_VERSION(12)
|
#define DATABASE_CONVERT_TO_LATEST_VERSION() DATABASE_CONVERT_TO_VERSION(13)
|
||||||
|
|
||||||
#define SQL_BOOL "BOOL"
|
#define SQL_BOOL "BOOL"
|
||||||
#define SQL_INTEGER "INTEGER"
|
#define SQL_INTEGER "INTEGER"
|
||||||
|
@ -285,6 +285,8 @@ void Database::createMessagesTable()
|
||||||
SQL_ATTRIBUTE(isSpoiler, SQL_BOOL)
|
SQL_ATTRIBUTE(isSpoiler, SQL_BOOL)
|
||||||
SQL_ATTRIBUTE(errorText, SQL_TEXT)
|
SQL_ATTRIBUTE(errorText, SQL_TEXT)
|
||||||
SQL_ATTRIBUTE(replaceId, SQL_TEXT)
|
SQL_ATTRIBUTE(replaceId, SQL_TEXT)
|
||||||
|
SQL_ATTRIBUTE(originId, SQL_TEXT)
|
||||||
|
SQL_ATTRIBUTE(stanzaId, SQL_TEXT)
|
||||||
"FOREIGN KEY(author) REFERENCES " DB_TABLE_ROSTER " (jid),"
|
"FOREIGN KEY(author) REFERENCES " DB_TABLE_ROSTER " (jid),"
|
||||||
"FOREIGN KEY(recipient) REFERENCES " DB_TABLE_ROSTER " (jid)"
|
"FOREIGN KEY(recipient) REFERENCES " DB_TABLE_ROSTER " (jid)"
|
||||||
)
|
)
|
||||||
|
@ -418,3 +420,12 @@ void Database::convertDatabaseToV12()
|
||||||
Utils::execQuery(query, "ALTER TABLE Messages ADD replaceId " SQL_TEXT);
|
Utils::execQuery(query, "ALTER TABLE Messages ADD replaceId " SQL_TEXT);
|
||||||
m_version = 12;
|
m_version = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Database::convertDatabaseToV13()
|
||||||
|
{
|
||||||
|
DATABASE_CONVERT_TO_VERSION(12);
|
||||||
|
QSqlQuery query(m_database);
|
||||||
|
Utils::execQuery(query, "ALTER TABLE Messages ADD stanzaId " SQL_TEXT);
|
||||||
|
Utils::execQuery(query, "ALTER TABLE Messages ADD originId " SQL_TEXT);
|
||||||
|
m_version = 13;
|
||||||
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ private:
|
||||||
void convertDatabaseToV10();
|
void convertDatabaseToV10();
|
||||||
void convertDatabaseToV11();
|
void convertDatabaseToV11();
|
||||||
void convertDatabaseToV12();
|
void convertDatabaseToV12();
|
||||||
|
void convertDatabaseToV13();
|
||||||
|
|
||||||
QSqlDatabase m_database;
|
QSqlDatabase m_database;
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,8 @@ void MessageDb::parseMessagesFromQuery(QSqlQuery &query, QVector<Message> &msgs)
|
||||||
int idxIsSpoiler = rec.indexOf("isSpoiler");
|
int idxIsSpoiler = rec.indexOf("isSpoiler");
|
||||||
int idxErrorText = rec.indexOf("errorText");
|
int idxErrorText = rec.indexOf("errorText");
|
||||||
int idxReplaceId = rec.indexOf("replaceId");
|
int idxReplaceId = rec.indexOf("replaceId");
|
||||||
|
int idxOriginId = rec.indexOf("originId");
|
||||||
|
int idxStanza = rec.indexOf("stanzaId");
|
||||||
|
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
Message msg;
|
Message msg;
|
||||||
|
@ -111,6 +113,8 @@ void MessageDb::parseMessagesFromQuery(QSqlQuery &query, QVector<Message> &msgs)
|
||||||
msg.setErrorText(query.value(idxErrorText).toString());
|
msg.setErrorText(query.value(idxErrorText).toString());
|
||||||
msg.setIsSpoiler(query.value(idxIsSpoiler).toBool());
|
msg.setIsSpoiler(query.value(idxIsSpoiler).toBool());
|
||||||
msg.setReplaceId(query.value(idxReplaceId).toString());
|
msg.setReplaceId(query.value(idxReplaceId).toString());
|
||||||
|
msg.setOriginId(query.value(idxOriginId).toString());
|
||||||
|
msg.setStanzaId(query.value(idxStanza).toString());
|
||||||
msg.setReceiptRequested(true); //this is useful with resending pending messages
|
msg.setReceiptRequested(true); //this is useful with resending pending messages
|
||||||
msgs << msg;
|
msgs << msg;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +175,10 @@ QSqlRecord MessageDb::createUpdateRecord(const Message &oldMsg, const Message &n
|
||||||
rec.append(Utils::createSqlField("isSpoiler", newMsg.isSpoiler()));
|
rec.append(Utils::createSqlField("isSpoiler", newMsg.isSpoiler()));
|
||||||
if (oldMsg.replaceId() != newMsg.replaceId())
|
if (oldMsg.replaceId() != newMsg.replaceId())
|
||||||
rec.append(Utils::createSqlField("replaceId", newMsg.replaceId()));
|
rec.append(Utils::createSqlField("replaceId", newMsg.replaceId()));
|
||||||
|
if (oldMsg.originId() != newMsg.originId())
|
||||||
|
rec.append(Utils::createSqlField("originId", newMsg.originId()));
|
||||||
|
if (oldMsg.stanzaId() != newMsg.stanzaId())
|
||||||
|
rec.append(Utils::createSqlField("stanzaId", newMsg.stanzaId()));
|
||||||
|
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
@ -255,6 +263,8 @@ void MessageDb::addMessage(const Message &msg)
|
||||||
record.setValue("mediaLastModified", msg.mediaLastModified().toMSecsSinceEpoch());
|
record.setValue("mediaLastModified", msg.mediaLastModified().toMSecsSinceEpoch());
|
||||||
record.setValue("errorText", msg.errorText());
|
record.setValue("errorText", msg.errorText());
|
||||||
record.setValue("replaceId", msg.replaceId());
|
record.setValue("replaceId", msg.replaceId());
|
||||||
|
record.setValue("originId", msg.originId());
|
||||||
|
record.setValue("stanzaId", msg.stanzaId());
|
||||||
|
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
Utils::execQuery(query, db.driver()->sqlStatement(
|
Utils::execQuery(query, db.driver()->sqlStatement(
|
||||||
|
|
|
@ -121,6 +121,8 @@ void MessageHandler::handleMessage(const QXmppMessage &msg)
|
||||||
message.setIsSpoiler(msg.isSpoiler());
|
message.setIsSpoiler(msg.isSpoiler());
|
||||||
message.setSpoilerHint(msg.spoilerHint());
|
message.setSpoilerHint(msg.spoilerHint());
|
||||||
message.setOutOfBandUrl(msg.outOfBandUrl());
|
message.setOutOfBandUrl(msg.outOfBandUrl());
|
||||||
|
message.setStanzaId(msg.stanzaId());
|
||||||
|
message.setOriginId(msg.originId());
|
||||||
|
|
||||||
// check if message contains a link and also check out of band url
|
// check if message contains a link and also check out of band url
|
||||||
if (!parseMediaUri(message, msg.outOfBandUrl(), false)) {
|
if (!parseMediaUri(message, msg.outOfBandUrl(), false)) {
|
||||||
|
@ -160,6 +162,7 @@ void MessageHandler::sendMessage(const QString& toJid,
|
||||||
msg.setTo(toJid);
|
msg.setTo(toJid);
|
||||||
msg.setBody(body);
|
msg.setBody(body);
|
||||||
msg.setId(QXmppUtils::generateStanzaHash());
|
msg.setId(QXmppUtils::generateStanzaHash());
|
||||||
|
msg.setOriginId(msg.id());
|
||||||
msg.setReceiptRequested(true);
|
msg.setReceiptRequested(true);
|
||||||
msg.setSentByMe(true);
|
msg.setSentByMe(true);
|
||||||
msg.setMediaType(MessageType::MessageText); // text message without media
|
msg.setMediaType(MessageType::MessageText); // text message without media
|
||||||
|
|
Loading…
Reference in New Issue