Merge branch 'develop' into main
This commit is contained in:
commit
f983acb910
|
@ -31,7 +31,7 @@ using std::variant;
|
|||
/*!
|
||||
* @brief Holds %API endpoints.
|
||||
*
|
||||
* Supported %API endpoints: Mastodon 3.0.1, Pleroma 1.1.7.
|
||||
* Supported %API endpoints: Mastodon 3.0.1, Pleroma 2.0.0.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
/*!
|
||||
* @brief An enumeration of all v1 %API endpoints.
|
||||
*
|
||||
* The original `/` are substituted with `_`.
|
||||
* The original `/` are substituted with `_`. `:` are omitted.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
@ -184,7 +184,6 @@ public:
|
|||
admin_reports_id_reopen,
|
||||
|
||||
pleroma_notifications_read,
|
||||
|
||||
pleroma_accounts_id_subscribe,
|
||||
pleroma_accounts_id_unsubscribe,
|
||||
pleroma_accounts_id_favourites,
|
||||
|
@ -192,17 +191,20 @@ public:
|
|||
pleroma_accounts_update_banner,
|
||||
pleroma_accounts_update_background,
|
||||
pleroma_accounts_confirmation_resend,
|
||||
|
||||
pleroma_mascot,
|
||||
|
||||
pleroma_conversations_id_statuses,
|
||||
pleroma_conversations_id,
|
||||
pleroma_conversations_id_read,
|
||||
pleroma_accounts_id_scrobbles,
|
||||
pleroma_scrobble,
|
||||
pleroma_statuses_id_reactions_emoji,
|
||||
pleroma_statuses_id_reactions,
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief An enumeration of all v2 %API endpoints.
|
||||
*
|
||||
* The original `/` are substituted with `_`.
|
||||
* The original `/` are substituted with `_`. `:` are omitted.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
@ -214,7 +216,7 @@ public:
|
|||
/*!
|
||||
* @brief An enumeration of all oauth %API endpoints.
|
||||
*
|
||||
* The original `/` are substituted with `_`.
|
||||
* The original `/` are substituted with `_`. `:` are omitted.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
@ -230,7 +232,7 @@ public:
|
|||
*
|
||||
* These endpoints are directly under `/api/`.
|
||||
*
|
||||
* The original `/` are substituted with `_`.
|
||||
* The original `/` are substituted with `_`. `:` are omitted.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
@ -243,7 +245,7 @@ public:
|
|||
/*!
|
||||
* @brief An enumeration of all pleroma %API endpoints.
|
||||
*
|
||||
* The original `/` are substituted with `_`.
|
||||
* The original `/` are substituted with `_`. `:` are omitted.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
|
@ -252,38 +254,65 @@ public:
|
|||
admin_users,
|
||||
admin_users_follow,
|
||||
admin_users_unfollow,
|
||||
admin_users_nickname,
|
||||
admin_users_nickname_toggle_activation,
|
||||
admin_users_tag,
|
||||
admin_users_nickname_permission_group,
|
||||
admin_users_nickname_permission_group_permission_group,
|
||||
admin_users_nickname_activation_status,
|
||||
admin_users_permission_group_permission_group,
|
||||
admin_users_activate,
|
||||
admin_users_deactivate,
|
||||
admin_users_nickname_or_id,
|
||||
admin_users_nickname_or_id_statuses,
|
||||
admin_instances_instance_statuses,
|
||||
admin_statuses,
|
||||
admin_relay,
|
||||
admin_users_invite_token,
|
||||
admin_users_invites,
|
||||
admin_users_revoke_invite,
|
||||
admin_users_email_invite,
|
||||
admin_users_nickname_password_reset,
|
||||
admin_users_force_password_reset,
|
||||
admin_reports,
|
||||
admin_grouped_reports,
|
||||
admin_reports_id,
|
||||
admin_reports_id_respond,
|
||||
admin_reports_id_notes,
|
||||
admin_reports_report_id_notes_id,
|
||||
admin_statuses_id,
|
||||
admin_restart,
|
||||
admin_config,
|
||||
admin_config_descriptions,
|
||||
admin_moderation_log,
|
||||
admin_reload_emoji,
|
||||
admin_users_confirm_email,
|
||||
admin_users_resend_confirm_email,
|
||||
admin_stats,
|
||||
|
||||
// No longer documented for Pleroma 2.0.0.
|
||||
admin_users_nickname,
|
||||
admin_users_nickname_activation_status,
|
||||
admin_reports_id_respond,
|
||||
admin_config_migrate_to_db,
|
||||
admin_config_migrate_from_db,
|
||||
admin_config,
|
||||
|
||||
emoji,
|
||||
follow_import,
|
||||
captcha,
|
||||
|
||||
delete_account,
|
||||
disable_account,
|
||||
account_register,
|
||||
|
||||
notification_settings,
|
||||
healthcheck,
|
||||
change_email
|
||||
change_email,
|
||||
emoji_packs,
|
||||
emoji_packs_name,
|
||||
emoji_packs_name_update_file,
|
||||
emoji_packs_name_update_metadata,
|
||||
emoji_packs_download_from,
|
||||
emoji_packs_list_from,
|
||||
emoji_packs_name_download_shared,
|
||||
|
||||
// No longer documented for Pleroma 2.0.0.
|
||||
account_register,
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
110
src/api.cpp
110
src/api.cpp
|
@ -150,7 +150,7 @@ const map<API::endpoint_type,string_view> API::_endpoint_map
|
|||
{v1::admin_accounts, "/api/v1/admin/accounts"},
|
||||
{v1::admin_accounts_id, "/api/v1/admin/accounts/<ID>"},
|
||||
{v1::admin_accounts_account_id_action,
|
||||
"/api/v1/admin/accounts/<ACCOUNT_ID>/action"},
|
||||
"/api/v1/admin/accounts/<ACCOUNT_ID>/action"},
|
||||
{v1::admin_accounts_id_approve, "/api/v1/admin/accounts/<ID>/approve"},
|
||||
{v1::admin_accounts_id_reject, "/api/v1/admin/accounts/<ID>/reject"},
|
||||
{v1::admin_accounts_id_enable, "/api/v1/admin/accounts/<ID>/enable"},
|
||||
|
@ -159,33 +159,39 @@ const map<API::endpoint_type,string_view> API::_endpoint_map
|
|||
{v1::admin_reports, "/api/v1/admin/reports"},
|
||||
{v1::admin_reports_id, "/api/v1/admin/reports/<ID>"},
|
||||
{v1::admin_reports_id_assign_to_self,
|
||||
"/api/v1/admin/reports/<ID>/assign_to_self"},
|
||||
"/api/v1/admin/reports/<ID>/assign_to_self"},
|
||||
{v1::admin_reports_id_unassign, "/api/v1/admin/reports/<ID>/unassign"},
|
||||
{v1::admin_reports_id_resolve, "/api/v1/admin/reports/<ID>/resolve"},
|
||||
{v1::admin_reports_id_reopen, "/api/v1/admin/reports/<ID>/reopen"},
|
||||
|
||||
{v1::pleroma_notifications_read, " /api/v1/pleroma/notifications/read"},
|
||||
|
||||
{v1::pleroma_accounts_id_subscribe,
|
||||
"/api/v1/pleroma/accounts/<ID>/subscribe"},
|
||||
"/api/v1/pleroma/accounts/<ID>/subscribe"},
|
||||
{v1::pleroma_accounts_id_unsubscribe,
|
||||
"/api/v1/pleroma/accounts/<ID>/unsubscribe"},
|
||||
"/api/v1/pleroma/accounts/<ID>/unsubscribe"},
|
||||
{v1::pleroma_accounts_id_favourites,
|
||||
"/api/v1/pleroma/accounts/<ID>/favourites"},
|
||||
"/api/v1/pleroma/accounts/<ID>/favourites"},
|
||||
{v1::pleroma_accounts_update_avatar,
|
||||
"/api/v1/pleroma/accounts/update_avatar"},
|
||||
"/api/v1/pleroma/accounts/update_avatar"},
|
||||
{v1::pleroma_accounts_update_banner,
|
||||
"/api/v1/pleroma/accounts/update_banner"},
|
||||
"/api/v1/pleroma/accounts/update_banner"},
|
||||
{v1::pleroma_accounts_update_background,
|
||||
"/api/v1/pleroma/accounts/update_background"},
|
||||
"/api/v1/pleroma/accounts/update_background"},
|
||||
{v1::pleroma_accounts_confirmation_resend,
|
||||
"/api/v1/pleroma/accounts/confirmation_resend"},
|
||||
|
||||
"/api/v1/pleroma/accounts/confirmation_resend"},
|
||||
{v1::pleroma_mascot, "/api/v1/pleroma/mascot"},
|
||||
|
||||
{v1::pleroma_conversations_id_statuses,
|
||||
"/api/v1/pleroma/conversations/<ID>/statuses"},
|
||||
"/api/v1/pleroma/conversations/<ID>/statuses"},
|
||||
{v1::pleroma_conversations_id, "/api/v1/pleroma/conversations/<ID>"},
|
||||
{v1::pleroma_conversations_id_read,
|
||||
"/api/v1/pleroma/conversations/<ID>/read"},
|
||||
{v1::pleroma_accounts_id_scrobbles,
|
||||
"/api/v1/pleroma/accounts/<ID>/scrobbles"},
|
||||
{v1::pleroma_scrobble, "/api/v1/pleroma/scrobble"},
|
||||
{v1::pleroma_statuses_id_reactions_emoji,
|
||||
"/api/v1/pleroma/statuses/<ID>/reactions/<EMOJI>"},
|
||||
{v1::pleroma_statuses_id_reactions,
|
||||
"/api/v1/pleroma/statuses/<ID>/reactions"},
|
||||
|
||||
{v2::search, "/api/v2/search"},
|
||||
|
||||
|
@ -199,49 +205,89 @@ const map<API::endpoint_type,string_view> API::_endpoint_map
|
|||
{pleroma::admin_users, "/api/pleroma/admin/users"},
|
||||
{pleroma::admin_users_follow, "/api/pleroma/admin/users/follow"},
|
||||
{pleroma::admin_users_unfollow, "/api/pleroma/admin/users/unfollow"},
|
||||
{pleroma::admin_users_nickname, "/api/pleroma/admin/users/<NICKNAME>"},
|
||||
{pleroma::admin_users_nickname_toggle_activation,
|
||||
"/api/pleroma/admin/users/<NICKNAME>/toggle_activation"},
|
||||
{pleroma::admin_users_tag, "/api/pleroma/admin/users/tag"},
|
||||
{pleroma::admin_users_nickname_permission_group,
|
||||
"/api/pleroma/admin/users/<NICKNAME>/permission_group"},
|
||||
"/api/pleroma/admin/users/<NICKNAME>/permission_group"},
|
||||
{pleroma::admin_users_nickname_permission_group_permission_group,
|
||||
"/api/pleroma/admin/users/<NICKNAME>/permission_group/<PERMISSION_GROUP>"},
|
||||
{pleroma::admin_users_nickname_activation_status,
|
||||
"/api/pleroma/admin/users/<NICKNAME>/activation_status"},
|
||||
"/api/pleroma/admin/users/<NICKNAME>"
|
||||
"/permission_group/<PERMISSION_GROUP>"},
|
||||
{pleroma::admin_users_permission_group_permission_group,
|
||||
"/api/pleroma/admin/users/permission_group/<PERMISSION_GROUP>"},
|
||||
{pleroma::admin_users_activate, "/api/pleroma/admin/users/activate"},
|
||||
{pleroma::admin_users_deactivate, "/api/pleroma/admin/users/deactivate"},
|
||||
{pleroma::admin_users_nickname_or_id,
|
||||
"/api/pleroma/admin/users/<NICKNAME_OR_ID>"},
|
||||
"/api/pleroma/admin/users/<NICKNAME_OR_ID>"},
|
||||
{pleroma::admin_users_nickname_or_id_statuses,
|
||||
"/api/pleroma/admin/users/<NICKNAME_OR_ID>/statuses"},
|
||||
"/api/pleroma/admin/users/<NICKNAME_OR_ID>/statuses"},
|
||||
{pleroma::admin_instances_instance_statuses,
|
||||
"/api/pleroma/admin/instances/<INSTANCE>/statuses"},
|
||||
{pleroma::admin_statuses, "/api/pleroma/admin/statuses"},
|
||||
{pleroma::admin_relay, "/api/pleroma/admin/relay"},
|
||||
{pleroma::admin_users_invite_token,
|
||||
"/api/pleroma/admin/users/invite_token"},
|
||||
"/api/pleroma/admin/users/invite_token"},
|
||||
{pleroma::admin_users_invites, "/api/pleroma/admin/users/invites"},
|
||||
{pleroma::admin_users_revoke_invite,
|
||||
"/api/pleroma/admin/users/revoke_invite"},
|
||||
"/api/pleroma/admin/users/revoke_invite"},
|
||||
{pleroma::admin_users_email_invite,
|
||||
"/api/pleroma/admin/users/email_invite"},
|
||||
"/api/pleroma/admin/users/email_invite"},
|
||||
{pleroma::admin_users_nickname_password_reset,
|
||||
"/api/pleroma/admin/users/<NICKNAME>/password_reset"},
|
||||
"/api/pleroma/admin/users/<NICKNAME>/password_reset"},
|
||||
{pleroma::admin_users_force_password_reset,
|
||||
"/api/pleroma/admin/users/force_password_reset"},
|
||||
{pleroma::admin_reports, "/api/pleroma/admin/reports"},
|
||||
{pleroma::admin_grouped_reports, "/api/pleroma/admin/grouped_reports"},
|
||||
{pleroma::admin_reports_id, "/api/pleroma/admin/reports/<ID>"},
|
||||
{pleroma::admin_reports_id_respond,
|
||||
"/api/pleroma/admin/reports/<ID>/respond"},
|
||||
{pleroma::admin_reports_id_notes, "/api/pleroma/admin/reports/<ID>/notes"},
|
||||
{pleroma::admin_reports_report_id_notes_id,
|
||||
"/api/pleroma/admin/reports/<REPORT_ID>/notes/<ID>"},
|
||||
{pleroma::admin_statuses_id, "/api/pleroma/admin/statuses/<ID>"},
|
||||
{pleroma::admin_config_migrate_to_db,
|
||||
"/api/pleroma/admin/config/migrate_to_db"},
|
||||
{pleroma::admin_config_migrate_from_db,
|
||||
"/api/pleroma/admin/config/migrate_from_db"},
|
||||
{pleroma::admin_restart, "/api/pleroma/admin/restart"},
|
||||
{pleroma::admin_config, "/api/pleroma/admin/config"},
|
||||
{pleroma::admin_config_descriptions,
|
||||
"/api/pleroma/admin/config/descriptions"},
|
||||
{pleroma::admin_moderation_log, "/api/pleroma/admin/moderation_log"},
|
||||
{pleroma::admin_reload_emoji, "/api/pleroma/admin/reload_emoji"},
|
||||
{pleroma::admin_users_confirm_email,
|
||||
"/api/pleroma/admin/users/confirm_email"},
|
||||
{pleroma::admin_users_resend_confirm_email,
|
||||
"/api/pleroma/admin/users/resend_confirm_email"},
|
||||
{pleroma::admin_stats, "/api/pleroma/admin/stats"},
|
||||
|
||||
{pleroma::admin_users_nickname, "/api/pleroma/admin/users/<NICKNAME>"},
|
||||
{pleroma::admin_users_nickname_activation_status,
|
||||
"/api/pleroma/admin/users/<NICKNAME>/activation_status"},
|
||||
{pleroma::admin_reports_id_respond,
|
||||
"/api/pleroma/admin/reports/<ID>/respond"},
|
||||
{pleroma::admin_config_migrate_to_db,
|
||||
"/api/pleroma/admin/config/migrate_to_db"},
|
||||
{pleroma::admin_config_migrate_from_db,
|
||||
"/api/pleroma/admin/config/migrate_from_db"},
|
||||
|
||||
{pleroma::emoji, "/api/pleroma/emoji"},
|
||||
{pleroma::follow_import, "/api/pleroma/follow_import"},
|
||||
{pleroma::captcha, "/api/pleroma/captcha,"},
|
||||
{pleroma::delete_account, "/api/pleroma/delete_account"},
|
||||
{pleroma::disable_account, "/api/pleroma/disable_account"},
|
||||
{pleroma::account_register, "/api/pleroma/account/register"},
|
||||
|
||||
{pleroma::notification_settings, "/api/pleroma/notification_settings"},
|
||||
{pleroma::healthcheck, "/api/pleroma/healthcheck"},
|
||||
{pleroma::change_email, "/api/pleroma/change_email"},
|
||||
{pleroma::emoji_packs, "/api/pleroma/emoji/packs"},
|
||||
{pleroma::emoji_packs_name, "/api/pleroma/emoji/packs/<NAME>"},
|
||||
{pleroma::emoji_packs_name_update_file,
|
||||
"/api/pleroma/emoji/packs/<NAME>/update_file"},
|
||||
{pleroma::emoji_packs_name_update_metadata,
|
||||
"/api/pleroma/emoji/packs/<NAME>/update_metadata"},
|
||||
{pleroma::emoji_packs_download_from,
|
||||
"/api/pleroma/emoji/packs/download_from"},
|
||||
{pleroma::emoji_packs_list_from,
|
||||
"/api/pleroma/emoji/packs/list_from"},
|
||||
{pleroma::emoji_packs_name_download_shared,
|
||||
"/api/pleroma/emoji/packs/<NAME>/download_shared"},
|
||||
|
||||
{pleroma::account_register, "/api/pleroma/account/register"},
|
||||
|
||||
};
|
||||
|
||||
} // namespace mastodonpp
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
|
||||
namespace mastodonpp
|
||||
|
@ -30,8 +31,10 @@ namespace mastodonpp
|
|||
using std::get;
|
||||
using std::holds_alternative;
|
||||
using std::any_of;
|
||||
using std::transform;
|
||||
using std::array; // NOLINT(misc-unused-using-decls)
|
||||
using std::atomic;
|
||||
using std::toupper;
|
||||
using std::uint8_t;
|
||||
using std::uint16_t;
|
||||
|
||||
|
@ -355,13 +358,22 @@ bool CURLWrapper::replace_parameter_in_uri(string &uri,
|
|||
{
|
||||
static constexpr array replace
|
||||
{
|
||||
"id", "nickname", "nickname_or_id", "account_id",
|
||||
"list_id", "hashtag", "permission_group"
|
||||
"id", "nickname", "nickname_or_id", "account_id", "list_id",
|
||||
"hashtag", "permission_group", "instance", "report_id", "name",
|
||||
"emoji"
|
||||
};
|
||||
if (any_of(replace.begin(), replace.end(),
|
||||
[¶meter](const auto &s) { return s == parameter.first; }))
|
||||
{
|
||||
const auto pos{uri.find('<')};
|
||||
const string searchstring{[¶meter]
|
||||
{
|
||||
string s{"<"};
|
||||
s += parameter.first;
|
||||
transform(s.begin(), s.end(), s.begin(),
|
||||
[](const unsigned char c){ return toupper(c); });
|
||||
return s;
|
||||
}()};
|
||||
const auto pos{uri.find(searchstring)};
|
||||
if (pos != string::npos)
|
||||
{
|
||||
uri.replace(pos, parameter.first.size() + 2,
|
||||
|
|
Loading…
Reference in New Issue
Block a user