libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
accountdataevents.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2018 Kitsune Ral <kitsune-ral@users.sf.net>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include "event.h"
7
8#include "../csapi/definitions/tag.h"
9
10namespace Quotient {
11constexpr inline auto FavouriteTag = "m.favourite"_L1;
12constexpr inline auto LowPriorityTag = "m.lowpriority"_L1;
13constexpr inline auto ServerNoticeTag = "m.server_notice"_L1;
14
15inline std::partial_ordering operator<=>(
16 const Tag& lhs, const Tag& rhs) // clazy:exclude=function-args-by-value
17{
18 // Per The Spec, rooms with no order should be after those with order,
19 // against std::optional<>::operator<=>() convention.
20 return (lhs.order && !rhs.order) ? std::partial_ordering::less
21 : (!lhs.order && rhs.order) ? std::partial_ordering::greater
22 : *lhs.order <=> *rhs.order;
23}
24
25inline bool operator==(const Tag& lhs, const Tag& rhs) // clazy:exclude=function-args-by-value
26{
27 return std::is_eq(lhs <=> rhs);
28}
29
30using TagsMap = QHash<QString, Tag>;
31
32DEFINE_SIMPLE_EVENT(TagEvent, Event, "m.tag", TagsMap, tags, "tags")
33DEFINE_SIMPLE_EVENT(ReadMarkerEvent, Event, "m.fully_read", QString,
34 eventId, "event_id")
35DEFINE_SIMPLE_EVENT(IgnoredUsersEvent, Event, "m.ignored_user_list",
36 QSet<QString>, ignoredUsers, "ignored_users")
37} // namespace Quotient
#define DEFINE_SIMPLE_EVENT(Name_, Base_, TypeId_, ValueType_, GetterName_, JsonKey_)
Define a new event class with a single key-value pair in the content.
Definition event.h:463