Do not try to serialize something what is not Storage element
This commit is contained in:
parent
742ed6bc69
commit
fe74083e2e
2 changed files with 16 additions and 6 deletions
|
@ -27,7 +27,7 @@
|
|||
#include "Swiften/Swiften.h"
|
||||
#include "transport/storagebackend.h"
|
||||
#include "transport/config.h"
|
||||
#include "mysql.h"
|
||||
#include <pqxx/pqxx>
|
||||
|
||||
namespace Transport {
|
||||
|
||||
|
@ -99,6 +99,8 @@ class PQXXBackend : public StorageBackend
|
|||
bool exec(const std::string &query);
|
||||
Config *m_config;
|
||||
std::string m_prefix;
|
||||
|
||||
pqxx::connection *m_conn;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -71,11 +71,19 @@ bool StorageResponder::handleSetRequest(const Swift::JID& from, const Swift::JID
|
|||
return true;
|
||||
}
|
||||
|
||||
StorageSerializer serializer;
|
||||
std::string value = serializer.serializePayload(boost::dynamic_pointer_cast<Storage>(payload->getPayload()));
|
||||
m_storageBackend->updateUserSetting(user->getUserInfo().id, "storage", value);
|
||||
LOG4CXX_INFO(logger, from.toBare().toString() << ": Storing jabber:iq:storage");
|
||||
sendResponse(from, id, boost::shared_ptr<PrivateStorage>());
|
||||
boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload());
|
||||
|
||||
if (storage) {
|
||||
StorageSerializer serializer;
|
||||
std::string value = serializer.serializePayload(boost::dynamic_pointer_cast<Storage>(payload->getPayload()));
|
||||
m_storageBackend->updateUserSetting(user->getUserInfo().id, "storage", value);
|
||||
LOG4CXX_INFO(logger, from.toBare().toString() << ": Storing jabber:iq:storage");
|
||||
sendResponse(from, id, boost::shared_ptr<PrivateStorage>());
|
||||
}
|
||||
else {
|
||||
LOG4CXX_INFO(logger, from.toBare().toString() << ": Unknown element. Libtransport does not support serialization of this.");
|
||||
sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Cancel);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue