Best presence calculated incorrectly (#3)
Unknown opened 4 years ago

I use ContactChangeStatusEvent to intercept contact's status changes.

The event provides 2 presences: bestPresence and lastPresence. I am trying to use "bestPresence" to show contact's status in the app.

However, the best presence calculation seem to be off. In my logs I am seeing something like this:

Contact user@domain, status changed to AWAY, message: null
BestPresence: type=null, status= (Not available as a result of being idle more than 15 min), show=XA
LastPresence: type=null, status=null, show=null

The first line shows App's own status AWAY based on the best presence which has show=XA - second line. However, as you can see in the third line, the lastPresence is "all nulls" which means, the user is back from XA to "available". So, this should be his best presence.

Unknown commented 4 years ago

ContactChangeStatusEvent has two properties: presence - what is best calculated presence for contact and lastReceivedPresence - contains presence what caused firing event. Please use latest library code, and try again. If it will not help, then I will need more details: what stanzas are received, etc.

Unknown commented 4 years ago

The problem still happens on code from today's repo. Here is complete log:

BestPresence: type=null, show=XA, status= (Not available as a result of being idle more than 15 min)
BestPresence stanza: 
<presence xmlns="jabber:client" from="sample@domain/gajim.54W7RLVK" to="kobit@domain" id="abcd9250-6f46-4129-b612-ff4ec9012c2a">
  <priority>30</priority>
  <show>xa</show>
  <status> (Not available as a result of being idle more than 15 min)</status>
  <idle xmlns="urn:xmpp:idle:1" since="2020-10-15T17:25:38Z"/>
  <c xmlns="http://jabber.org/protocol/caps" node="https://gajim.org" ver="lZlpLWr1GcE7e6Amd2w0l/77U48=" hash="sha-1"/>
  <x xmlns="vcard-temp:x:update">
    <photo>869b7799d3a28c45b7ea2075834398bdc179bfeb</photo>
  </x>
  <delay xmlns="urn:xmpp:delay" stamp="2020-10-15T17:30:50Z" from="ik.nu"/>
</presence>

LastPresence: type=null, show=XA, status= (Not available as a result of being idle more than 15 min)
LastPresence stanza: 
<presence xmlns="jabber:client" from="sample@domain/gajim.54W7RLVK" to="kobit@domain" id="abcd9250-6f46-4129-b612-ff4ec9012c2a">
  <priority>30</priority>
  <show>xa</show>
  <status> (Not available as a result of being idle more than 15 min)</status>
  <idle xmlns="urn:xmpp:idle:1" since="2020-10-15T17:25:38Z"/>
  <c xmlns="http://jabber.org/protocol/caps" node="https://gajim.org" ver="lZlpLWr1GcE7e6Amd2w0l/77U48=" hash="sha-1"/>
  <x xmlns="vcard-temp:x:update">
    <photo>869b7799d3a28c45b7ea2075834398bdc179bfeb</photo>
  </x>
  <delay xmlns="urn:xmpp:delay" stamp="2020-10-15T17:30:50Z" from="ik.nu"/>
</presence>

And then a few seconds later:

BestPresence: type=null, show=XA, status= (Not available as a result of being idle more than 15 min)
BestPresence stanza: 
<presence xmlns="jabber:client" from="sample@domain/gajim.54W7RLVK" to="kobit@domain" id="abcd9250-6f46-4129-b612-ff4ec9012c2a">
  <priority>30</priority>
  <show>xa</show>
  <status> (Not available as a result of being idle more than 15 min)</status>
  <idle xmlns="urn:xmpp:idle:1" since="2020-10-15T17:25:38Z"/>
  <c xmlns="http://jabber.org/protocol/caps" node="https://gajim.org" ver="lZlpLWr1GcE7e6Amd2w0l/77U48=" hash="sha-1"/>
  <x xmlns="vcard-temp:x:update">
    <photo>869b7799d3a28c45b7ea2075834398bdc179bfeb</photo>
  </x>
  <delay xmlns="urn:xmpp:delay" stamp="2020-10-15T17:30:50Z" from="ik.nu"/>
</presence>

LastPresence: type=null, show=null, status=null
LastPresence stanza: 
<presence xmlns="jabber:client" from="sample@domain/Conversations.edWE" to="kobit@domain"> 
  <c xmlns="http://jabber.org/protocol/caps" node="http://conversations.im" ver="i7p2hiK4xwPYfSVHCR6DAhqNrXU=" hash="sha-1"/>
  <x xmlns="vcard-temp:x:update">
    <photo>869b7799d3a28c45b7ea2075834398bdc179bfeb</photo>
  </x>
  <delay xmlns="urn:xmpp:delay" stamp="2020-10-14T07:07:58Z" from="ik.nu"/>
</presence>

My understanding of the concept is that, in the second part, the best presence should be the last presence as it is "better". It shows user as available, instead of XA.

Unknown commented 4 years ago

Best presence returns the best presence according to the XMPP protocol, so the presence with highest priority. In this case presence with show of xa has priority of 30, while the secondary presence has no priority (default value in this case is 0). Due to that, first presence is better than second one, even though second has better availability.

Unknown commented 4 years ago

Thank you for explanation. I understand that this works as intended. Closing the ticket then.

issue 1 of 1
Issue Votes (0)
Watchers (0)
Reference
tigase/_libraries/halcyon-cn1#3
Please wait...
Page is in error, reload to recover