Coder Social home page Coder Social logo

nheko-reborn / mtxclient Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 25.0 2.25 MB

Client API library for Matrix, built on top of libcurl

License: MIT License

Shell 0.49% CMake 3.31% Dockerfile 0.37% Makefile 0.22% C++ 94.89% Meson 0.68% Batchfile 0.03%
async hacktoberfest matrix

mtxclient's People

Contributors

ajberchek avatar chethan2k1 avatar christarazi avatar deepbluev7 avatar govynnus avatar heirecka avatar jevolk avatar kamathmanu avatar lorendb avatar maltee1 avatar mujx avatar nepnep21 avatar nico-famedly avatar r0hit05 avatar ramajd avatar redsky17 avatar rnhmjoj avatar symphorien avatar tastytea avatar thulinma avatar trilene avatar vurpo avatar xvitaly avatar yuyichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtxclient's Issues

Build failure - Hunter/OpenSSL

Hello again, I have been running into an issue with OpenSSL where rm -rfing ~/.hunter still doesn't appear to resolve the issue

Description

CMake fails

Branch / Commit

master / f4425af

OS

Arch with Kernel version 5.18.16-arch1-1

Compiler

GCC / G++ gcc (GCC) 13.1.1

Procedure

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DHUNTER_ENABLED=ON -DUSE_BUNDLED_OPENSSL=OFF -DBUILD_LIB_TESTS=OFF -DBUILD_LIB_EXAMPLES=OFF

Result


CMake Warning (dev) at /usr/share/cmake/Modules/ExternalProject.cmake:3091 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  /usr/share/cmake/Modules/ExternalProject.cmake:4208 (_ep_add_download_command)
  CMakeLists.txt:4 (ExternalProject_Add)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- [hunter] Initializing Hunter workspace (ca7838dded9a1811b04ffd56175f629e0af82d3d)
-- [hunter]   https://github.com/cpp-pm/hunter/archive/v0.24.8.tar.gz
-- [hunter]   -> /home/logicp/.hunter/_Base/Download/Hunter/0.24.8/ca7838d
CMake Error at /home/logicp/.hunter/_Base/Download/Hunter/0.24.8/ca7838d/Unpacked/cmake/find/FindOpenSSL.cmake:309 (message):
  Incorrect OPENSSL_VERSION_NUMBER define in header:
  /usr/include/openssl/opensslv.h
Call Stack (most recent call first):
  CMakeLists.txt:97 (find_package)

OpenSSL issues had come up in the past, but I'd always been able to get around them. In this case, even with examples/tests off and a clean ~/.hunter

Tests don't compile with -flto

Compiling mtxclient with -flto works fine, but compiling the tests fails:

build failure log
[86/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/messages.dir/tests/messages.cpp.o -o messages  -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build  libmatrix_client.so.0.8.0  /usr/lib64/libspdlog.so.1.10.0  /usr/lib64/libfmt.so.9.0.0  -Wl,--as-needed  /usr/lib64/libcoeurl.so  /usr/lib64/libssl.so  /usr/lib64/libcrypto.so  /usr/lib64/libolm.so.3.2.12  /usr/lib64/libgtest_main.so.1.11.0  /usr/lib64/libgtest.so.1.11.0 && :
FAILED: messages 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/messages.dir/tests/messages.cpp.o -o messages  -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build  libmatrix_client.so.0.8.0  /usr/lib64/libspdlog.so.1.10.0  /usr/lib64/libfmt.so.9.0.0  -Wl,--as-needed  /usr/lib64/libcoeurl.so  /usr/lib64/libssl.so  /usr/lib64/libcrypto.so  /usr/lib64/libolm.so.3.2.12  /usr/lib64/libgtest_main.so.1.11.0  /usr/lib64/libgtest.so.1.11.0 && :
lto-wrapper: warning: using serial compilation of 4 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/ccM7FmFB.ltrans1.ltrans.o: in function `RoomEvents_Encrypted_Test::TestBody()':
<artificial>:(.text+0x5d3a): undefined reference to `void mtx::events::from_json<mtx::events::msg::Encrypted>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::RoomEvent<mtx::events::msg::Encrypted>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x5ea5): undefined reference to `void mtx::events::to_json<mtx::events::msg::Encrypted>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::RoomEvent<mtx::events::msg::Encrypted> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6388): undefined reference to `void mtx::events::to_json<mtx::events::msg::Encrypted>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::RoomEvent<mtx::events::msg::Encrypted> const&)'
collect2: error: ld returned 1 exit status
[87/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/requests.dir/tests/requests.cpp.o -o requests  -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build  libmatrix_client.so.0.8.0  /usr/lib64/libspdlog.so.1.10.0  /usr/lib64/libfmt.so.9.0.0  -Wl,--as-needed  /usr/lib64/libcoeurl.so  /usr/lib64/libssl.so  /usr/lib64/libcrypto.so  /usr/lib64/libolm.so.3.2.12  /usr/lib64/libgtest_main.so.1.11.0  /usr/lib64/libgtest.so.1.11.0 && :
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
[88/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/events.dir/tests/events.cpp.o -o events  -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build  libmatrix_client.so.0.8.0  /usr/lib64/libspdlog.so.1.10.0  /usr/lib64/libfmt.so.9.0.0  -Wl,--as-needed  /usr/lib64/libcoeurl.so  /usr/lib64/libssl.so  /usr/lib64/libcrypto.so  /usr/lib64/libolm.so.3.2.12  /usr/lib64/libgtest_main.so.1.11.0  /usr/lib64/libgtest.so.1.11.0 && :
FAILED: events 
: && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/events.dir/tests/events.cpp.o -o events  -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build  libmatrix_client.so.0.8.0  /usr/lib64/libspdlog.so.1.10.0  /usr/lib64/libfmt.so.9.0.0  -Wl,--as-needed  /usr/lib64/libcoeurl.so  /usr/lib64/libssl.so  /usr/lib64/libcrypto.so  /usr/lib64/libolm.so.3.2.12  /usr/lib64/libgtest_main.so.1.11.0  /usr/lib64/libgtest.so.1.11.0 && :
lto-wrapper: warning: using serial compilation of 8 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationRequest_Test::TestBody()':
<artificial>:(.text+0x2c35): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationRequest>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationRequest>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x3024): undefined reference to `void mtx::events::to_json<mtx::events::msg::KeyVerificationRequest>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::Event<mtx::events::msg::KeyVerificationRequest> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationStart_Test::TestBody()':
<artificial>:(.text+0x3f30): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationStart>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationStart>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationAccept_Test::TestBody()':
<artificial>:(.text+0x4a13): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationAccept>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationAccept>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x4e49): undefined reference to `void mtx::events::to_json<mtx::events::msg::KeyVerificationAccept>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::Event<mtx::events::msg::KeyVerificationAccept> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationKey_Test::TestBody()':
<artificial>:(.text+0x54f9): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationKey>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationKey>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x5672): undefined reference to `void mtx::events::to_json<mtx::events::msg::KeyVerificationKey>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::Event<mtx::events::msg::KeyVerificationKey> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationMac_Test::TestBody()':
<artificial>:(.text+0x5c3a): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationMac>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationMac>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x6085): undefined reference to `void mtx::events::to_json<mtx::events::msg::KeyVerificationMac>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::Event<mtx::events::msg::KeyVerificationMac> const&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationReady_Test::TestBody()':
<artificial>:(.text+0x6725): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationReady>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationReady>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationDone_Test::TestBody()':
<artificial>:(.text+0x6f42): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationDone>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationDone>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/dev-libs/mtxclient-0.8.0/temp/cc99rG83.ltrans3.ltrans.o: in function `ToDevice_KeyVerificationCancel_Test::TestBody()':
<artificial>:(.text+0x748f): undefined reference to `void mtx::events::from_json<mtx::events::msg::KeyVerificationCancel>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::Event<mtx::events::msg::KeyVerificationCancel>&)'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: <artificial>:(.text+0x7688): undefined reference to `void mtx::events::to_json<mtx::events::msg::KeyVerificationCancel>(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::Event<mtx::events::msg::KeyVerificationCancel> const&)'
collect2: error: ld returned 1 exit status
[89/91] : && /usr/bin/x86_64-pc-linux-gnu-g++ -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 CMakeFiles/responses.dir/tests/responses.cpp.o -o responses  -Wl,-rpath,/var/tmp/portage/dev-libs/mtxclient-0.8.0/work/mtxclient-0.8.0_build  libmatrix_client.so.0.8.0  /usr/lib64/libspdlog.so.1.10.0  /usr/lib64/libfmt.so.9.0.0  -Wl,--as-needed  /usr/lib64/libcoeurl.so  /usr/lib64/libssl.so  /usr/lib64/libcrypto.so  /usr/lib64/libolm.so.3.2.12  /usr/lib64/libgtest_main.so.1.11.0  /usr/lib64/libgtest.so.1.11.0 && :
lto-wrapper: warning: using serial compilation of 7 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information

Full build log: https://861731.bugs.gentoo.org/attachment.cgi?id=795278
Gentoo bug: https://bugs.gentoo.org/861731

I don't think anyone needs optimized tests but i thought you may want to know about it. 😊

Build fails: Ubuntu 22.04 / GCC 11.2.0

Branch / Commit

master / e136bc2

OS

22.04 LTS (Pop!_OS)

Compiler

GCC / G++ 11.2.0

Procedure

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug
cmake --build build

Result

In file included from /data/stronglogic/mtxclient/include/mtx/requests.hpp:7,
                 from /data/stronglogic/mtxclient/lib/structs/requests.cpp:1:
/usr/include/c++/11/variant: In instantiation of ‘struct std::variant_size<const mtx::events::collections::StrippedEvents>’:
/usr/include/c++/11/variant:1756:13:   required from ‘constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...) [with _Visito
r = mtx::requests::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>; _Variants = {const mtx::events::collections::StrippedEvents&}; std::__detail::__variant::__visit_
result_t<_Visitor, _Variants ...> = nlohmann::basic_json<>]’
/data/stronglogic/mtxclient/lib/structs/requests.cpp:59:41:   required from here
/usr/include/c++/11/variant:84:12: error: invalid use of incomplete type ‘struct std::variant_size<mtx::events::collections::StrippedEvents>’
   84 |     struct variant_size<const _Variant> : variant_size<_Variant> {};
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/variant:81:12: note: declaration of ‘struct std::variant_size<mtx::events::collections::StrippedEvents>’
   81 |     struct variant_size;
      |            ^~~~~~~~~~~~
/usr/include/c++/11/variant: In instantiation of ‘constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...) [with _Visitor = 
mtx::requests::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>; _Variants = {const mtx::events::collections::StrippedEvents&}; std::__detail::__variant::__visit_resu
lt_t<_Visitor, _Variants ...> = nlohmann::basic_json<>]’:
/data/stronglogic/mtxclient/lib/structs/requests.cpp:59:41:   required from here
/usr/include/c++/11/variant:1756:20: error: ‘value’ is not a member of ‘std::variant_size<const mtx::events::collections::StrippedEvents>’
 1756 |               std::make_index_sequence<
      |                    ^~~~~~~~~~~~~~~~~~~~
 1757 |                 std::variant_size<remove_reference_t<_Variants>...>::value>());
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/variant:1760:29: error: non-constant condition for static assertion
 1760 |               static_assert(__visit_rettypes_match,
      |                             ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/variant:1763:15: error: return-statement with no value, in function returning ‘std::__detail::__variant::__visit_result_t<mtx::requests::to_json(json&, const mtx::re
quests::CreateRoom&)::<lambda(auto:42)>, const mtx::events::collections::StrippedEvents&>’ {aka ‘nlohmann::basic_json<>’} [-fpermissive]
 1763 |               return;
      |               ^~~~~~
/usr/include/c++/11/variant: In instantiation of ‘constexpr const size_t std::variant_size_v<const mtx::events::collections::StrippedEvents>’:
/usr/include/c++/11/variant:1049:10:   required from ‘struct std::__detail::__variant::__gen_vtable<std::__detail::__variant::__deduce_visit_result<nlohmann::basic_json<> >, mtx::reques
ts::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>&&, const mtx::events::collections::StrippedEvents&>’
/usr/include/c++/11/variant:1732:45:   required from ‘constexpr decltype(auto) std::__do_visit(_Visitor&&, _Variants&& ...) [with _Result_type = std::__detail::__variant::__deduce_visit
_result<nlohmann::basic_json<> >; _Visitor = mtx::requests::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>; _Variants = {const mtx::events::collections::StrippedEve
nts&}]’
/usr/include/c++/11/variant:1766:34:   required from ‘constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...) [with _Visito
r = mtx::requests::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>; _Variants = {const mtx::events::collections::StrippedEvents&}; std::__detail::__variant::__visit_
result_t<_Visitor, _Variants ...> = nlohmann::basic_json<>]’
/data/stronglogic/mtxclient/lib/structs/requests.cpp:59:41:   required from here
/usr/include/c++/11/variant:97:70: error: ‘value’ is not a member of ‘std::variant_size<const mtx::events::collections::StrippedEvents>’
   97 |     inline constexpr size_t variant_size_v = variant_size<_Variant>::value;
      |                                                                      ^~~~~
/usr/include/c++/11/variant: In instantiation of ‘constexpr decltype(auto) std::__do_visit(_Visitor&&, _Variants&& ...) [with _Result_type = std::__detail::__variant::__deduce_visit_res
ult<nlohmann::basic_json<> >; _Visitor = mtx::requests::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>; _Variants = {const mtx::events::collections::StrippedEvents&
}]’:
/usr/include/c++/11/variant:1766:34:   required from ‘constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...) [with _Visito
r = mtx::requests::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>; _Variants = {const mtx::events::collections::StrippedEvents&}; std::__detail::__variant::__visit_
result_t<_Visitor, _Variants ...> = nlohmann::basic_json<>]’
/data/stronglogic/mtxclient/lib/structs/requests.cpp:59:41:   required from here
/usr/include/c++/11/variant:1732:52: error: ‘_S_vtable’ is not a member of ‘std::__detail::__variant::__gen_vtable<std::__detail::__variant::__deduce_visit_result<nlohmann::basic_json<>
 >, mtx::requests::to_json(json&, const mtx::requests::CreateRoom&)::<lambda(auto:42)>&&, const mtx::events::collections::StrippedEvents&>’
 1732 |         _Result_type, _Visitor&&, _Variants&&...>::_S_vtable;
      |                                                    ^~~~~~~~~
gmake[2]: *** [CMakeFiles/matrix_client.dir/build.make:244: CMakeFiles/matrix_client.dir/lib/structs/requests.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:158: CMakeFiles/matrix_client.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Please advise! I have been stuck on an old commit of your project for a long time, but need to upgrade everything to C++20.

Tight loop and requests spam in case of 502 on /sync

In the case of a reverse proxy setup, and the homeserver is not available, the reverse proxy will return HTTP Status 502. This will cause what seems to be a tight loop and spam the server with requests until the client goes into "connectivity lost" mode.

This is problematic because:

  • Big spike in CPU usages
  • Can trigger (D)DoS protection on the reverse proxy/firewall

A waiting period might be desirable between attempts, as well as a limit in retries.

Truncated example console log:

[...]
[2019-03-11 21:41:54.797] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.800] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.802] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.805] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.807] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.810] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.812] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.815] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.818] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.821] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.824] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.828] [net] [error] sync error: 502 M_UNRECOGNIZED
[2019-03-11 21:41:54.834] [net] [error] sync error: 502 
[2019-03-11 21:41:54.835] [net] [info] connectivity lost

There doesn't seem to be recommendation for a generic retry mechanism in the C2S spec, or for /sync. The only recommendation found is about errors while sending messages.

Examples: Getting room names

Any chance of an example pulling in room information like it's name? The API isn't exactly easy to use / understand with the mixed layers of abstraction (I think some of this the complexities of Matrix). There also doesn't appear to be any documentation about any of this stuff.

Here was my best guess which was... wrong. Horribly wrong.

               for (mtx::events::collections::StateEvents &ev : room.state.events)
                       if (auto event = std::get_if<mtx::events::StateEvent<mtx::identifiers::Room>>(&ev);
                                       event != nullptr)
                       {
                               joinedMsg.AddString("chat_name", event->content.name.c_str());
                       }

coeurl issues

My account request at nheko.im was rejected so I cannot report an issue there or submit a pull request so these are the issues...

  1. There's some copy-n-paste issues at https://nheko.im/nheko-reborn/coeurl/-/blob/22f58922da16c3b94d293d98a07cb7caa7a019e8/CMakeLists.txt#L22-25

    The messages are all the same and there are two USE_BUNDLED_SPDLOGs.

  2. The install at https://nheko.im/nheko-reborn/coeurl/-/blob/22f58922da16c3b94d293d98a07cb7caa7a019e8/CMakeLists.txt#L137 has the wrong namespace.

    It should be coeurl:: (to be consistent with line 121) or ${PROJECT_NAME}::.

  3. There is no pkg-config files generated but this project uses those:

    find_package(PkgConfig REQUIRED)

    Setting a dummy coeurl_DIR seem to work around that though the installed cmake config isn't usable due to the previous issue.

can't find libevent_windows

Hi, I've been using this library flawlessly on linux for a while, and I wanted to port the app I'm using it with to windows while it's still kinda early in development.

Unfortunately, no matter what I try, I can't get it to realize I have libevent installed, and it errors.

image

Is there something I'm missing here? or a step i forgot to do?

Of note, opting for the USE_BUNDLED_* versions of libraries results in this error:

image

Attempting to remedy the above problem by enabling hunter gives me a new error. Using the exact(ish) same command as in the CI script, it fails with an error that's straight-up wrong.

image

E2E Key Import / Export Format Does Not Match Spec

System:

  • Nheko version: 0.6.3
  • Installation method: AppImage
  • Operating System: Arch Linux
  • Desktop Environment: Gnome Shell (3.30.2)

Actual behavior

decrypt_exported_sessions: ciphertext too small when trying to import E2EE keys from Riot.

Expected behavior

Keys are imported.

Steps to reproduce

  • Export keys from Riot using the "Export E2E room keys" button
  • Import the file in nheko

Logs

Nothing related in nheko logs.

Support custom fields for the PushData struct

as mentioned in the Matrix specification - Client Server API, data parameter in SetPusher struct should be a dictionary of pusher specific parameters:

Required if kind is not null. A dictionary of information for the pusher implementation itself. If kind is http, this should contain url which is the URL to use to send notifications to.

working on push notification implementation for iOS devices, I found that there are a series of additional parameters we need to set in the PushData struct.

{
  "url": "https://push-gateway.location.here/_matrix/push/v1/notify",
  "format": "event_id_only",
  "default_payload": {
    "aps": {
      "mutable-content": 1,
      "content-available": 1,
      "alert": {"loc-key": "SINGLE_UNREAD", "loc-args": []}
    }
  }
}

so I'm proposing tho change the data field in SetPusher struct to support additional parameters (Maybe the nlohmann::json).

MSC2285 hidden/private read receipts setting no longer functioning on Synapse 1.59 or later

