diff options
-rw-r--r-- | src/api.cpp | 2 | ||||
-rw-r--r-- | src/curl_wrapper.cpp | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/api.cpp b/src/api.cpp index fd7eede..d0ffefa 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -31,7 +31,7 @@ const map<API::endpoint_type,string_view> API::_endpoint_map {v1::accounts, "/api/v1/accounts"}, {v1::accounts_verify_credentials, "/api/v1/accounts/verify/credentials"}, {v1::accounts_update_credentials, "/api/v1/accounts/update/credentials"}, - {v1::accounts_id, "/api/v1/accounts/id"}, + {v1::accounts_id, "/api/v1/accounts/<ID>"}, {v1::accounts_id_statuses, "/api/v1/accounts/<ID>/statuses"}, {v1::accounts_id_followers, "/api/v1/accounts/<ID>/followers"}, {v1::accounts_id_following, "/api/v1/accounts/<ID>/following"}, diff --git a/src/curl_wrapper.cpp b/src/curl_wrapper.cpp index d153f7e..1e1040b 100644 --- a/src/curl_wrapper.cpp +++ b/src/curl_wrapper.cpp @@ -19,6 +19,8 @@ #include "log.hpp" #include "version.hpp" +#include <algorithm> +#include <array> #include <atomic> #include <cstdint> #include <cstring> @@ -28,6 +30,8 @@ namespace mastodonpp using std::get; using std::holds_alternative; +using std::any_of; +using std::array; using std::atomic; using std::uint8_t; using std::uint16_t; @@ -72,6 +76,22 @@ answer_type CURLWrapper::make_request(const http_method &method, string uri, for (const auto ¶m : parameters) { + static constexpr array replace_in_uri + { + "id", "nickname", "nickname_or_id", + "hashtag", "permission_group" + }; + if (any_of(replace_in_uri.begin(), replace_in_uri.end(), + [¶m](const auto &s) { return s == param.first; })) + { + const auto pos{uri.find('<')}; + if (pos != string::npos) + { + uri.replace(pos, param.first.size() + 2, + get<string>(param.second)); + } + continue; + } static bool first{true}; if (first) { |