mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Move stringify function to rapidjson-helpers
This commit is contained in:
parent
9bad40742f
commit
d4c31309f0
|
@ -68,7 +68,7 @@ bool PubSubClient::listen(rapidjson::Document &message)
|
|||
|
||||
rj::set(message, "nonce", uuid);
|
||||
|
||||
std::string payload = stringify(message);
|
||||
std::string payload = rj::stringify(message);
|
||||
sentMessages[uuid.toStdString()] = payload;
|
||||
|
||||
this->send(payload.c_str());
|
||||
|
@ -100,7 +100,7 @@ void PubSubClient::unlistenPrefix(const std::string &prefix)
|
|||
|
||||
rj::set(message, "nonce", CreateUUID());
|
||||
|
||||
std::string payload = stringify(message);
|
||||
std::string payload = rj::stringify(message);
|
||||
sentMessages[uuid.toStdString()] = payload;
|
||||
|
||||
this->send(payload.c_str());
|
||||
|
@ -747,7 +747,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
|
|||
std::string moderationAction;
|
||||
|
||||
if (!rj::getSafe(data, "moderation_action", moderationAction)) {
|
||||
debug::Log("Missing moderation action in data: {}", stringify(data));
|
||||
debug::Log("Missing moderation action in data: {}", rj::stringify(data));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,6 @@ bool getTargetUser(const rapidjson::Value &data, ActionUser &user)
|
|||
return rj::getSafe(data, "target_user_id", user.id);
|
||||
}
|
||||
|
||||
std::string stringify(const rapidjson::Value &v)
|
||||
{
|
||||
return pajlada::Settings::SettingManager::stringify(v);
|
||||
}
|
||||
|
||||
rapidjson::Document createListenMessage(const std::vector<std::string> &topicsVec,
|
||||
std::shared_ptr<providers::twitch::TwitchAccount> account)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
|
|||
|
||||
bool getTargetUser(const rapidjson::Value &data, ActionUser &user);
|
||||
|
||||
std::string stringify(const rapidjson::Value &v);
|
||||
|
||||
rapidjson::Document createListenMessage(const std::vector<std::string> &topicsVec,
|
||||
std::shared_ptr<providers::twitch::TwitchAccount> account);
|
||||
rapidjson::Document createUnlistenMessage(const std::vector<std::string> &topicsVec);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "util/rapidjson-helpers.hpp"
|
||||
|
||||
#include <rapidjson/prettywriter.h>
|
||||
|
||||
namespace chatterino {
|
||||
namespace rj {
|
||||
|
||||
|
@ -15,5 +17,14 @@ void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
|
|||
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);
|
||||
}
|
||||
|
||||
std::string stringify(const rapidjson::Value &value)
|
||||
{
|
||||
rapidjson::StringBuffer buffer;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||
value.Accept(writer);
|
||||
|
||||
return std::string(buffer.GetString());
|
||||
}
|
||||
|
||||
} // namespace rj
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <pajlada/settings/serialize.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
namespace chatterino {
|
||||
namespace rj {
|
||||
|
@ -93,5 +94,7 @@ bool getSafe(const rapidjson::Value &value, Type &out)
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string stringify(const rapidjson::Value &value);
|
||||
|
||||
} // namespace rj
|
||||
} // namespace chatterino
|
||||
|
|
Loading…
Reference in a new issue