Fixed VCard without to attribute

This commit is contained in:
HanzZ 2011-06-19 19:53:53 +02:00
parent cbc80e06db
commit 2d49798d12

View file

@ -56,6 +56,7 @@ void VCardResponder::sendVCard(unsigned int id, boost::shared_ptr<Swift::VCard>
bool VCardResponder::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::VCard> payload) {
// Get means we're in server mode and user wants to fetch his roster.
// For now we send empty reponse, but TODO: Get buddies from database and send proper stored roster.
std::cout << "VCARD\n";
User *user = m_userManager->getUser(from.toBare().toString());
if (!user) {
return false;
@ -66,13 +67,15 @@ bool VCardResponder::handleGetRequest(const Swift::JID& from, const Swift::JID&
std::string name = to_.getUnescapedNode();
if (name.empty()) {
to_ = user->getComponent()->getJID();
std::string name = to_.getUnescapedNode();
name = to_.getUnescapedNode();
}
if (name.find_last_of("%") != std::string::npos) {
name.replace(name.find_last_of("%"), 1, "@");
}
std::cout << "VCARD1 " << name << "\n";
m_queries[m_id].from = from;
m_queries[m_id].to = to_;
m_queries[m_id].id = id;