libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
roompowerlevelsevent.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include "stateevent.h"
7
8namespace Quotient {
9
11 // See https://spec.matrix.org/v1.11/client-server-api/#mroompower_levels for the defaults
12
13 int invite = 0;
14 int kick = 50;
15 int ban = 50;
16
17 int redact = 50;
18
21 int stateDefault = 50;
22
24 int usersDefault = 0;
25
27 int room = 50;
28 };
30};
31
32template <>
36};
37
40public:
41 QUO_EVENT(RoomPowerLevelsEvent, "m.room.power_levels")
42
44
45 int invite() const { return content().invite; }
46 int kick() const { return content().kick; }
47 int ban() const { return content().ban; }
48
49 int redact() const { return content().redact; }
50
51 QHash<QString, int> events() const { return content().events; }
52 int eventsDefault() const { return content().eventsDefault; }
53 int stateDefault() const { return content().stateDefault; }
54
55 QHash<QString, int> users() const { return content().users; }
56 int usersDefault() const { return content().usersDefault; }
57
58 int roomNotification() const { return content().notifications.room; }
59
60 //! \brief Get the power level for message events of a given type
61 //!
62 //! \note You normally should not compare power levels returned from this
63 //! and other powerLevelFor*() functions directly; use
64 //! Room::canSendEvents() instead
66
67 //! \brief Get the power level for state events of a given type
68 //!
69 //! \note You normally should not compare power levels returned from this
70 //! and other powerLevelFor*() functions directly; use
71 //! Room::canSetState() instead
73
74 //! \brief Get the power level for a given user
75 //!
76 //! \note You normally should not directly use power levels returned by this
77 //! and other powerLevelFor*() functions; use Room API instead
78 //! \sa Room::canSend, Room::canSendEvents, Room::canSetState,
79 //! Room::effectivePowerLevel
80 int powerLevelForUser(const QString& userId) const;
81
82 template <EventClass EvT>
84 {
85 if constexpr (std::is_base_of_v<StateEvent, EvT>) {
87 } else {
89 }
90 }
91};
92
93} // namespace Quotient
#define QUO_EVENT(CppType_, MatrixType_)
Supply event metatype information in (specific) event types.
Definition event.h:436
#define QUOTIENT_API