Added support vor bookmarks (Glitch-Soc)
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
64f4e378ef
commit
8a0f709a6e
|
@ -262,9 +262,9 @@ Feature complete as of Mastodon 2.6.1
|
||||||
|
|
||||||
* [x] max_toot_chars in /api/v1/instance
|
* [x] max_toot_chars in /api/v1/instance
|
||||||
|
|
||||||
* [ ] GET /api/v1/bookmarks
|
* [x] GET /api/v1/bookmarks
|
||||||
* [ ] POST /api/v1/statuses/:id/bookmark
|
* [x] POST /api/v1/statuses/:id/bookmark
|
||||||
* [ ] POST /api/v1/statuses/:id/underbookmark
|
* [x] POST /api/v1/statuses/:id/unbookmark
|
||||||
|
|
||||||
# Copyright
|
# Copyright
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Print the first 20 characters from every bookmark (Glitch-Soc only).
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Don't compile this if the Easy-interface is turned off
|
||||||
|
#ifndef WITHOUT_EASY
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
#ifdef MASTODON_CPP
|
||||||
|
#include "mastodon-cpp.hpp"
|
||||||
|
#include "easy/all.hpp"
|
||||||
|
#else
|
||||||
|
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||||
|
#include <mastodon-cpp/easy/all.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using Mastodon::API;
|
||||||
|
using Mastodon::Easy;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
std::cerr << "usage: " << argv[0] << " <instance> <access token>\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Easy masto(argv[1], argv[2]);
|
||||||
|
std::string answer;
|
||||||
|
std::uint16_t ret;
|
||||||
|
ret = masto.get(API::v1::bookmarks, answer);
|
||||||
|
|
||||||
|
cout << "Return code: " << ret << '\n';
|
||||||
|
|
||||||
|
std::vector<string> statuses = Easy::json_array_to_vector(answer);
|
||||||
|
for (const string &json : statuses)
|
||||||
|
{
|
||||||
|
cout << Easy::Status(json).content().substr(0, 20) << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <cstdio>
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
printf("mastodon-cpp was compiled without Easy support.\n");
|
||||||
|
return 255;
|
||||||
|
}
|
||||||
|
#endif // WITHOUT_EASY
|
|
@ -147,6 +147,9 @@ const uint_fast16_t API::get(const Mastodon::API::v1 &call,
|
||||||
case v1::endorsements:
|
case v1::endorsements:
|
||||||
strcall = "/api/v1/endorsements";
|
strcall = "/api/v1/endorsements";
|
||||||
break;
|
break;
|
||||||
|
case v1::bookmarks:
|
||||||
|
strcall = "/api/v1/bookmarks";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ttdebug << "ERROR: Invalid call.\n";
|
ttdebug << "ERROR: Invalid call.\n";
|
||||||
return 11;
|
return 11;
|
||||||
|
|
|
@ -122,6 +122,12 @@ const uint_fast16_t API::post(const Mastodon::API::v1 &call,
|
||||||
case v1::accounts_id_unpin:
|
case v1::accounts_id_unpin:
|
||||||
strcall = "/api/v1/accounts/" + strid + "/unpin";
|
strcall = "/api/v1/accounts/" + strid + "/unpin";
|
||||||
break;
|
break;
|
||||||
|
case v1::statuses_id_bookmark:
|
||||||
|
strcall = "/api/v1/statuses/" + strid + "/bookmark";
|
||||||
|
break;
|
||||||
|
case v1::statuses_id_unbookmark:
|
||||||
|
strcall = "/api/v1/statuses/" + strid + "/unbookmark";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ttdebug << "ERROR: Invalid call.\n";
|
ttdebug << "ERROR: Invalid call.\n";
|
||||||
return 11;
|
return 11;
|
||||||
|
|
|
@ -265,7 +265,11 @@ public:
|
||||||
streaming_hashtag,
|
streaming_hashtag,
|
||||||
streaming_list,
|
streaming_list,
|
||||||
// Push
|
// Push
|
||||||
push_subscription
|
push_subscription,
|
||||||
|
// Glitch-Soc
|
||||||
|
bookmarks,
|
||||||
|
statuses_id_bookmark,
|
||||||
|
statuses_id_unbookmark
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Reference in New Issue