parent
cade0f8a4a
commit
0f471e860f
|
@ -2,7 +2,7 @@ pipeline:
|
||||||
download:
|
download:
|
||||||
image: plugins/download
|
image: plugins/download
|
||||||
pull: true
|
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
|
destination: mastodon-cpp.deb
|
||||||
# gcc5:
|
# gcc5:
|
||||||
# image: gcc:5
|
# image: gcc:5
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (expandurl-mastodon
|
project (expandurl-mastodon
|
||||||
VERSION 0.9.13
|
VERSION 0.9.14
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ or to [@tastytea@soc.ialis.me](https://soc.ialis.me/@tastytea).
|
||||||
* C++ compiler (tested: gcc 6/7/8)
|
* C++ compiler (tested: gcc 6/7/8)
|
||||||
* [cmake](https://cmake.org/) (tested: 3.9 / 3.11)
|
* [cmake](https://cmake.org/) (tested: 3.9 / 3.11)
|
||||||
* [curlpp](http://www.curlpp.org/) (tested: 0.8 / 0.7)
|
* [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)
|
* [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)
|
* [libxdg-basedir](http://repo.or.cz/w/libxdg-basedir.git) (tested: 1.2)
|
||||||
|
|
||||||
|
|
|
@ -90,9 +90,9 @@ public:
|
||||||
|
|
||||||
const std::vector<Easy::Notification> get_new_messages();
|
const std::vector<Easy::Notification> get_new_messages();
|
||||||
const std::vector<Easy::Notification> catchup();
|
const std::vector<Easy::Notification> 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 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;
|
const bool stillrunning() const;
|
||||||
|
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -57,7 +57,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (!configfile.read())
|
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();
|
init_replacements();
|
||||||
|
|
||||||
|
@ -89,11 +90,11 @@ int main(int argc, char *argv[])
|
||||||
for (Easy::Notification ¬if : new_messages)
|
for (Easy::Notification ¬if : new_messages)
|
||||||
{
|
{
|
||||||
syslog(LOG_DEBUG, "new message");
|
syslog(LOG_DEBUG, "new message");
|
||||||
const std::uint_fast64_t id = listener.get_parent_id(notif);
|
const string id = listener.get_parent_id(notif);
|
||||||
syslog(LOG_DEBUG, "in_reply_to_id: %lu", id);
|
syslog(LOG_DEBUG, "in_reply_to_id: %s", id.c_str());
|
||||||
Easy::Status status;
|
Easy::Status status;
|
||||||
|
|
||||||
if (id > 0)
|
if (!id.empty())
|
||||||
{
|
{
|
||||||
status = listener.get_status(id);
|
status = listener.get_status(id);
|
||||||
if (status.valid())
|
if (status.valid())
|
||||||
|
@ -107,7 +108,8 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (!listener.send_reply(notif.status(), message))
|
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
|
else
|
||||||
|
|
|
@ -209,12 +209,12 @@ const std::vector<Easy::Notification> Listener::catchup()
|
||||||
return v;
|
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;
|
std::uint_fast16_t ret;
|
||||||
string answer;
|
string answer;
|
||||||
|
|
||||||
ret = _masto->get(API::v1::statuses_id, {{ "id", { std::to_string(id) }}},
|
ret = _masto->get(API::v1::statuses_id, {{ "id", { id }}},
|
||||||
answer);
|
answer);
|
||||||
if (ret == 0)
|
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;
|
string answer;
|
||||||
std::uint_fast16_t ret;
|
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,
|
ret = _masto->get(API::v1::statuses_id,
|
||||||
{{ "id", { std::to_string(notif.status().id()) }}},
|
{{ "id", { notif.status().id() }}},
|
||||||
answer);
|
answer);
|
||||||
|
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
|
@ -290,11 +290,11 @@ const std::uint_fast64_t Listener::get_parent_id(const Easy::Notification ¬if
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_config["last_id"] = std::to_string(notif.id());
|
_config["last_id"] = notif.id();
|
||||||
const Easy::Status s(answer);
|
const Easy::Status s(answer);
|
||||||
|
|
||||||
// If parent is found, return ID; else retry
|
// 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();
|
return s.in_reply_to_id();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user