summary refs log tree commit diff
path: root/src/CacheStructs.h
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-02-28 19:10:39 -0500
committerGitHub <noreply@github.com>2020-02-28 19:10:39 -0500
commit30cb7c5b02bb8a21a8d7257cfe5a8bd3db891606 (patch)
treeddadd16c86600ce937b47798a9b3d5ff2fdec998 /src/CacheStructs.h
parentMerge pull request #129 from nico202/master (diff)
parentMerge branch 'master' into 0.7.0-dev (diff)
downloadnheko-30cb7c5b02bb8a21a8d7257cfe5a8bd3db891606.tar.xz
Merge pull request #130 from Nheko-Reborn/0.7.0-dev
0.7.0 dev merge to master
Diffstat (limited to 'src/CacheStructs.h')
-rw-r--r--src/CacheStructs.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/CacheStructs.h b/src/CacheStructs.h
new file mode 100644

index 00000000..2051afc8 --- /dev/null +++ b/src/CacheStructs.h
@@ -0,0 +1,91 @@ +#pragma once + +#include <QDateTime> +#include <QImage> +#include <QString> + +#include <string> + +#include <mtx/events/join_rules.hpp> + +struct RoomMember +{ + QString user_id; + QString display_name; + QImage avatar; +}; + +struct SearchResult +{ + QString user_id; + QString display_name; +}; + +//! Used to uniquely identify a list of read receipts. +struct ReadReceiptKey +{ + std::string event_id; + std::string room_id; +}; + +void +to_json(nlohmann::json &j, const ReadReceiptKey &key); + +void +from_json(const nlohmann::json &j, ReadReceiptKey &key); + +struct DescInfo +{ + QString event_id; + QString userid; + QString body; + QString timestamp; + QDateTime datetime; +}; + +//! UI info associated with a room. +struct RoomInfo +{ + //! The calculated name of the room. + std::string name; + //! The topic of the room. + std::string topic; + //! The calculated avatar url of the room. + std::string avatar_url; + //! The calculated version of this room set at creation time. + std::string version; + //! Whether or not the room is an invite. + bool is_invite = false; + //! Total number of members in the room. + int16_t member_count = 0; + //! Who can access to the room. + mtx::events::state::JoinRule join_rule = mtx::events::state::JoinRule::Public; + bool guest_access = false; + //! Metadata describing the last message in the timeline. + DescInfo msgInfo; + //! The list of tags associated with this room + std::vector<std::string> tags; +}; + +void +to_json(nlohmann::json &j, const RoomInfo &info); +void +from_json(const nlohmann::json &j, RoomInfo &info); + +//! Basic information per member; +struct MemberInfo +{ + std::string name; + std::string avatar_url; +}; + +void +to_json(nlohmann::json &j, const MemberInfo &info); +void +from_json(const nlohmann::json &j, MemberInfo &info); + +struct RoomSearchResult +{ + std::string room_id; + RoomInfo info; +};