MCPcopy Create free account
hub / github.com/chrxh/alien / getUserNamesForResourceAndEmojiType

Method getUserNamesForResourceAndEmojiType

source/Network/NetworkService.cpp:382–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382bool NetworkService::getUserNamesForResourceAndEmojiType(std::set<std::string>& result, std::string const& simId, int likeType)
383{
384 log(Priority::Important, "network: get user reactions for resource with id=" + simId + " and reaction type=" + std::to_string(likeType));
385
386 httplib::SSLClient client(_serverAddress);
387 configureClient(client);
388
389 httplib::Params params;
390 params.emplace("simId", simId);
391 params.emplace("likeType", std::to_string(likeType));
392
393 try {
394 auto postResult = executeRequest([&] { return client.Post("/alien-server/getuserlikes.php", params); });
395
396 std::stringstream stream(postResult->body);
397 boost::property_tree::ptree tree;
398 boost::property_tree::read_json(stream, tree);
399
400 result.clear();
401 for (auto const& [key, subTree] : tree) {
402 result.insert(subTree.get<std::string>("userName"));
403 }
404 return true;
405 } catch (...) {
406 logNetworkError();
407 return false;
408 }
409}
410
411bool NetworkService::toggleReactionForResource(std::string const& simId, int likeType)
412{

Callers 1

processRequestMethod · 0.80

Calls 7

logFunction · 0.85
to_stringFunction · 0.85
configureClientFunction · 0.85
executeRequestFunction · 0.85
logNetworkErrorFunction · 0.85
PostMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected