Compare commits

...

38 Commits

Author SHA1 Message Date
tastytea 4b7215036b
Recommend switching to mastodonpp.
continuous-integration/drone/push Build is passing Details
2020-01-16 23:47:25 +01:00
tastytea e65fadfba6
Add low-maintenance note.
continuous-integration/drone/push Build is passing Details
2020-01-03 06:20:38 +01:00
tastytea fd407094a2
Add package for Ubuntu bionic. 2019-12-26 03:19:32 +01:00
tastytea 76e12d7093
Drone: Install lsb-release.
continuous-integration/drone/push Build is passing Details
2019-12-25 21:16:47 +01:00
tastytea 2a9219ce7e
Drone: Don't fail if file to delete doesn't exist. 2019-12-25 21:06:57 +01:00
tastytea cacc2c3a5b
Build packages for Debian stretch and buster. 2019-12-25 20:53:14 +01:00
tastytea ceda771700
Version bump 0.111.3.
continuous-integration/drone/push Build is passing Details
2019-12-19 15:16:24 +01:00
tastytea c6ad04e6ee
Typo in CMake config.
continuous-integration/drone/push Build was killed Details
2019-12-19 15:15:21 +01:00
tastytea 9671407556
Different indentation for CMake files. 2019-12-19 15:14:59 +01:00
tastytea c35dab8350
Merge branch 'develop'
continuous-integration/drone/push Build is passing Details
2019-10-14 12:06:43 +02:00
tastytea c772d7b60e
Improved introduction.
continuous-integration/drone/push Build is passing Details
2019-10-14 00:01:13 +02:00
tastytea e1b61b5041
Deprecated return_entity(_vector) and some high-level abstractions.
send_post(), send_toot() and get_notifications().
I don't have the energy to implement and maintain an useful set of high-level
abstractions.
2019-10-13 23:56:39 +02:00
tastytea db95855ab6
Merge branch 'develop'
continuous-integration/drone/push Build is passing Details
2019-10-13 21:05:34 +02:00
tastytea 5dce94a4a3
Add Emoji example.
continuous-integration/drone/push Build is passing Details
2019-10-13 17:39:49 +02:00
tastytea 7adad67dd9
Install examples into the correct directory. 2019-10-13 16:34:42 +02:00
tastytea 5275ab73ac
Version bump 0.111.2.
continuous-integration/drone/push Build is passing Details
2019-10-07 23:07:32 +02:00
tastytea a50d28e9a2
Merge branch 'develop' 2019-10-07 23:07:16 +02:00
tastytea 57238020a3
Do not return lowercased header, but the original one. 2019-10-07 23:06:15 +02:00
tastytea d37e720a11
Version bump 0.111.1.
continuous-integration/drone/push Build is passing Details
2019-10-06 17:20:44 +02:00
tastytea ad0773d5a7
Install documentation into ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}/. 2019-10-06 17:20:07 +02:00
tastytea bfe77f1b18
Don't install HTML documentation with autogenerated packages. 2019-10-06 17:19:07 +02:00
tastytea 10947148a1
Don't support versions pre 0.100.0.
continuous-integration/drone/push Build is passing Details
2019-10-06 16:43:13 +02:00
tastytea ec49399d39
Version bump 0.111.0 2019-10-06 16:40:22 +02:00
tastytea b4d6e37c96
Merge branch 'develop' 2019-10-06 16:39:38 +02:00
tastytea 719f8a7664
Actually delete parameters in delete_params(). 2019-10-06 16:39:06 +02:00
tastytea c3a5df62e5
Add Link::min_id() and allow for alphanumeric IDs. 2019-10-06 16:39:06 +02:00
tastytea 8b197134ab
Added favourites-example. 2019-10-06 16:39:06 +02:00
tastytea d43b1c72db
Match headers case-insensitively. 2019-10-06 14:58:04 +02:00
tastytea 2fa3bff89c
Re-add support for getting headers. 2019-10-06 14:35:06 +02:00
tastytea fe526f8e94
Merge branch 'develop'
continuous-integration/drone/push Build is passing Details
2019-09-27 03:54:53 +02:00
tastytea 28919cdaa8
Include contribution guidelines in readme.
continuous-integration/drone/push Build is failing Details
2019-09-27 03:52:58 +02:00
tastytea ff846a63cb
Make more use of variables in contribution guidelines. 2019-09-27 03:52:38 +02:00
tastytea 7857b17b8b
Fix contact-variable in COC. 2019-09-27 03:52:22 +02:00
tastytea f65cc6bac6
Add “patch via email”-paragraph to contributing guidelines.
continuous-integration/drone/push Build is passing Details
2019-09-23 19:27:26 +02:00
tastytea 453d8fc272
Fix path to CONTRIBUTING.adoc.
continuous-integration/drone/push Build is passing Details
2019-09-22 03:48:06 +02:00
tastytea a99fdc0742
Merge branch 'develop'
continuous-integration/drone/push Build was killed Details
2019-09-22 03:45:55 +02:00
tastytea 22754226f2
Replaced “mastodon-cpp” with variable “{project}” in readme.
continuous-integration/drone/push Build was killed Details
2019-09-22 03:45:18 +02:00
tastytea 66d41fec46
Add contributing guidelines, a COC and EditorConfig. 2019-09-22 03:38:14 +02:00
19 changed files with 371 additions and 76 deletions

