From a0435e37d3246ff021fdee5c2b691699dc858332 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 22 May 2018 23:49:31 +0200 Subject: [PATCH] Added support for push subscriptions --- CMakeLists.txt | 2 +- README.md | 4 ++++ src/api/delete.cpp | 3 +++ src/api/get.cpp | 3 +++ src/api/post.cpp | 3 +++ src/api/put.cpp | 3 +++ src/mastodon-cpp.hpp | 9 ++++++--- 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98bf921..98b6548 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastodon-cpp - VERSION 0.13.1 + VERSION 0.13.2 LANGUAGES CXX ) diff --git a/README.md b/README.md index 363900b..c375c85 100644 --- a/README.md +++ b/README.md @@ -270,6 +270,10 @@ Feature complete as of Mastodon 2.4.0 * [x] GET /api/v1/streaming/public/local * [x] GET /api/v1/streaming/hashtag * [x] GET /api/v1/streaming/list + * [x] POST /api/v1/push/subscription + * [x] GET /api/v1/push/subscription + * [x] PUT /api/v1/push/subscription + * [x] DELETE /api/v1/push/subscription # Copyright diff --git a/src/api/delete.cpp b/src/api/delete.cpp index d402973..4752dd8 100644 --- a/src/api/delete.cpp +++ b/src/api/delete.cpp @@ -47,6 +47,9 @@ const uint_fast16_t API::del(const Mastodon::API::v1 &call, case v1::statuses_id: strcall = "/api/v1/statuses/" + strid; break; + case v1::push_subscription: + strcall = "/api/v1/push/subscription"; + break; default: ttdebug << "ERROR: Invalid call.\n"; return 11; diff --git a/src/api/get.cpp b/src/api/get.cpp index 81e1f4d..a569ec2 100644 --- a/src/api/get.cpp +++ b/src/api/get.cpp @@ -141,6 +141,9 @@ const uint_fast16_t API::get(const Mastodon::API::v1 &call, case v1::timelines_list_list_id: strcall = "/api/v1/timelines/list/" + strid; break; + case v1::push_subscription: + strcall = "/api/v1/push/subscription"; + break; default: ttdebug << "ERROR: Invalid call.\n"; return 11; diff --git a/src/api/post.cpp b/src/api/post.cpp index d44b9bd..9856eaf 100644 --- a/src/api/post.cpp +++ b/src/api/post.cpp @@ -113,6 +113,9 @@ const uint_fast16_t API::post(const Mastodon::API::v1 &call, case v1::statuses_id_unmute: strcall = "/api/v1/statuses/" + strid + "/unmute"; break; + case v1::push_subscription: + strcall = "/api/v1/push/subscription"; + break; default: ttdebug << "ERROR: Invalid call.\n"; return 11; diff --git a/src/api/put.cpp b/src/api/put.cpp index 6f3321d..cfdece0 100644 --- a/src/api/put.cpp +++ b/src/api/put.cpp @@ -41,6 +41,9 @@ const uint_fast16_t API::put(const Mastodon::API::v1 &call, case v1::media_id: strcall = "/api/v1/media/" + strid; break; + case v1::push_subscription: + strcall = "/api/v1/push/subscription"; + break; default: ttdebug << "ERROR: Invalid call.\n"; return 11; diff --git a/src/mastodon-cpp.hpp b/src/mastodon-cpp.hpp index 0a73f45..fd7ce60 100644 --- a/src/mastodon-cpp.hpp +++ b/src/mastodon-cpp.hpp @@ -246,7 +246,9 @@ public: streaming_public, streaming_public_local, streaming_hashtag, - streaming_list + streaming_list, + // Push + push_subscription }; /*! @@ -303,14 +305,15 @@ public: * * @param client_name The name of the application * @param redirect_uri urn:ietf:wg:oauth:2.0:oob for none - * @param scopes Scopes (read, write, follow, space separated) + * @param scopes Scopes (`read`, `write`, `follow`, `push`; space + * separated) * @param website The website of the application * @param client_id Returned * @param client_secret Returned * @param url Returned, used to generate code for register_app2 * * @return @ref error "Error code". If the URL has permanently changed, 13 - * is returned and url is set to the new URL. + * is returned and url is set to the new URL. */ const uint_fast16_t register_app1(const string &client_name, const string &redirect_uri,