%ents; ]>
Last Activity This specification defines an XMPP protocol extension for communicating information about the last activity associated with an XMPP entity. It is typically used by an IM client to retrieve the most recent presence information from an offline contact by sending a last activity request to the server that hosts the account controlled by the contact. &LEGALNOTICE; 0012 Draft Standards Track Standards XMPP Core XMPP IM iq-last http://www.xmpp.org/schemas/iq-last.xsd &jer; &temas; &stpeter; 1.3 2008-07-16 psa

Corrected server processing rules to block queries to a full JID when the requesting entity is not authorized to view the presence of the user.

1.2 2007-02-15 psa

Per a vote of the XMPP Council, changed from Historical and Active to Standards Track and Draft; added Implementation Notes and clarified text throughout; added proviso to security considerations regarding client support; added section on Service Discovery.

1.1 2004-01-22 psa

Editorial revisions.

1.0 2002-01-22 psa

Changed status to Active.

0.3 2002-01-14 psa

Made appropriate changes to reflect status as informational.

0.2 2002-01-04 tjm

Converted to XML format.

0.1 2001-01-25 jm

Initial version from website.

It is often helpful to know the time of the last activity associated with a entity. The canonical usage is to discover when a disconnected user last accessed the server. The 'jabber:iq:last' namespace provides a method for retrieving that information. The 'jabber:iq:last' namespace can also be used to discover when a connected user was last active on the server (i.e., the user's idle time) or to query servers and components about their current uptime.

In order to request last activity information regarding another entity, the requesting entity shall send an &IQ; stanza of type "get" to the target entity, containing a &QUERY; element qualified by the 'jabber:iq:last' namespace:

]]>

The target entity MUST return either an IQ-result or an IQ-error. When returning an IQ-result, the target entity sends an &IQ; stanza of type='result' containing a &QUERY; element with a REQUIRED 'seconds' attribute and OPTIONAL XML character data.

]]>

The requesting entity must interpret the IQ-result based on the responding entity's JID type in order to determine the meaning of the information. Specifically, the information means something different depending on whether the responding entity has a JID of the form 'host', 'user@host', or 'user@host/resource'. These differences are explained more fully below.

The primary usage of the 'jabber:iq:last' namespace is to find out how long ago a user logged out (and, additionally, what their status message was at that time). This primary usage assumes that the IQ-get is sent to a bare JID &BAREJID;. When used in this way, the &QUERY; element contained in the IQ-result has a 'seconds' attribute, which is the number of seconds that have passed since the user last logged out. In addition, the element MAY contain XML character data that specifies the status message of the last unavailable presence received from the user. An example is shown below:

]]>

As specified in &xmppcore; and &xmppim;, an IQ stanza of type "get" sent to a bare JID &LOCALBARE; is handled by the user's server on the user's behalf, not delivered to one or more active resources.

If the requesting entity is not authorized to view the user's presence information (normally via a presence subscription as defined in XMPP-IM), the user's server MUST NOT return last activity information but instead MUST return a &forbidden; error in response to the last activity request.

]]>

If the requesting entity is authorized to view the user's presence information, the server shall return information about the last presence activity recorded by the server for that user.

Heading Home ]]>

In this example, the user logged out fifteen minutes and three seconds ago, and when they logged out they sent a presence stanza of type='unavailable' whose <status/> element contained the text "Heading Home".

If the user has at least one available resource when the server receives the request, the response SHOULD contain an empty <query/> element whose 'seconds' attribute is set to a value of '0'.

A requesting entity may send a last activity query to a full JID &LOCALFULL;.

]]>

In this case, the user's server shall either deliver the IQ to an available resource or respond on behalf of the user.

In particular, as with the offline query use case above, if the requesting entity is not authorized to view the user's presence information (normally via a presence subscription as defined in XMPP IM), the user's server MUST NOT deliver the IQ-get to an available resource but instead MUST return a &forbidden; error in response to the last activity request.

]]>

If the user's server delivers the IQ-get to one of the user's available resources, the user's client MAY respond with the idle time of the user (i.e., the last time that the user interacted with the client application).

]]>

In this example, the user has been idle for about two minutes.

Support for this functionality is OPTIONAL. A client that does not support the protocol, or that does not wish to divulge this information, MUST return a &unavailable; error.

]]>

If there is no available resource matching the user@host/resource in the 'to' attribute of the request, the server MUST follow the rules in XMPP IM in order to determine what error stanza to return.

When the last activity query is sent to a server or component (i.e., to a JID of the form &DOMAINBARE;), 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 up and running. The &QUERY; element SHOULD NOT contain XML character data.

]]>

In this example, the server has been up for a little more than 34 hours.

In order for a requesting entity to determine if a responding entity supports the last activity protocol, it SHOULD send a &xep0030; information request to the responding entity:

]]> ... ... ]]>

The information contained in an IQ reply for this namespace is inherently ambiguous. Specifically, for a bare JID &LOCALBARE; the information is the time since the JID was last connected to its server; for a full JID &LOCALFULL; the information is the time since the resource was last active in the context of an existing session; and for a bare domain the information is the uptime for the server or component. An application must take these differences into account when presenting the information to a human user.

A server MUST NOT allow an unauthorized entity to learn a user's network availability by sending a Last Activity request to a JID of the form user@host or user@host/resource; i.e., Last Activity information MAY be divulged only to those entities that have permission to view the user's presence via a presence subscription (potentially as restricted by &xep0016; or &xep0191;).

A client MUST provide a way for a human user to disable sending of Last Activity responses from the client's full JID &LOCALFULL;.

This document requires no interaction with &IANA;.

No action on the part of the ®ISTRAR; is necessary as a result of this document, since 'jabber:iq:last' is already registered in the protocol namespaces registry located at &NAMESPACES;.

The protocol documented by this schema is defined in XEP-0012: http://www.xmpp.org/extensions/xep-0012.html ]]>