summary refs log tree commit diff
path: root/src/EventAccessors.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-10-08 20:08:38 +0200
committerGitHub <noreply@github.com>2020-10-08 20:08:38 +0200
commit517a126a4427972668a97b21fc8684f7160976b9 (patch)
tree27142d719f848abe685897cd367e8d69a9bed719 /src/EventAccessors.cpp
parentMerge pull request #294 from trilene/master (diff)
parentTry to fix windows build (diff)
downloadnheko-517a126a4427972668a97b21fc8684f7160976b9.tar.xz
Merge pull request #270 from Chethan2k1/device-verification
Device verification and Cross-Signing
Diffstat (limited to 'src/EventAccessors.cpp')
-rw-r--r--src/EventAccessors.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp

index 88612b14..b62be9a5 100644 --- a/src/EventAccessors.cpp +++ b/src/EventAccessors.cpp
@@ -39,8 +39,15 @@ struct EventMsgType template<class T> mtx::events::MessageType operator()(const mtx::events::Event<T> &e) { - if constexpr (is_detected<msgtype_t, T>::value) - return mtx::events::getMessageType(e.content.msgtype); + if constexpr (is_detected<msgtype_t, T>::value) { + if constexpr (std::is_same_v<std::optional<std::string>, + std::remove_cv_t<decltype(e.content.msgtype)>>) + return mtx::events::getMessageType(e.content.msgtype.value()); + else if constexpr (std::is_same_v< + std::string, + std::remove_cv_t<decltype(e.content.msgtype)>>) + return mtx::events::getMessageType(e.content.msgtype); + } return mtx::events::MessageType::Unknown; } }; @@ -97,8 +104,15 @@ struct EventBody template<class T> std::string operator()(const mtx::events::Event<T> &e) { - if constexpr (is_detected<body_t, T>::value) - return e.content.body; + if constexpr (is_detected<body_t, T>::value) { + if constexpr (std::is_same_v<std::optional<std::string>, + std::remove_cv_t<decltype(e.content.body)>>) + return e.content.body ? e.content.body.value() : ""; + else if constexpr (std::is_same_v< + std::string, + std::remove_cv_t<decltype(e.content.body)>>) + return e.content.body; + } return ""; } };