matrixion/src/EventAccessors.h

108 lines
2.8 KiB
C
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
2019-12-27 23:49:55 +03:00
#pragma once
#include <string>
#include <QDateTime>
#include <QString>
#include <mtx/events/collections.hpp>
namespace nheko {
struct nonesuch
{
~nonesuch() = delete;
nonesuch(nonesuch const &) = delete;
void operator=(nonesuch const &) = delete;
};
namespace detail {
template<class Default, class AlwaysVoid, template<class...> class Op, class... Args>
struct detector
{
using value_t = std::false_type;
using type = Default;
};
template<class Default, template<class...> class Op, class... Args>
struct detector<Default, std::void_t<Op<Args...>>, Op, Args...>
{
using value_t = std::true_type;
using type = Op<Args...>;
};
} // namespace detail
}
2019-12-27 23:49:55 +03:00
namespace mtx::accessors {
std::string
event_id(const mtx::events::collections::TimelineEvents &event);
std::string
room_id(const mtx::events::collections::TimelineEvents &event);
std::string
sender(const mtx::events::collections::TimelineEvents &event);
2021-02-01 00:41:43 +03:00
bool
is_state_event(const mtx::events::collections::TimelineEvents &event);
2019-12-27 23:49:55 +03:00
QDateTime
origin_server_ts(const mtx::events::collections::TimelineEvents &event);
std::string
filename(const mtx::events::collections::TimelineEvents &event);
mtx::events::MessageType
msg_type(const mtx::events::collections::TimelineEvents &event);
std::string
room_name(const mtx::events::collections::TimelineEvents &event);
std::string
room_topic(const mtx::events::collections::TimelineEvents &event);
2020-07-24 20:30:12 +03:00
std::string
call_type(const mtx::events::collections::TimelineEvents &event);
2019-12-27 23:49:55 +03:00
std::string
body(const mtx::events::collections::TimelineEvents &event);
std::string
formatted_body(const mtx::events::collections::TimelineEvents &event);
QString
formattedBodyWithFallback(const mtx::events::collections::TimelineEvents &event);
std::optional<mtx::crypto::EncryptedFile>
file(const mtx::events::collections::TimelineEvents &event);
std::string
url(const mtx::events::collections::TimelineEvents &event);
std::string
thumbnail_url(const mtx::events::collections::TimelineEvents &event);
std::string
blurhash(const mtx::events::collections::TimelineEvents &event);
std::string
2019-12-27 23:49:55 +03:00
mimetype(const mtx::events::collections::TimelineEvents &event);
2021-01-27 00:36:35 +03:00
mtx::common::Relations
relations(const mtx::events::collections::TimelineEvents &event);
2021-01-27 18:14:03 +03:00
void
set_relations(mtx::events::collections::TimelineEvents &event, mtx::common::Relations relations);
2020-07-20 01:42:48 +03:00
std::string
transaction_id(const mtx::events::collections::TimelineEvents &event);
2019-12-27 23:49:55 +03:00
int64_t
filesize(const mtx::events::collections::TimelineEvents &event);
uint64_t
media_height(const mtx::events::collections::TimelineEvents &event);
uint64_t
media_width(const mtx::events::collections::TimelineEvents &event);
2020-05-30 17:37:51 +03:00
nlohmann::json
serialize_event(const mtx::events::collections::TimelineEvents &event);
2019-12-27 23:49:55 +03:00
}