Commit 0beb640b authored by LNJ's avatar LNJ 💬

Last Message Correction: Follow new guidelines for multiple edits

There are upcoming changes of the expected behaviour when correcting a
message multiple times. The old way was to correct the last correction,
the new way is to always correct the original id.

See https://github.com/xsf/xeps/pull/764
parent 30db3ee1
......@@ -91,8 +91,6 @@ MessageHandler::~MessageHandler()
void MessageHandler::handleMessage(const QXmppMessage &msg)
{
bool isCarbonMessage = false;
if (msg.body().isEmpty())
return;
......@@ -154,6 +152,7 @@ void MessageHandler::handleMessage(const QXmppMessage &msg)
emit model->addMessageRequested(entry);
} else {
entry.edited = true;
entry.id = "";
emit model->updateMessageRequested(msg.replaceId(), entry);
}
#else
......@@ -171,7 +170,7 @@ void MessageHandler::handleMessage(const QXmppMessage &msg)
if (contactName.isEmpty())
contactName = contactJid;
if (!entry.sentByMe && !isCarbonMessage)
if (!entry.sentByMe)
Notifications::sendMessageNotification(contactName.toStdString(),
msg.body().toStdString());
......@@ -244,7 +243,6 @@ void MessageHandler::correctMessage(QString toJid, QString msgId, QString body)
MessageModel::Message msg;
msg.author = client->configuration().jidBare();
msg.recipient = toJid;
msg.id = QXmppUtils::generateStanzaHash(48);
msg.sentByMe = true;
msg.message = body;
msg.type = MessageType::MessageText; // text message without media
......@@ -253,7 +251,6 @@ void MessageHandler::correctMessage(QString toJid, QString msgId, QString body)
emit model->updateMessageRequested(msgId, msg);
QXmppMessage m(msg.author, msg.recipient, body);
m.setId(msg.id);
m.setReceiptRequested(true);
#if QXMPP_VERSION >= QT_VERSION_CHECK(1, 0, 0)
m.setReplaceId(msgId);
......
......@@ -155,8 +155,7 @@ void MessageModel::updateMessage(const QString id, Message msg)
if (!found)
return;
QString newId = msg.id.isEmpty() ? id : msg.id;
rec.setValue("id", newId);
rec.setValue("id", msg.id.isEmpty() ? id : msg.id);
rec.setValue("edited", msg.edited);
rec.setValue("isSent", msg.isSent);
rec.setValue("isDelivered", msg.isDelivered);
......
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