Commit d11a6f2f authored by Linus Jahn's avatar Linus Jahn Committed by Jonah Brüchert
Browse files

MessageHandler: Fix receipt requests are not answered

Fixes #160.
parent cc3445ef
...@@ -119,7 +119,7 @@ void MessageHandler::handleMessage(const gloox::Message &stanza, gloox::MessageS ...@@ -119,7 +119,7 @@ void MessageHandler::handleMessage(const gloox::Message &stanza, gloox::MessageS
// add the message to the database // add the message to the database
messageModel->addMessage(&fromJid, &toJid, &timestamp, &body, &msgId, messageModel->addMessage(&fromJid, &toJid, &timestamp, &body, &msgId,
isSentByMe, &fromJidResource, &toJidResource); isSentByMe, &fromJidResource, &toJidResource);
// //
// Send a new notification | TODO: Resolve nickname from JID // Send a new notification | TODO: Resolve nickname from JID
...@@ -148,30 +148,27 @@ void MessageHandler::handleMessage(const gloox::Message &stanza, gloox::MessageS ...@@ -148,30 +148,27 @@ void MessageHandler::handleMessage(const gloox::Message &stanza, gloox::MessageS
newUnreadMessageForJid(&contactJid); newUnreadMessageForJid(&contactJid);
} }
if (message->hasEmbeddedStanza()) { // XEP-0184: Message Delivery Receipts
// XEP-0184: Message Delivery Receipts // try to get a possible delivery receipt
// try to get a possible delivery receipt gloox::Receipt *receipt = (gloox::Receipt*) message->findExtension<gloox::Receipt>(gloox::ExtReceipt);
gloox::Receipt *receipt = (gloox::Receipt*) message->findExtension<gloox::Receipt>(gloox::ExtReceipt);
if (receipt) {
if (receipt) { // get the type of the receipt
// get the type of the receipt gloox::Receipt::ReceiptType receiptType = receipt->rcpt();
gloox::Receipt::ReceiptType receiptType = receipt->rcpt(); if (receiptType == gloox::Receipt::Request) {
if (receiptType == gloox::Receipt::Request) { // send the asked confirmation, that the message has been arrived
// send the asked confirmation, that the message has been arrived // new message to the author of the request
// new message to the author of the request gloox::Message receiptMessage(gloox::Message::Chat, message->from());
gloox::Message receiptMessage(gloox::Message::Chat, message->from());
// add the receipt extension containing the request's message id
// add the receipt extension containing the request's message id gloox::Receipt *receiptPayload = new gloox::Receipt(gloox::Receipt::Received, message->id());
gloox::Receipt *receiptPayload = new gloox::Receipt(gloox::Receipt::Received, receiptMessage.addExtension(receiptPayload);
message->id());
receiptMessage.addExtension(receiptPayload); // send the receipt message
client->send(receiptMessage);
// send the receipt message } else if (receiptType == gloox::Receipt::Received) {
client->send(receiptMessage); // Delivery Receipt Received -> mark message as read in db
} else if (receiptType == gloox::Receipt::Received) { messageModel->setMessageAsDelivered(QString::fromStdString(receipt->id()));
// Delivery Receipt Received -> mark message as read in db
messageModel->setMessageAsDelivered(QString::fromStdString(receipt->id()));
}
} }
} }
} }
......
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