void CapsManager::handleDiscoInfoReceived(const JID& from, const std::string& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) { requestedDiscoInfos.erase(hash); if (error || !discoInfo || CapsInfoGenerator("", crypto).generateCapsInfo(*discoInfo.get()).getVersion() != hash) { if (warnOnInvalidHash && !error && discoInfo) { SWIFT_LOG(warning) << "Caps from " << from.toString() << " do not verify" << std::endl; } failingCaps.insert(std::make_pair(from, hash)); std::map<std::string, std::set< std::pair<JID, std::string> > >::iterator i = fallbacks.find(hash); if (i != fallbacks.end() && !i->second.empty()) { std::pair<JID,std::string> fallbackAndNode = *i->second.begin(); i->second.erase(i->second.begin()); requestDiscoInfo(fallbackAndNode.first, fallbackAndNode.second, hash); } return; } fallbacks.erase(hash); capsStorage->setDiscoInfo(hash, discoInfo); onCapsAvailable(hash); }
void CapsFileStorage::setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo) { DiscoInfo::ref bareDiscoInfo(new DiscoInfo(*discoInfo.get())); bareDiscoInfo->setNode(""); DiscoInfoPersister().savePayload(bareDiscoInfo, getCapsPath(hash)); }