kopia lustrzana https://gitlab.com/tomaszg/geostat
Fill out correctly the source of a cache
rodzic
03d6188758
commit
e6dc8e930a
18
okapi.cpp
18
okapi.cpp
|
@ -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"];
|
||||
|
||||
|
|
4
okapi.h
4
okapi.h
|
@ -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);
|
||||
|
|
Ładowanie…
Reference in New Issue