powered by Jive Software

Send delivery response manually


#1

Hey,
I´m using MAM messages in my Android app and I want to send a response to a message sender, if the recipient reached the message.

If both chat partners are online, the delivery response function is working fine.
But if the message is loaded from the MAM, the delivery response doesn´t get triggered.

For this case I want to send the response manually, but I don´t know how to do it.

Can I get an example?

Thanks in advance.


#2

I’m confused. You want to send the reponse, or handling incoming MAM messages being delivery receipts just like live delivery receipts?


#3

I want to send a response, if the message is loaded from the MAM.


#4

I see.

I don’t think that you should do that, as the requestor of the receipt possibly already has forgotten about it, or even worse, that he considers the receipt for another message because he re-used the stanza ID.

But if you really want to do it, the logic is simple

for (Message mamMessage : mamMessages) {
  DeliverReceiptRequest request = DeliveryReceiptRequest.from(mam-message);
  if (request == null) continue;
  Message receipt = DeliveryReceiptManager.receiptMessageFor(request);
  connection.sendStanza(receipt);
}

Of course you first have to unwrap the messages from the Forwarded.


#5

Before, I casted the ‘ForwaredStanza’ object into a ‘Message’, because I can get the values from it,
but it is the wrong way right?

Here is my code, what I did:

return (Message) mamQueryResult.forwardedMessages.get(0).getForwardedStanza()

#6

No, that looks correct.


#7

Okay, but this does not work.
It seems that this is not working for messages which are loaded from the MAM, because from the OfflineMessageManager it works well.


#8

I’m sorry, but “does not” work is not a very good problem description.


#9

If I load the message from the MAM storage, the DeliveryReceiptManager does not automatically sends a response to the message sender.

Because if I load the message from the OfflineMessageStorage, then the response for the message is sent dirctly.


#10

Right, that is expected behavior. I was referring to your attempt to manually send receipts for messages returned by a MAM query.


#11

Okay, I thought that its working like to receive the message from the OfflineMessageManager.
So in this case, the solution, to send the response manually, should not run into problems?


#12

Have a look at https://xmpp.org/extensions/xep-0013.html, xep13 offline messages are delivered in line like live messages. That triggers the deliver receipts manager automatism. Unlike xep313 messages, which are wrapped in a forwarded.

None problems besides the one I mentioned and that you should ensure to not ack a message which already got a receipt. Again, I personally would possibly not go down that route.