StanzaErrorType errorType = StanzaErrorType.CANCEL;
if (!(failedToDeliverStanza instanceof XMPPCoreStanza)) {
throw new DeliveryException("could not return to sender");
}
XMPPCoreStanza failedCoreStanza = (XMPPCoreStanza) failedToDeliverStanza;
if (failedCoreStanza.getType() != null && failedCoreStanza.getType().equals("error")) {
return; // do not answer these
}
if (deliveryExceptions == null) {
XMPPCoreStanza error = XMPPCoreStanza.getWrapper(ServerErrorResponses.getInstance().getStanzaError(
stanzaErrorCondition, failedCoreStanza, errorType, "stanza could not be delivered", "en", null));
stanzaRelay.relay(error.getTo(), error, IgnoreFailureStrategy.IGNORE_FAILURE_STRATEGY);
} else if (deliveryExceptions.size() == 1) {
DeliveryException deliveryException = deliveryExceptions.get(0);
if (deliveryException instanceof LocalRecipientOfflineException) {
// TODO implement 8.2.3 here
stanzaErrorCondition = StanzaErrorCondition.RECIPIENT_UNAVAILABLE;