View File

@ -25,8 +25,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- apt-get install -qy build-essential cmake
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen catch
@ -48,8 +48,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" >> /etc/apt/sources.list.d/ubuntu-toolchain-r.list
@ -77,8 +77,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
@ -104,8 +104,8 @@ steps:
MASTODON_CPP_ACCESS_TOKEN:
from_secret: mastodon_cpp_access_token
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- apt-get update -q
- apt-get install -qy build-essential cmake clang
@ -153,34 +153,73 @@ trigger:
- tag
steps:
- name: deb
- name: Debian stretch
image: debian:stretch-slim
pull: always
environment:
CXXFLAGS: -pipe -O2
LANG: C.utf8
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- apt-get install -qy build-essential cmake
- apt-get install -qy libpoco-dev libjsoncpp-dev doxygen file
- apt-get install -qy build-essential cmake lsb-release
- apt-get install -qy libpoco-dev libjsoncpp-dev file
- rm -rf build && mkdir -p build && cd build
- cmake -DWITH_EXAMPLES=NO -DWITH_TESTS=NO ..
- cmake -DWITH_DEB=YES -DWITH_DOC=NO ..
- make package
- cmake -DWITH_DEB=YES ..
- make package
- cp -v mastodon-cpp-${DRONE_TAG}_x86_64.tar.gz ..
- cp -v libmastodon-cpp_${DRONE_TAG}-0_amd64.deb ..
- cp -v libmastodon-cpp_${DRONE_TAG}-0_stretch_amd64.deb ..
volumes:
- name: debian-package-cache
path: /var/cache/apt/archives
- name: rpm
- name: Debian buster
image: debian:buster-slim
pull: always
environment:
CXXFLAGS: -pipe -O2
LANG: C.utf8
commands:
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- apt-get install -qy build-essential cmake lsb-release
- apt-get install -qy libpoco-dev libjsoncpp-dev file
- rm -rf build && mkdir -p build && cd build
- cmake -DWITH_DEB=YES -DWITH_DOC=NO ..
- make package
- cp -v libmastodon-cpp_${DRONE_TAG}-0_buster_amd64.deb ..
volumes:
- name: debian-package-cache
path: /var/cache/apt/archives
- name: Ubuntu bionic
image: ubuntu:bionic
pull: always
environment:
CXXFLAGS: -pipe -O2
LANG: C.utf8
commands:
- rm -f /etc/apt/apt.conf.d/docker-clean
- rm -f /var/cache/apt/archives/lock
- apt-get update -q
- apt-get install -qy build-essential cmake lsb-release
- apt-get install -qy libpoco-dev libjsoncpp-dev file
- rm -rf build && mkdir -p build && cd build
- cmake -DWITH_DEB=YES -DWITH_DOC=NO ..
- make package
- cp -v libmastodon-cpp_${DRONE_TAG}-0_bionic_amd64.deb ..
volumes:
- name: debian-package-cache
path: /var/cache/apt/archives
- name: CentOS 7
image: centos:7
pull: always
environment:
CXX: /opt/rh/devtoolset-6/root/usr/bin/g++
CXXFLAGS: -pipe -O2
LANG: C.utf8
commands:
- sed -i 's/keepcache=0/keepcache=1/' /etc/yum.conf
- curl -s -o /var/cache/yum/epel-release-latest-7.noarch.rpm http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
@ -191,9 +230,7 @@ steps:
- yum install -qy poco-devel openssl-devel doxygen rpm-build
- yum --enablerepo=epel install -qy cmake3 jsoncpp-devel
- rm -rf build && mkdir -p build && cd build
- cmake3 -DWITH_EXAMPLES=NO -DWITH_TESTS=NO ..
- make package
- cmake3 -DWITH_RPM=YES ..
- cmake3 -DWITH_RPM=YES -DWITH_DOC=NO ..
- make package
- cp -v libmastodon-cpp-${DRONE_TAG}-0.x86_64.rpm ..
volumes:
@ -210,8 +247,9 @@ steps:
title: ${DRONE_TAG}
prerelease: true
files:
- mastodon-cpp-${DRONE_TAG}_x86_64.tar.gz
- libmastodon-cpp_${DRONE_TAG}-0_amd64.deb
- libmastodon-cpp_${DRONE_TAG}-0_stretch_amd64.deb
- libmastodon-cpp_${DRONE_TAG}-0_buster_amd64.deb
- libmastodon-cpp_${DRONE_TAG}-0_bionic_amd64.deb
- libmastodon-cpp-${DRONE_TAG}-0.x86_64.rpm
checksum:
- sha256