MSC2285 for private read receipts was updated (https://github.com/matrix-org/matrix-spec-proposals/pull/2285/files) to use a new receipt type (org.matrix.msc2285.read.private) instead of the previously proposed read_fully flag (org.matrix.msc2285.hidden).

As of Synapse 1.59, support for the org.matrix.msc2285.hidden flag was ripped out (matrix-org/synapse@116a4c8) and replaced with support for the new read receipt type org.matrix.msc2285.read.private. This means all clients sending org.matrix.msc2285.hidden are now having their privacy request dropped by the server and are leaking read receipts once again.

Unfortunately both versions of the proposal share the same org.matrix.msc2285 unstable feature flag, making it effectively impossible to detect which servers will respect the org.matrix.msc2285.hidden flag.

Create pre warmed test docker image

As discussed with @deepbluev7, I woul like to run the mtxclient tests against the Conduit Matrix Homeserver in Conduit's CI.

mtxclient's test job currently needs to compile the project first, which takes some time. To avoid that during Conduit's CI runs, I envision the following:

  • mtxclients CI outputs a docker image (maybe just stored in the GitLab Container registry)
  • In the image the source code sits at /mtxclient and has already built binaries (and maybe ccache artifacts?), so that tests can be started immediately.

Rough suggestion for how that could look like:

FROM ubuntu:18.04
RUN mkdir /mtxclient
COPY . /mtxclient/
WORKDIR /mtxclient/
RUN ... # Basically all these lines: https://nheko.im/nheko-reborn/mtxclient/-/blob/master/.gitlab-ci.yml#L54-80

Build fails: Arch /w 5.18.16-arch1-1

Thanks again for following up so quick on the other issue. Everything builds perfectly on that system, but I have another deployment environment where I've run into some issues.

Description

Build fails when linking with coeurl libcoeurld.so

Branch / Commit

master / e136bc2

OS

Arch with Kernel version 5.18.16-arch1-1

Compiler

GCC / G++ 12.1.1

Procedure

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DHUNTER_ENABLED=ON
cmake --build build

Result

[ 56%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/responses/turn_server.cpp.o
[ 56%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/responses/users.cpp.o
[ 57%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/responses/version.cpp.o
[ 58%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/responses/well-known.cpp.o
[ 58%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/responses/public_rooms.cpp.o
[ 59%] Linking CXX shared library libmatrix_client.so
[ 59%] Built target matrix_client
[ 59%] Building CXX object CMakeFiles/client_api.dir/tests/client_api.cpp.o
[ 60%] Linking CXX executable client_api
/usr/bin/ld: _deps/coeurl-build/libcoeurld.so: undefined reference to `arc4random_addrandom' 
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/client_api.dir/build.make:109: client_api] Error 1
make[1]: *** [CMakeFiles/Makefile2:250: CMakeFiles/client_api.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Any information is greatly appreciated!

Compilation fails.

/usr/bin/clang++ -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dmatrix_client_EXPORTS -I/tmp/SBo/mtxclient-f4f0bed1c3723daf83d715b98d94b0cde7b42243/include -O2 -fPIC -std=c++23 -fpermissive 		-Wall 		-Wextra 		-Wconversion 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -O3 -DNDEBUG -fPIC -pthread -DNOMINMAX -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -std=c++20 -MD -MT CMakeFiles/matrix_client.dir/lib/structs/events/messages/file.cpp.o -MF CMakeFiles/matrix_client.dir/lib/structs/events/messages/file.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/structs/events/messages/file.cpp.o -c /tmp/SBo/mtxclient-f4f0bed1c3723daf83d715b98d94b0cde7b42243/lib/structs/events/messages/file.cpp
In file included from /tmp/SBo/mtxclient-f4f0bed1c3723daf83d715b98d94b0cde7b42243/lib/structs/requests.cpp:1:
In file included from /tmp/SBo/mtxclient-f4f0bed1c3723daf83d715b98d94b0cde7b42243/include/mtx/requests.hpp:7:
/usr/bin/../lib64/gcc/x86_64-slackware-linux/11.2.0/../../../../include/c++/11.2.0/variant:84:43: error: implicit instantiation of undefined template 'std::variant_size<mtx::events::collections::StrippedEvents>'
   84 |     struct variant_size<const _Variant> : variant_size<_Variant> {};
      |                                           ^
/usr/bin/../lib64/gcc/x86_64-slackware-linux/11.2.0/../../../../include/c++/11.2.0/variant:1755:15: note: in instantiation of template class 'std::variant_size<const mtx::events::collections::StrippedEvents>' requested here
 1755 |                 std::variant_size<remove_reference_t<_Variants>...>::value>());
      |                      ^
/tmp/SBo/mtxclient-f4f0bed1c3723daf83d715b98d94b0cde7b42243/lib/structs/requests.cpp:57:36: note: in instantiation of function template specialization 'std::visit<(lambda at /tmp/SBo/mtxclient-f4f0bed1c3723daf83d715b98d94b0cde7b42243/lib/structs/requests.cpp:57:42), const mtx::events::collections::StrippedEvents &>' requested here
   57 |             auto event_json = std::visit([](auto e) { return json(e); }, ev);
      |                                    ^
/usr/bin/../lib64/gcc/x86_64-slackware-linux/11.2.0/../../../../include/c++/11.2.0/variant:81:12: note: template is declared here
   81 |     struct variant_size;
      |            ^

Tests fail to build with nlohmann_json 3.11.2

Hello

I'm a package maintainer in Archlinux and looking to get nheko into the repos. Building the mtxclient using cmake and enabled tests fails with the below which I think is due to nlogmann_json dependency (maybe I'm wrong):

FAILED: messages 
: && /usr/bin/c++ -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/mtxclient/src=/usr/src/debug/mtxclient -flto=auto 		-Wall 		-Wextra 		-Wconversion 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto CMakeFiles/messages.dir/tests/messages.cpp.o -o messages  -Wl,-rpath,/build/mtxclient/src/build  libmatrix_client.so.0.9.1  /usr/lib/libspdlog.so.1.11.0  /usr/lib/libfmt.so.9.1.0  /usr/lib/libcoeurl.so  /usr/lib/libssl.so  /usr/lib/libcrypto.so  /usr/lib/libolm.so.3.2.12  /usr/lib/libgtest_main.so.1.13.0  /usr/lib/libgtest.so.1.13.0 && :
/usr/bin/ld: /tmp/ccqB79NN.ltrans1.ltrans.o: in function `RoomEvents_Encrypted_Test::TestBody()':
/usr/include/nlohmann/detail/conversions/from_json.hpp:478: undefined reference to `void mtx::events::from_json<mtx::events::msg::Encrypted>(nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, mtx::events::RoomEvent<mtx::events::msg::Encrypted>&)'
/usr/bin/ld: /tmp/ccqB79NN.ltrans1.ltrans.o: in function `RoomEvents_Encrypted_Test::TestBody()':
/usr/include/nlohmann/detail/conversions/to_json.hpp:428: undefined reference to `void mtx::events::to_json<mtx::events::msg::Encrypted>(nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::RoomEvent<mtx::events::msg::Encrypted> const&)'
/usr/bin/ld: /usr/include/nlohmann/detail/conversions/to_json.hpp:428: undefined reference to `void mtx::events::to_json<mtx::events::msg::Encrypted>(nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, mtx::events::RoomEvent<mtx::events::msg::Encrypted> const&)'
collect2: error: ld returned 1 exit status

Build command used:

  cmake \
    -Bbuild \
    -GNinja \
    -S "$pkgname" \
    -DCMAKE_BUILD_TYPE='None' \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -DCMAKE_INSTALL_LIBDIR='lib' \
    -DBUILD_LIB_EXAMPLES=OFF \
    -DBUILD_SHARED_LIBS=ON \
    -Wno-dev
  cmake --build build --verbose

cmake build detection log:

-- The C compiler identification is GNU 12.2.1
-- The CXX compiler identification is GNU 12.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found OpenSSL: /usr/lib/libcrypto.so (found suitable version "3.0.8", minimum required is "1.1.0")  
-- Found nlohmann_json: /usr/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found suitable version "3.11.2", minimum required is "3.2.0") 
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0") 
-- Checking for module 're2'
--   Found re2, version 10.0.0
-- Checking for module 'libevent_core'
--   Found libevent_core, version 2.1.12
-- Checking for module 'libevent_pthreads'
--   Found libevent_pthreads, version 2.1.12
-- Checking for module 'libcurl'
--   Found libcurl, version 7.87.0
-- Checking for module 'coeurl>=0.3.0'
--   Found coeurl, version 0.3.0
-- The following REQUIRED packages have been found:

 * OpenSSL (required version >= 1.1.0), Open source SSL and TLS implementation and cryptographic library, <https://www.openssl.org/>
 * Olm (required version >= 3.2.7), An implementation of the Double Ratchet cryptographic ratchet, <https://git.matrix.org/git/olm/about/>
 * nlohmann_json (required version >= 3.2.0), JSON for Modern C++, a C++11 header-only JSON class, <https://nlohmann.github.io/json/>
 * Threads
 * spdlog (required version >= 1.0.0), Very fast, header only, C++ logging library, <https://github.com/gabime/spdlog>
 * PkgConfig

-- Found GTest: /usr/lib/cmake/GTest/GTestConfig.cmake (found version "1.13.0") 
-- Configuring done

[...]

You can see the full log mtxclient-0.9.1-1-x86_64-build.log

Thanks for the assistance

Boost Build Fails On FreeBSD

The bundled boost library fails to build correctly on FreeBSD because --with-toolchain is not specified with the boost bootstrap. Update the boost cmake file to specify this parameter (making sure to use the correct one, ie: msvc, gcc, etc)

Failure to build from source (missing include)

Latest master with GCC 10:

/home/einar/Download/Sources/mtxclient/lib/http/session.cpp: In member function ‘void mtx::http::Session::on_close(boost::system::error_code)’:
/home/einar/Download/Sources/mtxclient/lib/http/session.cpp:60:22: error: ‘cout’ is not a member of ‘std’
   60 |                 std::cout << "shutdown: " << ec.message() << std::endl;
      |                      ^~~~
/home/einar/Download/Sources/mtxclient/lib/http/session.cpp:2:1: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
    1 | #include "mtxclient/http/session.hpp"

Tests: distinguish by the need of network connection

Hi, I'm building this library on guix. The build environment does not have network connection. I'd still like to run as many tests as possible, so it would be useful to have a flag that distinguish between those that depends on a working network connection and those that can be run locally.

Thanks!

Fails to build against Boost 1.70 (Beta1)

Regressed by boostorg/beast@9a8e22950ff5:

lib/http/session.cpp:60:22: error: no member named 'cout' in namespace 'std'
                std::cout << "shutdown: " << ec.message() << std::endl;
                ~~~~~^
lib/http/session.cpp:155:22: error: no member named 'cerr' in namespace 'std'
                std::cerr << ec.message() << "\n";
                ~~~~~^
2 errors generated.

Add logger to spdlog's registry

As discussed here, mtxclient should register its logger with spdlog in order for Nheko's per-component log settings to work on the mtx component.

A quick search of today's mtxclient code doesn't yield any hits for spdlog::register_logger(), and nheko -l off,mtx=trace doesn't produce any output, so I guess it still needs doing.

missing fPIC from examples and tests

CMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON

global fPIC is on, however..

/mtxclient> find . -name link.txt -exec grep -H fPIC {} \;

./build/CMakeFiles/matrix_client.dir/link.txt:/bin/c++ -fPIC            -Wall           -Wextra                 -pipe           -pedantic               -fsized-deallocation            -fdiagnostics-color=always              -Wno-attributes                -Wunreachable-code -shared -Wl,-soname,libmatrix_client.so.0.4.1 -o libmatrix_client.so.0.4.1 CMakeFiles/matrix_client.dir/lib/http/client.cpp.o CMakeFiles/matrix_client.dir/lib/http/session.cpp.o CMakeFiles/matrix_client.dir/lib/crypto/client.cpp.o CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o CMakeFiles/matrix_client.dir/lib/crypto/types.cpp.o CMakeFiles/matrix_client.dir/lib/crypto/utils.cpp.o CMakeFiles/matrix_client.dir/lib/utils.cpp.o CMakeFiles/matrix_client.dir/lib/log.cpp.o CMakeFiles/matrix_client.dir/lib/structs/common.cpp.o CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events.cpp.o CMakeFiles/matrix_client.dir/lib/structs/identifiers.cpp.o CMakeFiles/matrix_client.dir/lib/structs/pushrules.cpp.o CMakeFiles/matrix_client.dir/lib/structs/requests.cpp.o CMakeFiles/matrix_client.dir/lib/structs/secret_storage.cpp.o CMakeFiles/matrix_client.dir/lib/structs/user_interactive.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/aliases.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/avatar.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/canonical_alias.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/collections.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/common.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/create.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/encrypted.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/encryption.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/guest_access.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/history_visibility.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/join_rules.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/member.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/name.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/pinned_events.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/power_levels.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/presence.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/reaction.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/redaction.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/tag.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/tombstone.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/topic.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/unknown.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/voip.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/account_data/fully_read.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/ephemeral/receipt.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/ephemeral/typing.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/nheko_extensions/hidden_events.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/messages/audio.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/messages/emote.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/messages/file.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/messages/image.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/messages/notice.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/messages/text.cpp.o CMakeFiles/matrix_client.dir/lib/structs/events/messages/video.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/common.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/create_room.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/crypto.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/empty.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/groups.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/login.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/media.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/messages.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/notifications.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/profile.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/register.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/sync.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/turn_server.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/version.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/well-known.cpp.o CMakeFiles/matrix_client.dir/lib/structs/responses/public_rooms.cpp.o  -Wl,-rpath,/boot/system/lib:/packages/olm-3.1.4-1/.self/lib: /boot/system/lib/libboost_iostreams.so.1.70.0 /boot/system/lib/libboost_system.so.1.70.0 /boot/system/lib/libboost_thread.so.1.70.0 /packages/openssl-1.1.1i-1/.self/develop/lib/libcrypto.so /packages/openssl-1.1.1i-1/.self/develop/lib/libssl.so /packages/olm-3.1.4-1/.self/lib/libolm.so.3.1.4 /packages/openssl-1.1.1i-1/.self/develop/lib/libcrypto.so 

-fPIC only shows up on the shared library. The build fails due to fPIC issues between boost and various matrix components.

compilation fails for aarch64-linux using nix (missing include <compare>)

If I build mtxclient natively for x86_64-linux on x86_64-linux, it builds.

But when I try to build for aarch64-linux on aarch64-linux, it seems to fail:

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/4f0jxn0q4zirrkmx6dk5d33ipa56n33q-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
fixing cmake files...
cmake flags: -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCMAKE_INSTALL_LOCALEDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/share/locale -DCMAKE_INSTALL_LIBEXECDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/libexec -DCMAKE_INSTALL_LIBDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/lib -DCMAKE_INSTALL_DOCDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/share/doc/matrix_client -DCMAKE_INSTALL_INFODIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/share/info -DCMAKE_INSTALL_MANDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/share/man -DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/include -DCMAKE_INSTALL_INCLUDEDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/include -DCMAKE_INSTALL_SBINDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/sbin -DCMAKE_INSTALL_BINDIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/bin -DCMAKE_INSTALL_NAME_DIR=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_SYSROOT= -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_STRIP=/nix/store/1aaqc3ln9rb8nbbjrr8izwr3flb9aiql-gcc-wrapper-9.5.0/bin/strip -DCMAKE_RANLIB=/nix/store/1aaqc3ln9rb8nbbjrr8izwr3flb9aiql-gcc-wrapper-9.5.0/bin/ranlib -DCMAKE_AR=/nix/store/1aaqc3ln9rb8nbbjrr8izwr3flb9aiql-gcc-wrapper-9.5.0/bin/ar -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/nix/store/gkg3idj03w6zaad8iygd5cjdan6vz9r2-mtxclient-0.9.1 -DBUILD_LIB_TESTS=OFF -DBUILD_LIB_EXAMPLES=OFF
-- The C compiler identification is GNU 9.5.0
-- The CXX compiler identification is GNU 9.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /nix/store/1aaqc3ln9rb8nbbjrr8izwr3flb9aiql-gcc-wrapper-9.5.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/1aaqc3ln9rb8nbbjrr8izwr3flb9aiql-gcc-wrapper-9.5.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found OpenSSL: /nix/store/d55mh0sryrcpx4v8qr0g09z847c82l1w-openssl-3.0.7/lib/libcrypto.so (found suitable version "3.0.7", minimum required is "1.1.0")
-- Found nlohmann_json: /nix/store/kz4a6jwgyhpmdr8syilwhvv874ias3gg-nlohmann_json-3.11.2/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found suitable version "3.11.2", minimum required is "3.2.0")
-- Found PkgConfig: /nix/store/q7aj160n34mpagxfvhv0yj5ixzirsfnz-pkg-config-wrapper-0.29.2/bin/pkg-config (found version "0.29.2")
-- Checking for module 're2'
--   Found re2, version 10.0.0
-- Checking for module 'libevent_core'
--   Found libevent_core, version 2.1.12-stable
-- Checking for module 'libevent_pthreads'
--   Found libevent_pthreads, version 2.1.12-stable
-- Checking for module 'libcurl'
--   Found libcurl, version 7.87.0
-- Checking for module 'coeurl>=0.3.0'
--   Found coeurl, version 0.3.0
-- The following REQUIRED packages have been found:

 * OpenSSL (required version >= 1.1.0), Open source SSL and TLS implementation and cryptographic library, <https://www.openssl.org/>
 * Olm (required version >= 3.2.7), An implementation of the Double Ratchet cryptographic ratchet, <https://git.matrix.org/git/olm/about/>
 * nlohmann_json (required version >= 3.2.0), JSON for Modern C++, a C++11 header-only JSON class, <https://nlohmann.github.io/json/>
 * Threads
 * spdlog (required version >= 1.0.0), Very fast, header only, C++ logging library, <https://github.com/gabime/spdlog>
 * PkgConfig

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BUILD_TESTING
    CMAKE_POLICY_DEFAULT_CMP0025



-- Build files have been written to: /build/source/build
cmake: enabled parallel building
@nix { "action": "setPhase", "phase": "buildPhase" }
building
build flags: -j80 SHELL=/nix/store/sc8jyzxrzkw4sq01fa9zbgj530prz2sy-bash-5.2-p15/bin/bash
[  1%] Building CXX object CMakeFiles/matrix_client.dir/lib/http/client.cpp.o
[  2%] Building CXX object CMakeFiles/matrix_client.dir/lib/crypto/client.cpp.o
[  4%] Building CXX object CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o
[  5%] Building CXX object CMakeFiles/matrix_client.dir/lib/crypto/types.cpp.o
[  6%] Building CXX object CMakeFiles/matrix_client.dir/lib/crypto/utils.cpp.o
[  8%] Building CXX object CMakeFiles/matrix_client.dir/lib/utils.cpp.o
[  9%] Building CXX object CMakeFiles/matrix_client.dir/lib/log.cpp.o
[ 10%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/common.cpp.o
[ 12%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o
[ 13%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/events.cpp.o
[ 14%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/identifiers.cpp.o
In file included from /build/source/include/mtx/events.hpp:15,
                 from /build/source/include/mtxclient/http/client.hpp:13,
                 from /build/source/lib/http/client.cpp:1:
/build/source/include/mtx/identifiers.hpp:12:10: fatal error: compare: No such file or directory
   12 | #include <compare>
      |          ^~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/matrix_client.dir/build.make:76: CMakeFiles/matrix_client.dir/lib/http/client.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 16%] Building CXX object CMakeFiles/matrix_client.dir/lib/structs/pushrules.cpp.o
/build/source/include/mtx/identifiers.hpp:12:10: fatal error: compare: No such file or directory
   12 | #include <compare>
      |          ^~~~~~~~~
compilation terminated.
In file included from /build/source/include/mtx/events.hpp:15,
                 from /build/source/lib/structs/events.cpp:1:
/build/source/include/mtx/identifiers.hpp:12:10: fatal error: compare: No such file or directory
   12 | #include <compare>
      |          ^~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/matrix_client.dir/build.make:90: CMakeFiles/matrix_client.dir/lib/crypto/client.cpp.o] Error 1
make[2]: *** [CMakeFiles/matrix_client.dir/build.make:202: CMakeFiles/matrix_client.dir/lib/structs/events.cpp.o] Error 1
In file included from /build/source/include/mtxclient/crypto/client.hpp:17,
                 from /build/source/lib/crypto/utils.cpp:17:
/build/source/include/mtx/identifiers.hpp:12:10: fatal error: compare: No such file or directory
   12 | #include <compare>
      |          ^~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/matrix_client.dir/build.make:132: CMakeFiles/matrix_client.dir/lib/crypto/utils.cpp.o] Error 1
In file included from /build/source/lib/structs/pushrules.cpp:1:
/build/source/include/mtx/pushrules.hpp:12:10: fatal error: compare: No such file or directory
   12 | #include <compare>
      |          ^~~~~~~~~
compilation terminated.
In file included from /build/source/lib/structs/identifiers.cpp:1:
/build/source/include/mtx/identifiers.hpp:12:10: fatal error: compare: No such file or directory
   12 | #include <compare>
      |          ^~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/matrix_client.dir/build.make:230: CMakeFiles/matrix_client.dir/lib/structs/pushrules.cpp.o] Error 1
make[2]: *** [CMakeFiles/matrix_client.dir/build.make:216: CMakeFiles/matrix_client.dir/lib/structs/identifiers.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/matrix_client.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

JSON type errors cause events to be discarded, creating incompatibility with Element and other clients

This issue was going to originally be about specifically accepting JSON null values for optionally-present fields, but I think in general, it may be the expected behavior that clients be much more tolerant of out-of-spec JSON types than is currently implemented.


It seems that due to the lack of weak-typing-like conversions in the JSON library, a lot of events can potentially be discarded with errors like this:

[json.exception.type_error.302] type must be string, but is null

An example event I saw generated by an unnamed bot, where the thumbnail_info and thumbnail_url fields are null:

{
  "type": "m.room.message",
  "sender": "<redacted>",
  "content": {
    "body": "<redacted>",
    "info": {
      "size": 218987,
      "mimetype": "image/png",
      "thumbnail_info": null,
      "w": 462,
      "h": 462,
      "thumbnail_url": null
    },
    "msgtype": "m.image",
    "url": "mxc://<redacted>"
  },
  "origin_server_ts": 1654407062081,
  "unsigned": {
    "age": 386186
  },
  "event_id": "<redacted>",
  "room_id": "<redacted>"
}

I believe this is a malformed event, but Element, NeoChat and Quaternion will process and render it, while Nheko will discard it. (I did not test any other clients)

I think its tough to decide if/how a malformed event should be dropped or tolerated, but I think these Javascript-like rules make sense, at least for room event JSON content:

  1. Accepting a partial or empty object (e.g. the thumbnail_info value is empty, {}; or incomplete, {"w":100} with no other fields) as equivalent to the value being non-present -- Although perhaps some structures would need to be handled specially depending on which specific fields are present/valid
  2. Accepting a primitive type (null, int, string, bool), or array, as equivalent to an empty object or empty array, including the role of empty objects in the above rule -- Object keys that could be numeric do exist in Matrix, but I don't believe any exist in room events, so object<->array inter-compatibility is not needed
  3. Accepting any floating point number as equivalent to an int, including its role in the above rule as a primitive type -- Matrix does not use floating point numbers, so I believe this is OK -- if a future change or proposal needs it, an explicit request for the original floating point value could be made
  4. Accepting a non-present, but required key, as equivalent to an empty string / zero value / empty array / empty object -- I am the least sure about the future implications of this as specs change and extensions grow
  5. Implementing other primitive type (null, int, string, bool) conversions somewhat equivalent to Javascript -- Such that a string representation of a number in a field that is specified as an int could be processed, etc.

This would probably involve wrapping a lot of the JSON library interfaces with getters that allow for conversion, as well as changing a lot of various code to take more care not to assume that all expected object keys will exist.

I think these changes are logical for the following reasons:

  • Its reasonably logical, and other implementations are likely to end up working this way, even by accident, given how weak typed languages and JSON libraries tend to work.
  • Element seems to work this way in practice already.
  • Malformed messages are being generated and do exist (Also see: matrix-org/synapse#8445)
  • I believe the proposed behavior has a very low chance of breaking on any future valid messages, requiring a very bad change to the spec, like having a value that can either be null or not-present with different behavior.

Some related matrix.org stuff about clients being forced to deal with un-trusted event data:

As far as I can find, Matrix does not specify how clients should respond to out-of-spec event data, but it seems logical to stick to the behavior which most closely matches the most popular implementation, and to avoid cases where any room events can get dropped despite all of the critical info being present and able to be interpreted, and especially in cases where events get dropped just because some optional data is invalid.

There is one part of the spec that specifies behavior in the case that a value is "If not present, null, or empty", despite specifying it as a string, which supports the idea that clients should be tolerant in this way, however.

0.5.1 release Incompatible with Olm 3.2.6

The build of 0.5.1 release fails against Olm 3.2.6 on FreeBSD with clang 11.0.1, as follows:

/wrkdirs/usr/ports/net-im/mtxclient/work/mtxclient-0.5.1/lib/crypto/client.cpp:40:1: error: reference to 'OlmErrorCode' is ambiguous
OlmErrorCode
^
/usr/local/include/olm/error.h:22:6: note: candidate found by name lookup is 'OlmErrorCode'
enum OlmErrorCode {
     ^
/wrkdirs/usr/ports/net-im/mtxclient/work/mtxclient-0.5.1/include/mtxclient/crypto/client.hpp:34:12: note: candidate found by name lookup is 'mtx::crypto::OlmErrorCode'
enum class OlmErrorCode

This is, I think, because the newer Olm release introduces Olm error codes (I spotted a new header olm_error.h for instance). The fix is to add mtx::crypto:: to disambiguate the type-name lookup in client.cpp.

Build failure with latest json and GCC

GCC 10.1.1
json: 3.7.3
Boost: 1.73

[5/56] /usr/bin/c++  -Dmatrix_client_EXPORTS -I../include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wunreachable-code -DNDEBUG -fPIC   -pthread -std=c++17 -MD -MT CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o -MF CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o -c ../lib/structs/errors.cpp
FAILED: CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o 
/usr/bin/c++  -Dmatrix_client_EXPORTS -I../include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wunreachable-code -DNDEBUG -fPIC   -pthread -std=c++17 -MD -MT CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o -MF CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/structs/errors.cpp.o -c ../lib/structs/errors.cpp
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/utility:70,
                 from /usr/include/c++/10/algorithm:60,
                 from /usr/include/nlohmann/json.hpp:37,
                 from ../include/mtx/errors.hpp:6,
                 from ../lib/structs/errors.cpp:1:
/usr/include/c++/10/type_traits: In instantiation of 'struct std::is_constructible<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>':
/usr/include/nlohmann/json.hpp:11120:79:   required by substitution of 'template<class ... Args, typename std::enable_if<std::is_constructible<nlohmann::basic_json<>, Args ...>::value, int>::type <anonymous> > nlohmann::detail::json_ref<nlohmann::basic_json<> >::json_ref(Args&& ...) [with Args = {const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&}; typename std::enable_if<std::is_constructible<nlohmann::basic_json<>, Args ...>::value, int>::type <anonymous> = <missing>]'
/usr/include/c++/10/type_traits:901:30:   required from 'struct std::__is_constructible_impl<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
/usr/include/c++/10/type_traits:930:12:   required from 'struct std::__is_copy_constructible_impl<nlohmann::basic_json<>, true>'
/usr/include/c++/10/type_traits:936:12:   required from 'struct std::is_copy_constructible<nlohmann::basic_json<> >'
/usr/include/c++/10/type_traits:3111:33:   required from 'constexpr const bool std::is_copy_constructible_v<nlohmann::basic_json<> >'
/usr/include/c++/10/variant:294:5:   [ skipping 4 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/c++/10/bits/hashtable_policy.h:233:43:   required from 'struct std::__detail::_Hash_node_value_base<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > > >'
/usr/include/c++/10/bits/hashtable_policy.h:264:12:   required from 'struct std::__detail::_Hash_node<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >, true>'
/usr/include/c++/10/bits/hashtable_policy.h:1973:13:   required from 'struct std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >, true> > >'
/usr/include/c++/10/bits/hashtable.h:173:11:   required from 'class std::_Hashtable<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > > >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char> >, std::hash<std::__cxx11::basic_string<char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >'
/usr/include/c++/10/bits/unordered_map.h:105:18:   required from 'class std::unordered_map<std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >'
../include/mtx/user_interactive.hpp:78:46:   required from here
/usr/include/c++/10/type_traits:906:12: error: invalid use of incomplete type 'struct std::__is_constructible_impl<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
  906 |     struct is_constructible
      |            ^~~~~~~~~~~~~~~~
/usr/include/c++/10/type_traits:900:12: note: declaration of 'struct std::__is_constructible_impl<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
  900 |     struct __is_constructible_impl
      |            ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/vector:66,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/nlohmann/json.hpp:37,
                 from ../include/mtx/errors.hpp:6,
                 from ../lib/structs/errors.cpp:1:
/usr/include/c++/10/bits/stl_uninitialized.h: In instantiation of '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const nlohmann::basic_json<>*, std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >; _ForwardIterator = nlohmann::basic_json<>*]':
/usr/include/c++/10/bits/stl_uninitialized.h:325:37:   required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const nlohmann::basic_json<>*, std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >; _ForwardIterator = nlohmann::basic_json<>*; _Tp = nlohmann::basic_json<>]'
/usr/include/c++/10/bits/stl_vector.h:558:31:   required from 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = nlohmann::basic_json<>; _Alloc = std::allocator<nlohmann::basic_json<> >]'
/usr/include/c++/10/ext/new_allocator.h:150:4:   required from 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >; _Args = {const std::vector<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>, std::allocator<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >&}; _Tp = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >]'
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >; _Args = {const std::vector<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>, std::allocator<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >&}; _Tp = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >]'
/usr/include/nlohmann/json.hpp:15381:35:   [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/nlohmann/json.hpp:16365:25:   required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::basic_json(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]'
/usr/include/nlohmann/json.hpp:4737:31:   required from 'bool nlohmann::detail::json_sax_dom_callback_parser<BasicJsonType>::end_object() [with BasicJsonType = nlohmann::basic_json<>]'
/usr/include/nlohmann/json.hpp:8847:33:   required from 'bool nlohmann::detail::parser<BasicJsonType>::sax_parse_internal(SAX*) [with SAX = nlohmann::detail::json_sax_dom_callback_parser<nlohmann::basic_json<> >; BasicJsonType = nlohmann::basic_json<>]'
/usr/include/nlohmann/json.hpp:8738:31:   required from 'void nlohmann::detail::parser<BasicJsonType>::parse(bool, BasicJsonType&) [with BasicJsonType = nlohmann::basic_json<>]'
/usr/include/nlohmann/json.hpp:20882:79:   required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parse(IteratorType, IteratorType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t, bool) [with IteratorType = const char*; typename std::enable_if<std::is_base_of<std::random_access_iterator_tag, typename std::iterator_traits<_InputIterator>::iterator_category>::value, int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t = std::function<bool(int, nlohmann::detail::parser<nlohmann::basic_json<> >::parse_event_t, nlohmann::basic_json<>&)>]'
/usr/include/nlohmann/json.hpp:22700:42:   required from here
/usr/include/c++/10/bits/stl_uninitialized.h:137:72: error: 'value' is not a member of 'std::is_constructible<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
  137 |       static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
      |                                                                        ^~~~~
[6/56] /usr/bin/c++  -Dmatrix_client_EXPORTS -I../include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wunreachable-code -DNDEBUG -fPIC   -pthread -std=c++17 -MD -MT CMakeFiles/matrix_client.dir/lib/http/session.cpp.o -MF CMakeFiles/matrix_client.dir/lib/http/session.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/http/session.cpp.o -c ../lib/http/session.cpp
FAILED: CMakeFiles/matrix_client.dir/lib/http/session.cpp.o 
/usr/bin/c++  -Dmatrix_client_EXPORTS -I../include -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection 		-Wall 		-Wextra 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wunreachable-code -DNDEBUG -fPIC   -pthread -std=c++17 -MD -MT CMakeFiles/matrix_client.dir/lib/http/session.cpp.o -MF CMakeFiles/matrix_client.dir/lib/http/session.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/http/session.cpp.o -c ../lib/http/session.cpp
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/memory:63,
                 from /usr/include/boost/asio/associated_allocator.hpp:19,
                 from /usr/include/boost/asio.hpp:20,
                 from ../include/mtxclient/http/session.hpp:3,
                 from ../lib/http/session.cpp:1:
/usr/include/c++/10/type_traits: In instantiation of 'struct std::is_constructible<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>':
/usr/include/nlohmann/json.hpp:11120:79:   required by substitution of 'template<class ... Args, typename std::enable_if<std::is_constructible<nlohmann::basic_json<>, Args ...>::value, int>::type <anonymous> > nlohmann::detail::json_ref<nlohmann::basic_json<> >::json_ref(Args&& ...) [with Args = {const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&}; typename std::enable_if<std::is_constructible<nlohmann::basic_json<>, Args ...>::value, int>::type <anonymous> = <missing>]'
/usr/include/c++/10/type_traits:901:30:   required from 'struct std::__is_constructible_impl<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
/usr/include/c++/10/type_traits:930:12:   required from 'struct std::__is_copy_constructible_impl<nlohmann::basic_json<>, true>'
/usr/include/c++/10/type_traits:936:12:   required from 'struct std::is_copy_constructible<nlohmann::basic_json<> >'
/usr/include/c++/10/type_traits:3111:33:   required from 'constexpr const bool std::is_copy_constructible_v<nlohmann::basic_json<> >'
/usr/include/c++/10/variant:294:5:   [ skipping 4 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/c++/10/bits/hashtable_policy.h:233:43:   required from 'struct std::__detail::_Hash_node_value_base<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > > >'
/usr/include/c++/10/bits/hashtable_policy.h:264:12:   required from 'struct std::__detail::_Hash_node<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >, true>'
/usr/include/c++/10/bits/hashtable_policy.h:1973:13:   required from 'struct std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >, true> > >'
/usr/include/c++/10/bits/hashtable.h:173:11:   required from 'class std::_Hashtable<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > > >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char> >, std::hash<std::__cxx11::basic_string<char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >'
/usr/include/c++/10/bits/unordered_map.h:105:18:   required from 'class std::unordered_map<std::__cxx11::basic_string<char>, std::variant<mtx::user_interactive::OAuth2Params, mtx::user_interactive::TermsParams, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >'
../include/mtx/user_interactive.hpp:78:46:   required from here
/usr/include/c++/10/type_traits:906:12: error: invalid use of incomplete type 'struct std::__is_constructible_impl<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
  906 |     struct is_constructible
      |            ^~~~~~~~~~~~~~~~
/usr/include/c++/10/type_traits:900:12: note: declaration of 'struct std::__is_constructible_impl<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
  900 |     struct __is_constructible_impl
      |            ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/memory:66,
                 from /usr/include/boost/asio/associated_allocator.hpp:19,
                 from /usr/include/boost/asio.hpp:20,
                 from ../include/mtxclient/http/session.hpp:3,
                 from ../lib/http/session.cpp:1:
/usr/include/c++/10/bits/stl_uninitialized.h: In instantiation of '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const nlohmann::basic_json<>*, std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >; _ForwardIterator = nlohmann::basic_json<>*]':
/usr/include/c++/10/bits/stl_uninitialized.h:325:37:   required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const nlohmann::basic_json<>*, std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >; _ForwardIterator = nlohmann::basic_json<>*; _Tp = nlohmann::basic_json<>]'
/usr/include/c++/10/bits/stl_vector.h:558:31:   required from 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = nlohmann::basic_json<>; _Alloc = std::allocator<nlohmann::basic_json<> >]'
/usr/include/c++/10/ext/new_allocator.h:150:4:   required from 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >; _Args = {const std::vector<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>, std::allocator<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >&}; _Tp = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >]'
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >; _Args = {const std::vector<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>, std::allocator<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer> > >&}; _Tp = std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > >; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >]'
/usr/include/nlohmann/json.hpp:15381:35:   [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/nlohmann/json.hpp:16365:25:   required from 'nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::basic_json(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]'
/usr/include/nlohmann/json.hpp:4737:31:   required from 'bool nlohmann::detail::json_sax_dom_callback_parser<BasicJsonType>::end_object() [with BasicJsonType = nlohmann::basic_json<>]'
/usr/include/nlohmann/json.hpp:8847:33:   required from 'bool nlohmann::detail::parser<BasicJsonType>::sax_parse_internal(SAX*) [with SAX = nlohmann::detail::json_sax_dom_callback_parser<nlohmann::basic_json<> >; BasicJsonType = nlohmann::basic_json<>]'
/usr/include/nlohmann/json.hpp:8738:31:   required from 'void nlohmann::detail::parser<BasicJsonType>::parse(bool, BasicJsonType&) [with BasicJsonType = nlohmann::basic_json<>]'
/usr/include/nlohmann/json.hpp:20882:79:   required from 'static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parse(IteratorType, IteratorType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t, bool) [with IteratorType = const char*; typename std::enable_if<std::is_base_of<std::random_access_iterator_tag, typename std::iterator_traits<_InputIterator>::iterator_category>::value, int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t = std::function<bool(int, nlohmann::detail::parser<nlohmann::basic_json<> >::parse_event_t, nlohmann::basic_json<>&)>]'
/usr/include/nlohmann/json.hpp:22700:42:   required from here
/usr/include/c++/10/bits/stl_uninitialized.h:137:72: error: 'value' is not a member of 'std::is_constructible<nlohmann::basic_json<>, const nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long int, long unsigned int, double, std::allocator, nlohmann::adl_serializer>&>'
  137 |       static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
      |                                                                        ^~~~~

Sync is broken and always use the same token

When using nheko-reborn with Gridepo over the C2S API r0.4.0, sync doesn't work as expected from an empty state and after creating a new room.

Steps to reproduce (Recording available here):

  1. Start the client with no prior session
  2. Login on the gridepo server
  3. Create a new room

Expected result: See the room appear and be able to use it
Experienced behaviour: Creating the room seems to work, including the notification of the room ID being created, but the room never show up.

Here are the requests made by the client and the answers.

  • After login:
GET /_matrix/client/r0/sync

{
  "next_batch": "0",
  "rooms": {
    "invite": {},
    "join": {},
    "leave": {}
  }
}

After creating the room:

GET /_matrix/client/r0/sync?since=0

{
  "next_batch": "1",
  "rooms": {
    "invite": {},
    "join": {
      "!AAAAAWjvv73vv71ONTg:gridepo.localhost": {
        "state": {
          "events": []
        },
        "timeline": {
          "events": [
            {
              "event_id": "$e21bfa442ad24a3297dd05a99bdc4c112DKE:gridepo.localhost",
              "type": "m.room.create",
              "origin_server_ts": 1552347320538,
              "channel_id": "#AAAAAWjvv73vv71ONThAZGFyay5sb2NhbC5tYXguZG9yaXVzLmlv",
              "room_id": "!AAAAAWjvv73vv71ONTg:gridepo.localhost",
              "sender": "@user1:gridepo.localhost",
              "state_key": "",
              "content": {
                "creator": "@user1:gridepo.localhost"
              }
            }
          ]
        },
        "invite_state": {
          "events": []
        }
      }
    },
    "leave": {}
  }
}

All subsequent sync requests:

GET /_matrix/client/r0/sync?since=0

{
  "next_batch": "3",
  "rooms": {
    "invite": {},
    "join": {
      "!AAAAAWjvv73vv71ONTg:gridepo.localhost": {
        "state": {
          "events": [
            {
              "event_id": "$e21bfa442ad24a3297dd05a99bdc4c112DKE:gridepo.localhost",
              "type": "m.room.create",
              "origin_server_ts": 1552347320538,
              "channel_id": "#AAAAAWjvv73vv71ONThAZGFyay5sb2NhbC5tYXguZG9yaXVzLmlv",
              "room_id": "!AAAAAWjvv73vv71ONTg:gridepo.localhost",
              "sender": "@user1:gridepo.localhost",
              "state_key": "",
              "content": {
                "creator": "@user1:gridepo.localhost"
              }
            }
          ]
        },
        "timeline": {
          "events": [
            {
              "event_id": "$68be95fd308241baa2692cecb72de6722Lf9:gridepo.localhost",
              "type": "m.room.member",
              "origin_server_ts": 1552347320558,
              "channel_id": "#AAAAAWjvv73vv71ONThAZGFyay5sb2NhbC5tYXguZG9yaXVzLmlv",
              "room_id": "!AAAAAWjvv73vv71ONTg:gridepo.localhost",
              "sender": "@user1:gridepo.localhost",
              "state_key": "@user1:gridepo.localhost",
              "content": {
                "action": "join",
                "membership": "join"
              }
            },
            {
              "event_id": "$0b21c32750de4fe99fa939b549d813e7yaR1:gridepo.localhost",
              "type": "m.room.power_levels",
              "origin_server_ts": 1552347320566,
              "channel_id": "#AAAAAWjvv73vv71ONThAZGFyay5sb2NhbC5tYXguZG9yaXVzLmlv",
              "room_id": "!AAAAAWjvv73vv71ONTg:gridepo.localhost",
              "sender": "@user1:gridepo.localhost",
              "state_key": "",
              "content": {
                "ban": 50.0,
                "invite": 0.0,
                "kick": 50.0,
                "state_default": 50.0,
                "events_default": 0.0,
                "users_default": 0.0,
                "users": {
                  "@user1:gridepo.localhost": 1000.0
                }
              }
            }
          ]
        },
        "invite_state": {
          "events": []
        }
      }
    },
    "leave": {}
  }
}

What I notice is that the very first sync next_token is used in all next requests, while any of the others next_token are not being used, requesting the same data over and over again without actually being able to process it it seems.

This is all the console output:

$ ./nheko-6f13b0d-x86_64.AppImage 
[2019-03-12 02:00:18.166] [ui] [info] jdenticon plugin not found.
[2019-03-12 02:00:18.211] [ui] [info] starting nheko 0.6.3-6f13b0d
[2019-03-12 02:00:34.385] [db] [info] initializing LMDB
[2019-03-12 02:00:34.394] [crypto] [info] creating new olm account
[2019-03-12 02:00:34.397] [crypto] [info] ed25519   : X5QRpwlQisGju5EmlrVm6oL/hMBVNgyRRCHjvGC1dbE
[2019-03-12 02:00:34.398] [crypto] [info] curve25519: j5e7nLR0fopAKPxo3sF5vYGYFOXydde3jQYzxANnQg0
[2019-03-12 02:00:34.398] [crypto] [info] generating one time keys
[2019-03-12 02:00:34.437] [net] [warning] skipping key uploading. server doesn't provide /keys/upload
[2019-03-12 02:00:34.437] [net] [info] trying initial sync
[2019-03-12 02:00:34.440] [net] [critical] failed to retrieve joined groups: -134099632 
[2019-03-12 02:00:34.456] [net] [info] initial sync completed
[2019-03-12 02:00:34.457] [ui] [info] initialize room list

Restarting the client, using the cache, also doesn't help:

$ Downloads/nheko-6f13b0d-x86_64.AppImage 
[2019-03-12 01:51:51.117] [db] [info] restoring state from cache
[2019-03-12 01:51:51.120] [ui] [info] jdenticon plugin not found.
[2019-03-12 01:51:51.133] [net] [critical] failed to retrieve joined groups: 268517296 
[2019-03-12 01:51:51.143] [db] [info] sessions restored
[2019-03-12 01:51:51.148] [db] [info] loading 0 rooms
[2019-03-12 01:51:51.149] [crypto] [info] ed25519   : MfYFoGHQvtixoE7pOSrrpmuqj7J4NjG+7XV6QX4kKDI
[2019-03-12 01:51:51.149] [crypto] [info] curve25519: RhTecg4Psr8gG2RXRVjavwXNZ9to3FfCCEF50IMWMVU
[2019-03-12 01:51:51.184] [ui] [info] starting nheko 0.6.3-6f13b0d
[2019-03-12 01:51:51.184] [ui] [info] initialize room list

It feels like there is an error processing the sync payload which is not logged or displayed, making the client loop forever.

Error while building on Archlinux

This might be related to my config, or something else. In any case, I prefer to leave a written trace of it.

It happened on both my computers, that were both Archlinux "pet" installs dating from 2018. I tried replicating that issue in a docker container, to no avail, even when installing every packet that was on my system.

I am not sure what I did on one of my systems to fix it. It might have involved playing with ccache, pacman, makepkg.conf, LC_ALL, etc. But it now works.

I've been unable to replicate the fix on my other computer, so I instead symlinked /usr/include to /include. That's a dirty workaround, but I'm fine with it for now.


This is the configure output:

-- Configuring done
CMake Error in CMakeLists.txt:
  Imported target "Boost::iostreams" includes non-existent path

    "/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
  * The path was deleted, renamed, or moved to another location.
  * An install or uninstall procedure did not complete successfully.
  * The installation package was faulty and references files it does not
  provide.



CMake Error in CMakeLists.txt:
  Imported target "Boost::iostreams" includes non-existent path

    "/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
  * The path was deleted, renamed, or moved to another location.
  * An install or uninstall procedure did not complete successfully.
  * The installation package was faulty and references files it does not
  provide.

Looking at the source, I find:

grep -R INTERFACE_INCLUDE .
./CMakeFiles/Export/lib/cmake/MatrixClient/MatrixClientTargets.cmake:  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/usr/include"
./MatrixClientTargets.cmake:  INTERFACE_INCLUDE_DIRECTORIES "/home/user/mtxclient-aur/src/mtxclient-0.3.1/include;/usr/include"

Which leads me to think that _IMPORT_PREFIX is set to "". As I didn't successfully override it with -D and didn't want to resort to temporary hacks in the source tree, I settled on the symlink workaround.


I'm writing this to document my issue in case someone ever encounters something similar, but I am going to close it as "can't reproduce", since that's what I've basically been told in the Matrix room.

PATCH: support location message type

Since I need the location messages and it was not implemented in the library so I decided to add this feature to the library. Please review this patch and apply it or let me know if there is any issue.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd49555..98ea974 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -234,6 +234,7 @@ target_sources(matrix_client
 	lib/structs/events/messages/emote.cpp
 	lib/structs/events/messages/file.cpp
 	lib/structs/events/messages/image.cpp
+	lib/structs/events/messages/location.cpp
 	lib/structs/events/messages/notice.cpp
 	lib/structs/events/messages/text.cpp
 	lib/structs/events/messages/video.cpp
diff --git a/include/mtx.hpp b/include/mtx.hpp
index 4eb600b..81e76ad 100644
--- a/include/mtx.hpp
+++ b/include/mtx.hpp
@@ -27,6 +27,7 @@
 #include "mtx/events/messages/emote.hpp"
 #include "mtx/events/messages/file.hpp"
 #include "mtx/events/messages/image.hpp"
+#include "mtx/events/messages/location.hpp"
 #include "mtx/events/messages/notice.hpp"
 #include "mtx/events/messages/text.hpp"
 #include "mtx/events/messages/video.hpp"
diff --git a/include/mtx/events/collections.hpp b/include/mtx/events/collections.hpp
index f48aed6..aad7832 100644
--- a/include/mtx/events/collections.hpp
+++ b/include/mtx/events/collections.hpp
@@ -42,6 +42,7 @@
 #include "mtx/events/messages/emote.hpp"
 #include "mtx/events/messages/file.hpp"
 #include "mtx/events/messages/image.hpp"
+#include "mtx/events/messages/location.hpp"
 #include "mtx/events/messages/notice.hpp"
 #include "mtx/events/messages/text.hpp"
 #include "mtx/events/messages/video.hpp"
@@ -168,7 +169,7 @@ using TimelineEvents =
                mtx::events::RoomEvent<mtx::events::msg::Emote>,
                mtx::events::RoomEvent<mtx::events::msg::File>,
                mtx::events::RoomEvent<mtx::events::msg::Image>,
-               // TODO: events::RoomEvent<mtx::events::msg::Location>,
+               mtx::events::RoomEvent<mtx::events::msg::Location>,
                mtx::events::RoomEvent<mtx::events::msg::Notice>,
                mtx::events::RoomEvent<mtx::events::msg::Text>,
                mtx::events::RoomEvent<mtx::events::msg::Video>,
@@ -225,6 +226,9 @@ template<>
 constexpr inline EventType message_content_to_type<mtx::events::msg::Image> =
   EventType::RoomMessage;
 template<>
+constexpr inline EventType message_content_to_type<mtx::events::msg::Location> =
+  EventType::RoomMessage;
+template<>
 constexpr inline EventType message_content_to_type<mtx::events::msg::Notice> =
   EventType::RoomMessage;
 template<>
diff --git a/include/mtx/events/common.hpp b/include/mtx/events/common.hpp
index 094be0e..20e8271 100644
--- a/include/mtx/events/common.hpp
+++ b/include/mtx/events/common.hpp
@@ -146,10 +146,10 @@ struct LocationInfo
     std::string blurhash;
 
     //! Deserialization method needed by @p nlohmann::json.
-    friend void from_json(const nlohmann::json &obj, ThumbnailInfo &info);
+    friend void from_json(const nlohmann::json &obj, LocationInfo &info);
 
     //! Serialization method needed by @p nlohmann::json.
-    friend void to_json(nlohmann::json &obj, const ThumbnailInfo &info);
+    friend void to_json(nlohmann::json &obj, const LocationInfo &info);
 };
 
 //! Definition of rel_type for relations.
diff --git a/include/mtxclient/http/client.hpp b/include/mtxclient/http/client.hpp
index 2ca1c7e..b8d25fa 100644
--- a/include/mtxclient/http/client.hpp
+++ b/include/mtxclient/http/client.hpp
@@ -884,6 +884,7 @@ MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::Audio)
 MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::Emote)
 MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::File)
 MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::Image)
+MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::Location)
 MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::Notice)
 MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::Text)
 MTXCLIENT_SEND_ROOM_MESSAGE_FWD(mtx::events::msg::Video)
diff --git a/lib/http/client.cpp b/lib/http/client.cpp
index 979e2d7..7751a27 100644
--- a/lib/http/client.cpp
+++ b/lib/http/client.cpp
@@ -1718,6 +1718,7 @@ MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::Audio)
 MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::Emote)
 MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::File)
 MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::Image)
+MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::Location)
 MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::Notice)
 MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::Text)
 MTXCLIENT_SEND_ROOM_MESSAGE(mtx::events::msg::Video)
diff --git a/lib/structs/events/collections.cpp b/lib/structs/events/collections.cpp
index 8211b75..f6e82ad 100644
--- a/lib/structs/events/collections.cpp
+++ b/lib/structs/events/collections.cpp
@@ -44,6 +44,7 @@ MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::Audio)
 MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::Emote)
 MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::File)
 MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::Image)
+MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::Location)
 MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::Notice)
 MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::Text)
 MTXCLIENT_INSTANTIATE_JSON_FUNCTIONS(events::RoomEvent, mtx::events::msg::Video)
@@ -298,8 +299,7 @@ from_json(const nlohmann::json &obj, TimelineEvent &e)
                 break;
             }
             case MsgType::Location: {
-                /* events::RoomEvent<events::msg::Location> location = e; */
-                /* container.emplace_back(location); */
+                e.data = events::RoomEvent<events::msg::Location>(obj);
                 break;
             }
             case MsgType::Notice: {
diff --git a/lib/structs/events/common.cpp b/lib/structs/events/common.cpp
index 9fb6f07..50dd712 100644
--- a/lib/structs/events/common.cpp
+++ b/lib/structs/events/common.cpp
@@ -169,6 +169,35 @@ to_json(json &obj, const VideoInfo &info)
         obj["xyz.amorgan.blurhash"] = info.blurhash;
 }
 
