Commit d4ea3b11 authored by csh's avatar csh

OF-347 The domain should add support for Last Activity requests

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13973 b35dd754-fafc-0310-a699-88a17e54d16e
parent fea0986b
...@@ -60,10 +60,20 @@ public class IQLastActivityHandler extends IQHandler implements ServerFeaturesPr ...@@ -60,10 +60,20 @@ public class IQLastActivityHandler extends IQHandler implements ServerFeaturesPr
String username = packet.getTo() == null ? null : packet.getTo().getNode(); String username = packet.getTo() == null ? null : packet.getTo().getNode();
// Check if any of the usernames is null // Check if any of the usernames is null
if (sender == null || username == null) { if (sender == null) {
reply.setError(PacketError.Condition.forbidden); reply.setError(PacketError.Condition.forbidden);
return reply; return reply;
} }
if (username == null) {
// http://xmpp.org/extensions/xep-0012.html#server
// When the last activity query is sent to a server or component (i.e., to a JID of the form <domain.tld>),
// the information contained in the IQ reply reflects the uptime of the JID sending the reply.
// The seconds attribute specifies how long the host has been running since it was last (re-)started.
long uptime = XMPPServer.getInstance().getServerInfo().getLastStarted().getTime();
long lastActivityTime = (System.currentTimeMillis() - uptime) / 1000;
lastActivity.addAttribute("seconds", String.valueOf(lastActivityTime));
return reply;
}
try { try {
RosterItem item = rosterManager.getRoster(username).getRosterItem(packet.getFrom()); RosterItem item = rosterManager.getRoster(username).getRosterItem(packet.getFrom());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment