From 0f471e860f2ec2f500fb3e94714d2a6be039f26b Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 27 Jan 2019 04:51:03 +0100 Subject: [PATCH] Updated to mastodon-cpp 0.30.0 --- .drone.yml | 2 +- CMakeLists.txt | 2 +- README.md | 2 +- src/expandurl-mastodon.hpp | 4 ++-- src/main.cpp | 12 +++++++----- src/masto.cpp | 12 ++++++------ 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.drone.yml b/.drone.yml index a4eaea7..a851a28 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,7 +2,7 @@ pipeline: download: image: plugins/download pull: true - source: https://schlomp.space/attachments/761761c0-b16b-491e-a6ae-18dca23e82dd + source: https://schlomp.space/attachments/5ab8f994-669a-47f8-8ac7-ed5902ad0339 destination: mastodon-cpp.deb # gcc5: # image: gcc:5 diff --git a/CMakeLists.txt b/CMakeLists.txt index ca559c3..6fee29a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (expandurl-mastodon - VERSION 0.9.13 + VERSION 0.9.14 LANGUAGES CXX ) diff --git a/README.md b/README.md index 2f60995..85f69e4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ or to [@tastytea@soc.ialis.me](https://soc.ialis.me/@tastytea). * C++ compiler (tested: gcc 6/7/8) * [cmake](https://cmake.org/) (tested: 3.9 / 3.11) * [curlpp](http://www.curlpp.org/) (tested: 0.8 / 0.7) - * [mastodon-cpp](https://schlomp.space/tastytea/mastodon-cpp) (at least: 0.18) + * [mastodon-cpp](https://schlomp.space/tastytea/mastodon-cpp) (at least: 0.30) * [jsoncpp](https://github.com/open-source-parsers/jsoncpp) (tested: 1.8 / 1.7) * [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git) (tested: 1.2) diff --git a/src/expandurl-mastodon.hpp b/src/expandurl-mastodon.hpp index 56c72af..9c80573 100644 --- a/src/expandurl-mastodon.hpp +++ b/src/expandurl-mastodon.hpp @@ -90,9 +90,9 @@ public: const std::vector get_new_messages(); const std::vector catchup(); - Easy::Status get_status(const std::uint_fast64_t &id); + Easy::Status get_status(const string &id); const bool send_reply(const Easy::Status &to_status, const string &message); - const std::uint_fast64_t get_parent_id(const Easy::Notification ¬if); + const string get_parent_id(const Easy::Notification ¬if); const bool stillrunning() const; diff --git a/src/main.cpp b/src/main.cpp index 2e4bb62..84b3e0c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,8 @@ int main(int argc, char *argv[]) if (!configfile.read()) { - syslog(LOG_WARNING, "Could not open %s.", configfile.get_filepath().c_str()); + syslog(LOG_WARNING, "Could not open %s.", + configfile.get_filepath().c_str()); } init_replacements(); @@ -89,11 +90,11 @@ int main(int argc, char *argv[]) for (Easy::Notification ¬if : new_messages) { syslog(LOG_DEBUG, "new message"); - const std::uint_fast64_t id = listener.get_parent_id(notif); - syslog(LOG_DEBUG, "in_reply_to_id: %lu", id); + const string id = listener.get_parent_id(notif); + syslog(LOG_DEBUG, "in_reply_to_id: %s", id.c_str()); Easy::Status status; - if (id > 0) + if (!id.empty()) { status = listener.get_status(id); if (status.valid()) @@ -107,7 +108,8 @@ int main(int argc, char *argv[]) { if (!listener.send_reply(notif.status(), message)) { - syslog(LOG_ERR, "could not send reply to %lu", id); + syslog(LOG_ERR, "could not send reply to %s", + id.c_str()); } } else diff --git a/src/masto.cpp b/src/masto.cpp index 0e86023..e6e894e 100644 --- a/src/masto.cpp +++ b/src/masto.cpp @@ -209,12 +209,12 @@ const std::vector Listener::catchup() return v; } -Mastodon::Easy::Status Listener::get_status(const std::uint_fast64_t &id) +Mastodon::Easy::Status Listener::get_status(const string &id) { std::uint_fast16_t ret; string answer; - ret = _masto->get(API::v1::statuses_id, {{ "id", { std::to_string(id) }}}, + ret = _masto->get(API::v1::statuses_id, {{ "id", { id }}}, answer); if (ret == 0) { @@ -260,7 +260,7 @@ const bool Listener::send_reply(const Easy::Status &to_status, } } -const std::uint_fast64_t Listener::get_parent_id(const Easy::Notification ¬if) +const string Listener::get_parent_id(const Easy::Notification ¬if) { string answer; std::uint_fast16_t ret; @@ -279,7 +279,7 @@ const std::uint_fast64_t Listener::get_parent_id(const Easy::Notification ¬if } ret = _masto->get(API::v1::statuses_id, - {{ "id", { std::to_string(notif.status().id()) }}}, + {{ "id", { notif.status().id() }}}, answer); if (ret > 0) @@ -290,11 +290,11 @@ const std::uint_fast64_t Listener::get_parent_id(const Easy::Notification ¬if } else { - _config["last_id"] = std::to_string(notif.id()); + _config["last_id"] = notif.id(); const Easy::Status s(answer); // If parent is found, return ID; else retry - if (s.in_reply_to_id() != 0) + if (!s.in_reply_to_id().empty()) { return s.in_reply_to_id(); }