+void
+from_json(const json &obj, LocationInfo &info)
+{
+    if (obj.find("thumbnail_url") != obj.end())
+        info.thumbnail_url = obj.at("thumbnail_url").get<std::string>();
+
+    if (obj.find("thumbnail_info") != obj.end())
+        info.thumbnail_info = obj.at("thumbnail_info").get<ThumbnailInfo>();
+
+    if (obj.find("thumbnail_file") != obj.end())
+        info.thumbnail_file = obj.at("thumbnail_file").get<crypto::EncryptedFile>();
+
+    if (obj.find("xyz.amorgan.blurhash") != obj.end())
+        info.blurhash = obj.at("xyz.amorgan.blurhash").get<std::string>();
+}
+
+void
+to_json(json &obj, const LocationInfo &info)
+{
+    if (!info.thumbnail_url.empty()) {
+        obj["thumbnail_url"]  = info.thumbnail_url;
+        obj["thumbnail_info"] = info.thumbnail_info;
+    }
+    if (info.thumbnail_file)
+        obj["thumbnail_file"] = info.thumbnail_file.value();
+    if (!info.blurhash.empty())
+        obj["xyz.amorgan.blurhash"] = info.blurhash;
+}
+
 void
 to_json(json &obj, const RelationType &type)
 {
diff --git a/lib/structs/responses/common.cpp b/lib/structs/responses/common.cpp
index 79a0f4f..951696d 100644
--- a/lib/structs/responses/common.cpp
+++ b/lib/structs/responses/common.cpp
@@ -405,8 +405,7 @@ parse_timeline_events(const json &events,
                     break;
                 }
                 case MsgType::Location: {
-                    /* events::RoomEvent<events::msg::Location> location = e; */
-                    /* container.emplace_back(location); */
+                    container.emplace_back(events::RoomEvent<events::msg::Location>(e));
                     break;
                 }
                 case MsgType::Notice: {
diff --git a/meson.build b/meson.build
index 6984171..816de2d 100644
--- a/meson.build
+++ b/meson.build
@@ -82,6 +82,7 @@ src = [
 	'lib/structs/events/messages/emote.cpp',
 	'lib/structs/events/messages/file.cpp',
 	'lib/structs/events/messages/image.cpp',
+	'lib/structs/events/messages/location.cpp',
 	'lib/structs/events/messages/notice.cpp',
 	'lib/structs/events/messages/text.cpp',
 	'lib/structs/events/messages/video.cpp',
diff --git a/tests/messages.cpp b/tests/messages.cpp
index e9cc598..2c2581f 100644
--- a/tests/messages.cpp
+++ b/tests/messages.cpp
@@ -430,7 +430,53 @@ TEST(RoomEvents, ImageMessage)
               mtx::common::RelationType::InReplyTo);
 }
 
-TEST(RoomEvents, LocationMessage) {}
+TEST(RoomEvents, LocationMessage) {
+    json data = R"({
+            "content": {
+              "body": "Big Ben, London, UK",
+              "geo_uri": "geo:51.5008,0.1247",
+              "info": {
+                "thumbnail_info": {
+                  "h": 300,
+                  "mimetype": "image/jpeg",
+                  "size": 46144,
+                  "w": 300
+                },
+                "thumbnail_url": "mxc://matrix.org/FHyPlCeYUSFFxlgbQYZmoEoe"
+              },
+              "msgtype": "m.location",
+              "m.relates_to": {
+                    "m.in_reply_to": {
+                                    "event_id": "$6GKhAfJOcwNd69lgSizdcTob8z2pWQgBOZPrnsWMA1E"
+                                }
+                            }
+            },
+            "event_id": "$143273582443PhrSn:matrix.org",
+            "origin_server_ts": 1432735824653,
+            "room_id": "!jEsUZKDJdhlrceRyVU:matrix.org",
+            "sender": "@max:kamax.io",
+            "type": "m.room.message",
+            "unsigned": {
+              "age": 69168455
+            }
+          }
+        )"_json;
+    RoomEvent<msg::Location> event = data.get<RoomEvent<msg::Location>>();
+
+    EXPECT_EQ(event.type, EventType::RoomMessage);
+    EXPECT_EQ(event.event_id, "$143273582443PhrSn:matrix.org");
+    EXPECT_EQ(event.room_id, "!jEsUZKDJdhlrceRyVU:matrix.org");
+    EXPECT_EQ(event.sender, "@max:kamax.io");
+    EXPECT_EQ(event.origin_server_ts, 1432735824653);
+    EXPECT_EQ(event.unsigned_data.age, 69168455);
+    EXPECT_EQ(event.content.body,
+              "Big Ben, London, UK");
+    EXPECT_EQ(event.content.msgtype, "m.location");
+    EXPECT_EQ(event.content.relations.relations.at(0).event_id,
+              "$6GKhAfJOcwNd69lgSizdcTob8z2pWQgBOZPrnsWMA1E");
+    EXPECT_EQ(event.content.relations.relations.at(0).rel_type,
+              mtx::common::RelationType::InReplyTo);
+}
 
 TEST(RoomEvents, NoticeMessage)
 {
  • lib/structs/events/messages/location.cpp
#include <nlohmann/json.hpp>
#include <string>

#include "mtx/events/common.hpp"
#include "mtx/events/messages/location.hpp"

using json = nlohmann::json;

namespace mtx {
namespace events {
namespace msg {

void
from_json(const json &obj, Location &content)
{
    content.body    = obj.at("body").get<std::string>();
    content.msgtype = obj.at("msgtype").get<std::string>();
    if (obj.find("geo_uri") != obj.end())
        content.geo_uri = obj.at("geo_uri").get<std::string>();
    
    if (obj.find("info") != obj.end())
        content.info = obj.at("info").get<common::LocationInfo>();

    content.relations = common::parse_relations(obj);
}

void
to_json(json &obj, const Location &content)
{
    obj["msgtype"] = "m.location";
    obj["body"]    = content.body;
    
    obj["geo_uri"] = content.geo_uri;
    obj["info"]    = content.info;
    common::apply_relations(obj, content.relations);
}

} // namespace msg
} // namespace events
} // namespace mtx

nlohmann_json - WTH???

[ebuild N ~] dev-cpp/nlohmann_json-3.5.0::gentoo USE="-doc" 112106 KiB
What? json parser library 112 mb? Is it a joke?

Build breaks with nlohmann-json-3.11.1: multiple overloads of 'operator/=' instantiate to the same signature 'nlohmann::json_pointer<unsigned long> &(std::size_t)'

In file included from /wrkdirs/usr/ports/net-im/mtxclient/work/mtxclient-0.8.0/lib/structs/events/ephemeral/receipt.cpp:1:
In file included from /usr/local/include/nlohmann/json.hpp:50:
/usr/local/include/nlohmann/detail/json_pointer.hpp:116:19: error: multiple overloads of 'operator/=' instantiate to the same signature 'nlohmann::json_pointer<unsigned long> &(std::size_t)' (aka 'nlohmann::json_pointer<unsigned long> &(unsigned long)')
    json_pointer& operator/=(std::size_t array_idx)
                  ^
/wrkdirs/usr/ports/net-im/mtxclient/work/mtxclient-0.8.0/lib/structs/events/ephemeral/receipt.cpp:24:56: note: in instantiation of template class 'nlohmann::json_pointer<unsigned long>' requested here
                  userReceipts.value().value<uint64_t>("ts", 0);
                                                       ^
/wrkdirs/usr/ports/net-im/mtxclient/work/mtxclient-0.8.0/lib/structs/events/ephemeral/receipt.cpp:24:40: note: while substituting deduced template arguments into function template 'value' [with BasicJsonType = unsigned long]
                  userReceipts.value().value<uint64_t>("ts", 0);
                                       ^
/usr/local/include/nlohmann/detail/json_pointer.hpp:108:19: note: previous declaration is here
    json_pointer& operator/=(string_t token)
                  ^
/usr/local/include/nlohmann/detail/json_pointer.hpp:138:25: error: redefinition of 'operator/'
    friend json_pointer operator/(const json_pointer& lhs, std::size_t array_idx)
                        ^
/usr/local/include/nlohmann/detail/json_pointer.hpp:131:25: note: previous definition is here
    friend json_pointer operator/(const json_pointer& lhs, string_t token) // NOLINT(performance-unnecessary-value-param)
                        ^
2 errors generated.

Version: 0.8.0
FreeBSD 13.1

mtxclient does not build with fmt 11

mtxclient does not build with fmt 11.0.1.

[1/76] /home/ports/pobj/mtxclient-0.9.2/bin/c++ -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dmatrix_client_EXPORTS -I/home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/include -isystem /usr/local/include -O2 -pipe           -Wall          -Wextra          -Wconversion            -pipe           -pedantic               -fsized-deallocation            -fdiagnostics-color=always              -Wno-attributes                 -Wunreachable-code -DNDEBUG -std=c++20 -fPIC -pthread -Wno-float-conversion -Wno-implicit-float-conversion -Wno-implicit-int-float-conversion -Wno-unknown-warning-option -DNOMINMAX -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -MD -MT CMakeFiles/matrix_client.dir/lib/http/client.cpp.o -MF CMakeFiles/matrix_client.dir/lib/http/client.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/http/client.cpp.o -c /home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/lib/http/client.cpp
FAILED: CMakeFiles/matrix_client.dir/lib/http/client.cpp.o
/home/ports/pobj/mtxclient-0.9.2/bin/c++ -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dmatrix_client_EXPORTS -I/home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/include -isystem /usr/local/include -O2 -pipe          -Wall           -Wextra -Wconversion            -pipe           -pedantic               -fsized-deallocation            -fdiagnostics-color=always              -Wno-attributes                 -Wunreachable-code -DNDEBUG -std=c++20 -fPIC -pthread -Wno-float-conversion -Wno-implicit-float-conversion -Wno-implicit-int-float-conversion -Wno-unknown-warning-option -DNOMINMAX -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -MD -MT CMakeFiles/matrix_client.dir/lib/http/client.cpp.o -MF CMakeFiles/matrix_client.dir/lib/http/client.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/http/client.cpp.o -c /home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/lib/http/client.cpp
In file included from /home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/lib/http/client.cpp:1:
In file included from /home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/include/mtxclient/http/client.hpp:21:
In file included from /home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/include/mtxclient/http/errors.hpp:8:
In file included from /usr/local/include/spdlog/common.h:50:
In file included from /usr/local/include/spdlog/fmt/fmt.h:28:
In file included from /usr/local/include/fmt/core.h:5:
In file included from /usr/local/include/fmt/format.h:41:
/usr/local/include/fmt/base.h:1392:23: error: no matching member function for call to 'format'
    ctx.advance_to(cf.format(*static_cast<qualified_type*>(arg), ctx));
                   ~~~^~~~~~
/usr/local/include/fmt/base.h:1373:21: note: in instantiation of function template specialization 'fmt::detail::value<fmt::context>::format_custom_arg<std::optional<mtx::http::ClientError>, fmt::formatter<std::optional<mtx::http::ClientError>>>' requested here
    custom.format = format_custom_arg<
                    ^
/usr/local/include/spdlog/logger.h:80:9: note: in instantiation of function template specialization 'spdlog::logger::log_<const std::optional<mtx::http::ClientError> &>' requested here
        log_(loc, lvl, details::to_string_view(fmt), std::forward<Args>(args)...);
        ^
/usr/local/include/spdlog/logger.h:85:9: note: in instantiation of function template specialization 'spdlog::logger::log<const std::optional<mtx::http::ClientError> &>' requested here
        log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
        ^
/usr/local/include/spdlog/logger.h:135:9: note: in instantiation of function template specialization 'spdlog::logger::log<const std::optional<mtx::http::ClientError> &>' requested here
        log(level::debug, fmt, std::forward<Args>(args)...);
        ^
/home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/lib/http/client.cpp:1004:43: note: in instantiation of function template specialization 'spdlog::logger::debug<const std::optional<mtx::http::ClientError> &>' requested here
                  mtx::utils::log::log()->debug("{}", e);
                                          ^
/home/ports/pobj/mtxclient-0.9.2/mtxclient-0.9.2/include/mtxclient/http/errors.hpp:135:10: note: candidate function template not viable: 'this' argument has type 'const fmt::formatter<std::optional<mtx::http::ClientError>>', but method is not marked const
    auto format(std::optional<mtx::http::ClientError> c, FormatContext &ctx)
         ^
1 error generated.
ninja: build stopped: subcommand failed.

GCC 13 build failure

Build failure under GCC 13:

[1/76] /usr/bin/g++ -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dmatrix_client_EXPORTS -I/builddir/build/BUILD/mtxclient-0.9.1/include -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -U_FORTIFY_SOURCE -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer 		-Wall 		-Wextra 		-Wconversion 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -DNDEBUG -fPIC -pthread -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -std=c++20 -MD -MT CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o -MF CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o -c /builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp
FAILED: CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o 
/usr/bin/g++ -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dmatrix_client_EXPORTS -I/builddir/build/BUILD/mtxclient-0.9.1/include -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -U_FORTIFY_SOURCE -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer 		-Wall 		-Wextra 		-Wconversion 		-pipe 		-pedantic 		-fsized-deallocation 		-fdiagnostics-color=always 		-Wno-attributes 		-Wunreachable-code -DNDEBUG -fPIC -pthread -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -std=c++20 -MD -MT CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o -MF CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o.d -o CMakeFiles/matrix_client.dir/lib/crypto/encoding.cpp.o -c /builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:33:22: error: 'uint8_t' was not declared in this scope
   33 | constexpr std::array<uint8_t, 256>
      |                      ^~~~~~~
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:6:1: note: 'uint8_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
    5 | #include <vector>
  +++ |+#include <cstdint>
    6 | 
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:33:34: error: template argument 1 is invalid
   33 | constexpr std::array<uint8_t, 256>
      |                                  ^
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:33:16: error: '<expression error>' in namespace 'std' does not name a type
   33 | constexpr std::array<uint8_t, 256>
      |                ^~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:48:59: error: 'invert_alphabet' was not declared in this scope; did you mean 'base64_alphabet'?
   48 | static constexpr const std::array base64_to_int         = invert_alphabet(base64_alphabet);
      |                                                           ^~~~~~~~~~~~~~~
      |                                                           base64_alphabet
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:49:59: error: 'invert_alphabet' was not declared in this scope; did you mean 'base64_alphabet'?
   49 | static constexpr const std::array base64_urlsafe_to_int = invert_alphabet(base64_urlsafe_alphabet);
      |                                                           ^~~~~~~~~~~~~~~
      |                                                           base64_alphabet
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:50:59: error: 'invert_alphabet' was not declared in this scope; did you mean 'base64_alphabet'?
   50 | static constexpr const std::array base58_to_int         = invert_alphabet(base58_alphabet);
      |                                                           ^~~~~~~~~~~~~~~
      |                                                           base64_alphabet
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp: In function 'std::string {anonymous}::encode_base58(const std::array<char, 58>&, const std::string&)':
/builddir/build/BUILD/mtxclient-0.9.1/lib/crypto/encoding.cpp:64:17: error: 'uint8_t' was not declared in this scope

Fix:

#include <vector>
+#include <cstdint>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.