[ejabberd] Any way to get the Nickname of the 'from' on some Presence 'Subscribe' request?

Badlop badlop at gmail.com
Thu Apr 28 18:11:55 MSD 2011

2011/4/27 Franky Orson <franky.orson at gmail.com>:
> Is there any way to still get the nickname of some user sending some
> presence 'subscribe'?
> Does anyone know of any tips on how this would be possible?

Look at how other clients do that: Psi, Gajim, Tkabber, ...

A user can specify his own nickname in his vCard.
And a user specifies the desired nickname for each contact in his roster.

Let's see how Psi handles this (I tested with ejabberd 2.1.6):
When Psi shows a subscription form to the user,
given a contact JID, Psi can retrieve that contact nick like this:

<iq type='get' to='contact at localhost'>
  <vCard xmlns='vcard-temp'/>

<iq from='contact at localhost'
	to='user at localhost/psi'
  <vCard xmlns='vcard-temp'>
    <FN>This is contact's full name</FN>
    <NICKNAME>This is contact's nickname</NICKNAME>

When the user Accepts the form, Psi sends this to the contact:
<presence from="user at localhost" type="subscribe" to="contact at localhost">
  <nick xmlns="http://jabber.org/protocol/nick">And this is user's
That is received by the contact.
If the contact client doesn't support that <nick> element, it can get
the user nickname
by requesting the user vcard, just like Psi did.


More information about the ejabberd mailing list