I have been trying to do so btw, but getExtension returns null. There is message.extensions method that returns all available extensions and I get only 1 - the message body. So I thought I should add/register this delay extension somehow, but it is not working still:
ProviderManager.addExtensionProvider(DelayInformation.ELEMENT, DelayInformation.NAMESPACE,
object: ExtensionElementProvider<DelayInformation>() {
override fun parse(
parser: XmlPullParser?,
initialDepth: Int,
xmlEnvironment: XmlEnvironment?
): DelayInformation {
val stampString = parser?.getAttributeValue(DelayInformation.NAMESPACE, "stamp")
val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault())
val date = stampString?.let { dateFormat.parse(it) }
return DelayInformation(date)
}
})
The <delay/> extension is not part of the message but part of the message envelope <forwarded/>. And MamQuery.getMessages() returns the “forwarded” messages, not the message envolope <forwarded/> that carries them.
You want to use MamQuery.getMamResultsExtensions().