20
.editorconfig Normal file
View File

@ -0,0 +1,20 @@
# Configuration file for EditorConfig.
# More information is available under <https://editorconfig.org/>.
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80
[*.?pp]
indent_size = 4
tab_width = 4
[{CMakeLists.txt,*.cmake}]
indent_size = 2
tab_width = 2

View File

@ -9,7 +9,7 @@ endif()
include(GNUInstallDirs)
project (mastodon-cpp
VERSION 0.110.0
VERSION 0.111.5
LANGUAGES CXX)
# DESCRIPTION was introduced in version 3.9.
@ -77,7 +77,7 @@ if(WITH_DOC)
add_dependencies(${PROJECT_NAME} doc)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/doc/html
DESTINATION "${CMAKE_INSTALL_DOCDIR}")
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}")
endif()
add_subdirectory("cmake")

49
CODE_OF_CONDUCT.adoc Normal file
View File

@ -0,0 +1,49 @@
:contact-coc: tastytea@tastytea.de
== Code of Conduct
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, education, ethnicity, gender identity and expression, level of
experience, nationality, personal appearance, race, religion, sex
characteristics, sexual identity and orientation or socio-economic status.
=== Examples
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language.
* Being respectful of differing viewpoints and experiences.
* Gracefully accepting constructive criticism.
* Focusing on what is best for the community.
* Showing empathy towards other community members.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances.
* Trolling, insulting/derogatory comments, and personal attacks.
* Public or private harassment.
* Publishing others private information, such as a physical or electronic
address, without explicit permission.
=== Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at {contact-coc}.
All complaints will be reviewed and investigated and will result in a response
that is deemed necessary and appropriate to the circumstances. The project team
is obligated to maintain confidentiality with regard to the reporter of an
incident.
=== Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

29
CONTRIBUTING.adoc Normal file
View File

@ -0,0 +1,29 @@
:project: mastodon-cpp
:uri-base: https://schlomp.space/tastytea/{project}
:uri-coc: {uri-base}/src/branch/master/CODE_OF_CONDUCT.adoc
:contact-email: tastytea@tastytea.de
:contact-xmpp: {contact-email}
:contact-fediverse: https://likeable.space/users/tastytea
== How to contribute
Read the link:{uri-coc}[Code of Conduct].
=== Reporting bugs or suggesting enhancements
Before reporting a bug, please
https://schlomp.space/tastytea/{project}/issues[perform a search] to see if the
problem has already been reported. If it has, add a comment to the existing
issue instead of opening a new one. Same for enhancements.
You can also contact me via mailto:{contact-email}[E-Mail],
link:xmpp:{contact-xmpp}[XMPP] or the {contact-fediverse}[Fediverse] if you
don't want to open an account.
=== Pull requests
Please use similar coding conventions as the rest of the project. The basic rule
to remember is to write code in the same style as the existing/surrounding code.
You can also send me your patches via mailto:{contact-email}[E-Mail], ideally
using `git format-patch` or `git send-email`.

View File

