libQuotient
A Qt library for building matrix clients
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 
10 namespace Quotient {
11 constexpr inline auto FavouriteTag = "m.favourite"_L1;
12 constexpr inline auto LowPriorityTag = "m.lowpriority"_L1;
13 constexpr inline auto ServerNoticeTag = "m.server_notice"_L1;
14 
15 using TagRecord [[deprecated("Use Tag from csapi/definitions/tag.h instead")]] = Tag;
16 
17 inline std::partial_ordering operator<=>(
18  const Tag& lhs, const Tag& rhs) // clazy:exclude=function-args-by-value
19 {
20  // Per The Spec, rooms with no order should be after those with order,
21  // against std::optional<>::operator<=>() convention.
22  return (lhs.order && !rhs.order) ? std::partial_ordering::less
23  : (!lhs.order && rhs.order) ? std::partial_ordering::greater
24  : *lhs.order <=> *rhs.order;
25 }
26 
27 inline bool operator==(const Tag& lhs, const Tag& rhs) // clazy:exclude=function-args-by-value
28 {
29  return std::is_eq(lhs <=> rhs);
30 }
31 
32 using TagsMap = QHash<QString, Tag>;
33 
34 DEFINE_SIMPLE_EVENT(TagEvent, Event, "m.tag", TagsMap, tags, "tags")
35 DEFINE_SIMPLE_EVENT(ReadMarkerEvent, Event, "m.fully_read", QString,
36  eventId, "event_id")
37 DEFINE_SIMPLE_EVENT(IgnoredUsersEvent, Event, "m.ignored_user_list",
38  QSet<QString>, ignoredUsers, "ignored_users")
39 } // namespace Quotient