Listen for offline messages

How would one listen for offline message creation in a plugin so one could decide to email it or do something else interesting with it?

camclive,

I hunted through the code and don’'t see any listeners for new offline messages. It seems like a good idea for a new feature, though. I filed this as JM-912.

Regards,

Matt

I remember submitting some code for this a long time again so JM-236 could be implemented.

I’'ll do some digging to see if I still have it around somewhere…

I certainly hope you can get this feature added as I think it will be very useful.

I suppose an event for addOfflineMessage and removeOfflineMessage would be good.

The plugin attempts I have seen by following the links given seem to just listen for every mesage and do a presence check which is obviously not the best solution.

Maybe this can help you out… i had it done for myself but you can have a use for it altogether… or you can extend to process the messages collection or anything else you should need on it… major problem with this is just it is a pull service not a push (I used it for a general pending messages notification on a one-to-one IM with non-mandatory open window)

In UserService I added the following:

#UserServicePlugin.java:

public int getMessages(String jid)

{

OfflineMessageStore offmessage = server.getOfflineMessageStore() ;

Collection messages = offmessage.getMessages(jid,false) ;

return messages.size() ;

}

#UserServicePluginServlet.java:

else if (“getmessages”.equals(type)) {

int temp=plugin.getMessages(jid);

Integer res = new Integer(temp) ;

replyMessage(res.toString(),response,out);

//xmlProvider.sendInfo(request, response, presence);

}