I have run into an interesting bug. I’m building a fall back email plugin, and I am sending email messages to users, then sending a message packet back to the room/chat thread as the user that is not online to indicate that an email was sent to the user. However, when I send this message to a room, I get another packet to intercept ( the confirmation packet), and thus end up in an infinite loop. Am I missing something? I thought that if a packet is sent from the server, then it will not be marked as incoming to the packet interceptor:
My confirmation packet generator looks like this: ( the message_packet is the packet received, the to_jid, is the room, and the from_jid is the user that was offline.
private void sendConfirmationMessage(org.xmpp.packet.Message message_packet, JID to_jid, JID from_jid) {
// Send a message back to sender stating that we sent an // email
org.xmpp.packet.Message confirmation_message = new org.xmpp.packet.Message(); String from_email_addr;
try {
String[] results = getUserInfo(from_jid);
from_email_addr = results[2];
}
catch (UserNotFoundException exc) {
Log.debug("FallbackEmailPlugin: " + "Unexpected error while generating conf message");
return;
} confirmation_message.setType(message_packet.getType());
String thread = message_packet.getThread();
if (thread != null) {
confirmation_message.setThread(thread);
}
String conf_subject = message_packet.getSubject();
if (conf_subject != null) {
confirmation_message.setSubject("Re:" + conf_subject);
}
confirmation_message.setTo(to_jid);
confirmation_message.setFrom(from_jid);
confirmation_message.setBody(
"I'm not online, but I've been sent a message at"
+ " my email address: " +
from_email_addr);
message_router.route(confirmation_message);
}