Smack 4.4.0: LastActivityManager public boolean isLastActivitySupported(Jid) implementation and usage

This is not a bug but for general discussion:
Smack supports the inquiry LastActivity support for a contact via

public boolean isLastActivitySupported(Jid jid)

where jid needs to be FullJid. Generally contact last activity info is of use when the contact is offline. However use of the above method when contact is offline return errors as shown below.

2019-08-13 08:40:01.154 32464-715/org.atalk.android D/SMACK: SENT (0): 
    <iq to='eagle@atalk.org/atalk' id='Q1SPN-131' type='get'>
      <query xmlns='http://jabber.org/protocol/disco#info'>
      </query>
    </iq>
2019-08-13 08:40:01.169 32464-716/org.atalk.android D/SMACK: RECV (0): 
    <iq xml:lang='en' to='swordfish@atalk.org/atalk' from='eagle@atalk.org/atalk' type='error' id='Q1SPN-131'>
      <query xmlns='http://jabber.org/protocol/disco#info'/>
      <error code='503' type='cancel'>
        <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
        <text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>
          User session not found
        </text>
      </error>
    </iq>

if the contact is offline when a user login, invoke the isLastActivitySupported() method will always throw exception. I am not sure how this method is being used in application actual implementation and when to use this method.

XEP-0012: Last Activity states the following (quoted from §3):

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 <localpart@domain.tld>.

You example shows the use with a full jid, which describes the online use case (as described in §4).

A requesting entity can send a last activity query to the full JID <localpart@domain.tld/resource> of a connected or available resource associated with an account.

Smacks API is correct in that you can only ask a device that is currently online, if it supports last activity. It probably wouldn’t make sense to query offline devices for support.

Thanks for the clarifications.

Yes, aTalk v2.0.3 uses the last activity for offline contact to show his/her last access. So it only asks for last access time without checking for feature support.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.