Fill out correctly the source of a cache

sql-rework
Tomasz Golinski 2020-01-25 16:49:32 +01:00
rodzic 03d6188758
commit e6dc8e930a
2 zmienionych plików z 20 dodań i 2 usunięć

Wyświetl plik

@ -18,6 +18,22 @@ static const std::string OKAPI_username = "services/users/by_username";
static const std::string OKAPI_user = "services/users/user";
static const std::string OKAPI_changelog = "services/replicate/changelog";
Okapi::Okapi(std::string server_url, std::string consumer_key) : url(server_url), key(consumer_key) {
if (url.find(".pl/") != std::string::npos)
service = "OC.pl";
if (url.find(".de/") != std::string::npos)
service = "OC.de";
if (url.find(".us/") != std::string::npos)
service = "OC.us";
if (url.find(".nl/") != std::string::npos)
service = "OC.nl";
if (url.find(".ro/") != std::string::npos)
service = "OC.ro";
if (url.find(".uk/") != std::string::npos)
service = "OC.uk";
}
// Callback for cURL easy interface used to save received output to std::string object
size_t Okapi::write_cb(char* ptr, __attribute__((unused)) size_t size, size_t nmemb, void* userdata) {
std::string* str = reinterpret_cast<std::string*>(userdata);
@ -135,7 +151,7 @@ Caches Okapi::get_caches(std::vector<std::pair<std::string, std::tm>> codes) {
c.owner = el.value()["owner"]["username"];
c.owner_uuid = el.value()["owner"]["uuid"];
c.pos = get_lat_lon(el.value()["location"]);
c.origin = "OC.pl";
c.origin = service;
c.fav = el.value()["recommendations"];
c.founds = el.value()["founds"];

Wyświetl plik

@ -11,6 +11,8 @@ private:
std::string url;
std::string key;
std::string service;
static size_t write_cb(char* ptr, size_t size, size_t nmemb, void* userdata);
std::string curl_post(std::string url, std::string post);
std::string get_user_caches_json(std::string uuid, int count = 0, int offset = 0);
@ -18,7 +20,7 @@ private:
std::string get_caches_json(std::string codes);
public:
Okapi(std::string server_url, std::string consumer_key) : url(server_url), key(consumer_key) {}
Okapi(std::string server_url, std::string consumer_key);
// Cache get_cache(std::string code);
Caches get_caches(std::vector<std::pair<std::string, std::tm>> codes);