2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2021-03-05 02:35:15 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2019-12-15 01:39:02 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <mtx/events/join_rules.hpp>
|
2021-07-19 04:02:30 +03:00
|
|
|
#include <mtx/events/mscs/image_packs.hpp>
|
2019-12-15 01:39:02 +03:00
|
|
|
|
2020-05-02 17:44:50 +03:00
|
|
|
namespace cache {
|
|
|
|
enum class CacheVersion : int
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Older = -1,
|
|
|
|
Current = 0,
|
|
|
|
Newer = 1,
|
2020-05-02 17:44:50 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-12-15 01:39:02 +03:00
|
|
|
struct RoomMember
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
QString user_id;
|
|
|
|
QString display_name;
|
2021-11-21 09:06:37 +03:00
|
|
|
bool is_direct = false;
|
2019-12-15 01:39:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//! Used to uniquely identify a list of read receipts.
|
|
|
|
struct ReadReceiptKey
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
std::string event_id;
|
|
|
|
std::string room_id;
|
2019-12-15 01:39:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2020-01-30 01:39:05 +03:00
|
|
|
to_json(nlohmann::json &j, const ReadReceiptKey &key);
|
2019-12-15 01:39:02 +03:00
|
|
|
|
|
|
|
void
|
2020-01-30 01:39:05 +03:00
|
|
|
from_json(const nlohmann::json &j, ReadReceiptKey &key);
|
2019-12-15 01:39:02 +03:00
|
|
|
|
|
|
|
struct DescInfo
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
QString event_id;
|
|
|
|
QString userid;
|
|
|
|
QString body;
|
|
|
|
QString descriptiveTime;
|
2022-06-15 03:13:17 +03:00
|
|
|
uint64_t timestamp = 0;
|
2021-09-18 01:22:33 +03:00
|
|
|
QDateTime datetime;
|
2019-12-15 01:39:02 +03:00
|
|
|
};
|
|
|
|
|
2021-05-21 22:19:03 +03:00
|
|
|
inline bool
|
|
|
|
operator==(const DescInfo &a, const DescInfo &b)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
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);
|
2021-05-21 22:19:03 +03:00
|
|
|
}
|
|
|
|
inline bool
|
|
|
|
operator!=(const DescInfo &a, const DescInfo &b)
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
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);
|
2021-05-21 22:19:03 +03:00
|
|
|
}
|
|
|
|
|
2019-12-15 01:39:02 +03:00
|
|
|
//! UI info associated with a room.
|
|
|
|
struct RoomInfo
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
//! 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;
|
|
|
|
//! 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;
|
2022-04-13 21:40:00 +03:00
|
|
|
|
2022-06-15 03:13:17 +03:00
|
|
|
//! 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;
|
|
|
|
|
2022-10-26 02:10:35 +03:00
|
|
|
uint64_t highlight_count = 0;
|
|
|
|
uint64_t notification_count = 0;
|
2019-12-15 01:39:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2020-01-30 01:39:05 +03:00
|
|
|
to_json(nlohmann::json &j, const RoomInfo &info);
|
2019-12-15 01:39:02 +03:00
|
|
|
void
|
2020-01-30 01:39:05 +03:00
|
|
|
from_json(const nlohmann::json &j, RoomInfo &info);
|
2019-12-15 01:39:02 +03:00
|
|
|
|
2021-03-27 02:22:51 +03:00
|
|
|
//! Basic information per member.
|
2019-12-15 01:39:02 +03:00
|
|
|
struct MemberInfo
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
std::string name;
|
|
|
|
std::string avatar_url;
|
2022-12-27 03:40:03 +03:00
|
|
|
std::string reason;
|
2021-11-21 09:06:37 +03:00
|
|
|
bool is_direct = false;
|
2019-12-15 01:39:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2020-01-30 01:39:05 +03:00
|
|
|
to_json(nlohmann::json &j, const MemberInfo &info);
|
2019-12-15 01:39:02 +03:00
|
|
|
void
|
2020-01-30 01:39:05 +03:00
|
|
|
from_json(const nlohmann::json &j, MemberInfo &info);
|
2019-12-15 01:39:02 +03:00
|
|
|
|
|
|
|
struct RoomSearchResult
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
std::string room_id;
|
|
|
|
RoomInfo info;
|
2019-12-15 01:39:02 +03:00
|
|
|
};
|
2021-07-19 04:02:30 +03:00
|
|
|
|
|
|
|
struct ImagePackInfo
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
mtx::events::msc2545::ImagePack pack;
|
|
|
|
std::string source_room;
|
|
|
|
std::string state_key;
|
2022-09-01 14:25:11 +03:00
|
|
|
bool from_space = false;
|
2021-07-19 04:02:30 +03:00
|
|
|
};
|