Rewrote send_reply(), upped mastodon-cpp dependency to version 0.17.0

master
tastytea 4 years ago
parent 0b218fd472
commit c4b4522dc7
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
  1. 2
      .drone.yml
  2. 2
      CMakeLists.txt
  3. 2
      README.md
  4. 41
      src/masto.cpp

@ -1,7 +1,7 @@
pipeline:
download:
image: plugins/download
source: https://schlomp.space/attachments/b3119713-4c05-4acc-9cb4-460b15e19279
source: https://schlomp.space/attachments/dbc2b2b0-86c9-4aee-ac99-9cb9e91a82ed
destination: mastodon-cpp.deb
build:
image: debian:buster-slim

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon
VERSION 0.9.8
VERSION 0.9.9
LANGUAGES CXX
)

@ -25,7 +25,7 @@ or to [@tastytea@soc.ialis.me](https://soc.ialis.me/@tastytea).
* C++ compiler (tested: gcc 6.4 / 7.3)
* [cmake](https://cmake.org/) (tested: 3.9)
* [curlpp](http://www.curlpp.org/) (tested: 0.8 / 0.7)
* [mastodon-cpp](https://schlomp.space/tastytea/mastodon-cpp) (at least: 0.15.1)
* [mastodon-cpp](https://schlomp.space/tastytea/mastodon-cpp) (at least: 0.17)
* [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)

@ -230,42 +230,23 @@ Mastodon::Easy::Status Listener::get_status(const std::uint_fast64_t &id)
const bool Listener::send_reply(const Easy::Status &to_status,
const string &message)
{
std::uint_fast16_t ret;
string answer;
const string id = std::to_string(to_status.id());
string strvisibility;
std::uint_fast16_t ret = 0;
switch (to_status.visibility())
Easy::Status new_status;
if (to_status.visibility() == Easy::visibility_type::Public)
{
case Easy::visibility_type::Private:
strvisibility = "private";
break;
case Easy::visibility_type::Direct:
strvisibility = "direct";
break;
default:
strvisibility = "unlisted";
break;
new_status.visibility(Easy::visibility_type::Unlisted);
}
Easy::parametermap parameters =
{
{ "in_reply_to_id", { id } },
{ "visibility", { strvisibility } },
{ "status", { '@' + to_status.account().acct() + ' ' + message } }
};
if (to_status.sensitive())
{
parameters.insert({ "sensitive", { "true" } });
}
if (!to_status.spoiler_text().empty())
else
{
parameters.insert({ "spoiler_text", { to_status.spoiler_text() } });
new_status.visibility(to_status.visibility());
}
new_status.in_reply_to_id(to_status.id());
new_status.content('@' + to_status.account().acct() + ' ' + message);
new_status.sensitive(to_status.sensitive());
new_status.spoiler_text(to_status.spoiler_text());
ret = _masto->post(API::v1::statuses, parameters, answer);
_masto->send_toot(new_status, ret);
if (ret == 0)
{

Loading…
Cancel
Save