1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QDateTime>
#include <QImage>
#include <QString>
#include <string>
#include <mtx/events/join_rules.hpp>
#include <mtx/events/mscs/image_packs.hpp>
namespace cache {
enum class CacheVersion : int
{
Older = -1,
Current = 0,
Newer = 1,
};
}
struct RoomMember
{
QString user_id;
QString display_name;
QString avatar_url;
bool is_direct = false;
};
//! 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 descriptiveTime;
uint64_t timestamp = 0;
QDateTime datetime;
};
inline bool
operator==(const DescInfo &a, const DescInfo &b)
{
return std::tie(a.timestamp, a.event_id, a.userid, a.body, a.descriptiveTime) ==
std::tie(b.timestamp, b.event_id, b.userid, b.body, b.descriptiveTime);
}
inline bool
operator!=(const DescInfo &a, const DescInfo &b)
{
return std::tie(a.timestamp, a.event_id, a.userid, a.body, a.descriptiveTime) !=
std::tie(b.timestamp, b.event_id, b.userid, b.body, b.descriptiveTime);
}
//! 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;
//! Wheter or not the room is a space
bool is_space = false;
//! Wheter or not the room has a tombstone event
bool is_tombstoned = false;
//! Total number of members in the room.
size_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;
//! The list of tags associated with this room
std::vector<std::string> tags;
//! An approximate timestamp of when the last message was sent in the room.
//! Use the TimelineModel::lastMessage for an accurate timestamp.
uint64_t approximate_last_modification_ts = 0;
uint64_t highlight_count = 0;
uint64_t notification_count = 0;
};
void
to_json(nlohmann::json &j, const RoomInfo &info);
void
from_json(const nlohmann::json &j, RoomInfo &info);
//! A plain struct with roomid, name and alias used for filling the room completer.
struct RoomNameAlias
{
std::string id, name, alias;
std::uint64_t recent_activity;
bool is_tombstoned;
bool is_space;
};
//! Basic information per member.
struct MemberInfo
{
std::string name;
std::string avatar_url;
std::string inviter = "";
std::string reason = "";
bool is_direct = false;
};
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;
};
struct ImagePackInfo
{
mtx::events::msc2545::ImagePack pack;
std::string source_room;
std::string state_key;
bool from_space = false;
};
|