@ -1,16 +0,0 @@
# How to contribute
## Reporting bugs or suggesting enhancements
Before reporting a bug , please
[perform a search](https://schlomp.space/tastytea/mastodon-cpp/issues)
to see if the problem has already been reported. If it has, add a comment to the
existing issue instead of opening a new one. Same for enhancements.
You can also contact me via the Fediverse if you don't want to open an account.
My account is [@tastytea@likeable.space](https://likeable.space/users/tastytea).
## Pull requests
Please use similar coding conventions as the rest of the project. The basic rule
to remember is to write code in the same style as the existing/surrounding code.

View File

@ -1,17 +1,27 @@
= mastodon-cpp
:toc: preamble
:project: mastodon-cpp
:uri-base: https://schlomp.space/tastytea/{project}
:uri-branch-main: {uri-base}/src/branch/master
:uri-mastodonpp: https://schlomp.space/tastytea/mastodonpp
*mastodon-cpp* is a C++ wrapper for the Mastodon API. You submit an API call
and get the raw JSON or easy to use abstractions.
[IMPORTANT]
This project has become too complicated to maintain by myself and I can't find
the energy to add features. **You can find a complete rewrite, with cleaner and
much easier to understand code at link:{uri-mastodonpp}[mastodonpp].** I
recommend switching to it. You can still report bugs here and I will respond,
but I won't put too much work in it. If you want to take over maintainership,
get in touch.
*{project}* is a C++ wrapper for the Mastodon API. You submit an API call
and get the raw JSON that you can then transform into easy to use abstractions.
== Usage
The HTML reference can be generated with `build_doc.sh`, if doxygen is
installed. It is also available at
https://doc.schlomp.space/mastodon-cpp/annotated.html[doc.schlomp.space/mastodon-cpp/].
There are more
https://schlomp.space/tastytea/mastodon-cpp/src/branch/master/examples[examples]
in `examples/`.
https://doc.schlomp.space/{project}/annotated.html[doc.schlomp.space/{project}/].
There are more {uri-branch-main}/examples[examples] in `examples/`.
=== Examples
@ -76,10 +86,6 @@ Not included in this list are entities.
==== Return types
* `Mastodon::return_call`: Contains the response from `Mastodon::API` calls.
* `Mastodon::Easy::return_entity`: Contains the response from high-level
functions that return a single `Mastodon::Easy::Entity`.
* `Mastodon::Easy::return_entities_vector`: Contains the response from
high-level functions that return multiple `Mastodon::Easy::Entity`.
==== Other types
@ -132,14 +138,11 @@ If you use a debug build, you get more verbose error messages.
=== Upgrading from versions below 0.100.0
Starting with version `0.100.0`, large parts of the library have been rewritten.
Upgrading from previous versions will require extensive code changes. You can
keep using the old version, it is archived in the branch
https://schlomp.space/tastytea/mastodon-cpp/src/branch/pre-0.100.0[pre-0.100.0].
It will receive bug-fixes for a while but no new features.
Upgrading from previous versions will require extensive code changes.
=== Packages
Every https://schlomp.space/tastytea/mastodon-cpp/releases[release] includes
Every https://schlomp.space/tastytea/{project}/releases[release] includes
packages for Debian and Centos. Gentoo packages are available in my overlay.
==== Gentoo
@ -191,7 +194,7 @@ apt-get install build-essential cmake libpoco-dev libjsoncpp-dev doxygen
===== Release
Download the current release at
https://schlomp.space/tastytea/mastodon-cpp/releases[schlomp.space].
https://schlomp.space/tastytea/{project}/releases[schlomp.space].
===== Development version
@ -256,6 +259,8 @@ the filter ID with `MASTODON_CPP_FILTER_ID`. You can select the list ID with
* Have at least 1 list with at least one account in it.
* have at least 1 account muted.
include::{uri-base}/raw/branch/master/CONTRIBUTING.adoc[]
== Status of implementation
You can still use unsupported calls by using `API::get` and the others with

View File

@ -1,7 +1,7 @@
include(CMakeFindDependencyMacro)
include(GNUInstallDirs)
find_depencency(jsoncpp CONFIG REQUIRED)
find_dependency(jsoncpp CONFIG REQUIRED)
find_package(Poco COMPONENTS Foundation Net NetSSL CONFIG REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")

View File

@ -26,8 +26,11 @@ if (WITH_DEB)
execute_process(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND lsb_release --codename --short
OUTPUT_VARIABLE DEBIAN_CODENAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${DEBIAN_CODENAME}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
endif()
if (WITH_RPM)

View File

@ -7,5 +7,5 @@ endforeach()
if(WITH_DOC)
install(FILES ${sources_examples}
DESTINATION "${CMAKE_INSTALL_DOCDIR}/examples")
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}/examples")
endif()

View File

@ -0,0 +1,91 @@
// This file is part of mastodon-cpp.
// Get 2 pages of 5 favourites each.
// Don't compile this if the Easy-interface is turned off
#ifndef WITHOUT_EASY
#include <iostream>
#include <string>
#include <vector>
#include "mastodon-cpp.hpp"
#include "easy/all.hpp"
using std::cout;
using std::cerr;
using std::endl;
using std::string;
using std::vector;
using namespace Mastodon;
void print_favs(Easy::API &masto, const string &max_id = "")
{
// Set up parameters.
Mastodon::parameters params =
{
{ "limit", { "5" } },
{ "exclude_types", { "follow", "reblog", "mention" } }
};
// Set max_id if given.
if (!max_id.empty())
{
params.push_back({ "max_id", { max_id } });
}
// Retrieve the last 5 favourites.
return_call ret = masto.get(API::v1::notifications, params);
// If no error was returned.
if (ret)
{
// Convert answer to vector of strings, loop through vector.
for (const string &str : Easy::json_array_to_vector(ret.answer))
{
// Construct Mastodon::Easy::Notification from string.
const Easy::Notification notif(str);
cout << notif.created_at().strtime("%F %T: ");
cout << notif.account().display_name() << " favourited a status.\n";
}
}
else
{
// Print error message.
cerr << ret.error_message << endl;
// Print HTTP status code, if there is one.
if (ret.http_error_code != 0)
{
cerr << "HTTP status code: "
<< std::to_string(ret.http_error_code) << endl;
}
}
}
int main(int argc, char *argv[])
{
const vector<string> args(argv, argv + argc);
if (args.size() < 3)
{
std::cerr << "usage: " << args[0] << " <instance> <auth token>\n";
return 1;
}
// Construct a Mastodon::Easy object.
Easy::API masto(args[1], args[2]);
print_favs(masto);
cout << "\nLink header is: " << masto.get_header("link") << "\n\n";
// Get the max_id for pagination.
// See <https://docs.joinmastodon.org/api/rest/notifications/#pagination>
print_favs(masto, masto.get_link().max_id());
// The same: print_favs(masto, masto.get_link().next());
return 0;
}
#else
#include <iostream>
int main()
{
std::cout << "mastodon-cpp was compiled without Easy support.\n";
return 255;
}
#endif // WITHOUT_EASY

View File

@ -0,0 +1,48 @@
// This file is part of mastodon-cpp.
// Prints shortcode + URL for each custom emoji.
// Don't compile this if the Easy-interface is turned off
#ifndef WITHOUT_EASY
#include <iostream>
#include <string>
#include <vector>
#include "mastodon-cpp.hpp"
#include "easy/all.hpp"
using std::string;
using std::vector;
using namespace Mastodon;
int main(int argc, char *argv[])
{
const vector<string> args(argv, argv + argc);
if (args.size() < 2)
{
std::cerr << "usage: " << args[0] << " <instance>\n";
return 1;
}
// Construct a Mastodon::Easy object.
Easy::API masto(args[1], "");
const return_call ret = masto.get(API::v1::custom_emojis);
// Convert JSON array into vector of strings.
for (const string &str : Easy::json_array_to_vector(ret))
{
// Construct Emoji object from string.
const Easy::Emoji emoji(str);
std::cout << ':' << emoji.shortcode() << ": <" << emoji.url() << ">\n";
}
return 0;
}
#else
#include <iostream>
int main()
{
std::cout << "mastodon-cpp was compiled without Easy support.\n";
return 255;
}
#endif // WITHOUT_EASY

View File

@ -56,7 +56,7 @@ endif()
install(TARGETS ${PROJECT_NAME}
EXPORT "${PROJECT_NAME}Targets"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(FILES mastodon-cpp.hpp return_types.hpp types.hpp

View File

@ -101,8 +101,8 @@ Easy::Link::Link(const string &link_header)
: _next()
, _prev()
{
std::regex renext("max_id=([[:digit:]]*)");
std::regex reprev("since_id=([[:digit:]]*)");
std::regex renext("max_id=([[:alnum:]]*)");
std::regex reprev("(?:since|min)_id=([[:alnum:]]*)");
std::smatch match;
if (std::regex_search(link_header, match, renext))
@ -134,3 +134,8 @@ const string Easy::Link::since_id() const
{
return _prev;
}
const string Easy::Link::min_id() const
{
return _prev;
}

View File

@ -89,6 +89,13 @@ namespace Easy
*/
const string since_id() const;
/*!
* @brief Returns min_id.
*
* @since 0.111.0
*/
const string min_id() const;
private:
string _next;
string _prev;
@ -160,6 +167,7 @@ namespace Easy
*
* @since 0.100.0
*/
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
const return_entity<Easy::Status> send_post(const Status &status);
/*!
@ -167,6 +175,7 @@ namespace Easy
*
* @since 0.100.0
*/
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
const return_entity<Easy::Status> send_toot(const Status &status);
/*!
@ -180,6 +189,7 @@ namespace Easy
*
* @since 0.100.0
*/
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
const return_entity_vector<Easy::Notification> get_notifications(
const uint16_t limit = 20, const string since_id = "",
const string max_id = "");

View File

@ -36,8 +36,9 @@ namespace Easy
*
* @since 0.100.0
*/
template <typename T>
struct return_entity : return_base
template <typename T> struct
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
return_entity : return_base
{
/*!
* @brief Mastodon::Easy::Entity
@ -107,8 +108,9 @@ namespace Easy
*
* @since 0.100.0
*/
template <typename T>
struct return_entity_vector : return_base
template <typename T> struct
[[deprecated("Will go away in 1.0.0 with no replacement.")]]
return_entity_vector : return_base
{
/*!
* @brief std::vector of Mastodon::Easy::Entity.

View File

@ -234,13 +234,17 @@ return_call API::http::request_common(const http_method &meth,
}
HTTPResponse response;
istream &rs = session.receiveResponse(response);
istream &body_stream = session.receiveResponse(response);
const uint16_t http_code = response.getStatus();
ttdebug << "Response code: " << http_code << '\n';
answer.clear();
StreamCopier::copyToString(rs, answer);
StreamCopier::copyToString(body_stream, answer);
std::ostringstream headers_stream;
response.write(headers_stream);
_headers = headers_stream.str();
switch (http_code)
{
@ -343,7 +347,6 @@ return_call API::http::request_common(const http_method &meth,
}
}
// FIXME: get_headers() doesn't work anymore.
void API::http::get_headers(string &headers) const
{
headers = _headers;

View File

@ -20,6 +20,7 @@
#include <utility>
#include <iostream>
#include <exception>
#include <algorithm>
#include <Poco/Net/FilePartSource.h>
#include <Poco/URI.h>
#include "version.hpp"
@ -265,11 +266,18 @@ return_call API::register_app2(const string &client_id,
return ret;
}
const string API::get_header(const std::string &header) const
const string API::get_header(std::string header) const
{
string headers;
string headers_lower;
_http.get_headers(headers);
size_t startpos = headers.find(header + ':');
headers_lower.resize(headers.size());
std::transform(headers.begin(), headers.end(),
headers_lower.begin(), ::tolower);
std::transform(header.begin(), header.end(), header.begin(), ::tolower);
size_t startpos = headers_lower.find(header + ':');
if (startpos != std::string::npos)
{
startpos = headers.find(':', startpos) + 2;
@ -307,7 +315,7 @@ const parameters API::delete_params(const parameters &params,
std::copy_if(params.begin(), params.end(), newparams.begin(),
[&keys](const param &p)
{
return std::any_of(keys.begin(), keys.end(),
return std::all_of(keys.begin(), keys.end(),
[&p](const string &k)
{
return (k != p.key);

View File

@ -411,7 +411,7 @@ namespace Mastodon
string &access_token);
/*!
* @brief Gets the header from the last answer.
* @brief Gets the header from the last answer. Case insensitive.
*
* @param header The header to get
*
@ -419,7 +419,7 @@ namespace Mastodon
*
* @since before 0.11.0
*/
const string get_header(const string &header) const;
const string get_header(string header) const;
/*!
* @brief Turn exceptions on or off. Defaults to off.