Hello,
I’'ve noticed that Wildfire returns a blank VCard when requesting VCard for non existing user.
First of all, I thought that it wasn’‘t the correct behaviour, so I have a look at the XEP (http://www.xmpp.org/extensions/xep-0054.html) and they don’'t mention what should be return when asking for a vcard of a non-existing user.
I think that the best is to return an item-not-found exception when user request VCard for a non existing user (and also maybe for user who hasn’'t define yet a vcard).
I’'ve patched the VCardManager to do so:
// Only try to get the vCard values of non-anonymous users
if (recipient != null) {
if (recipient.getNode() != null && server.isLocal(recipient)) {
VCardManager vManager = VCardManager.getInstance();
Element userVCard = vManager.getVCard(recipient.getNode());
if (userVCard != null) {
// Check if the requester wants to ignore some vCard''s fields
Element filter = packet.getChildElement()
.element(QName.get("filter", "vcard-temp-filter"));
if (filter != null) {
// Create a copy so we don''t modify the original vCard
userVCard = userVCard.createCopy();
// Ignore fields requested by the user
for (Iterator toFilter = filter.elementIterator(); toFilter.hasNext();)
{
Element field = (Element) toFilter.next();
Element fieldToRemove = userVCard.element(field.getName());
if (fieldToRemove != null) {
fieldToRemove.detach();
}
}
}
result.setChildElement(userVCard);
}
//PATCH BEGIN
else if(!UserManager.getInstance().isRegisteredUser(recipient.getNode())) {
result = IQ.createResultIQ(packet);
result.setChildElement(packet.getChildElement().createCopy());
result.setError(PacketError.Condition.item_not_found);
}
//PATCH END
}
What do you think?
Message was edited by: yann formated code