| 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 | |
| 8 | namespace Quotient { |
| 9 | struct QUOTIENT_API PowerLevelsEventContent { |
| 10 | struct Notifications { |
| 11 | int room; |
| 12 | }; |
| 13 | |
| 14 | explicit PowerLevelsEventContent(const QJsonObject& json); |
| 15 | QJsonObject toJson() const; |
| 16 | |
| 17 | int invite; |
| 18 | int kick; |
| 19 | int ban; |
| 20 | |
| 21 | int redact; |
| 22 | |
| 23 | QHash<QString, int> events; |
| 24 | int eventsDefault; |
| 25 | int stateDefault; |
| 26 | |
| 27 | QHash<QString, int> users; |
| 28 | int usersDefault; |
| 29 | |
| 30 | Notifications notifications; |
| 31 | }; |
| 32 | |
| 33 | class QUOTIENT_API RoomPowerLevelsEvent |
| 34 | : public KeylessStateEventBase<RoomPowerLevelsEvent, PowerLevelsEventContent> { |
| 35 | public: |
| 36 | QUO_EVENT(RoomPowerLevelsEvent, "m.room.power_levels") |
| 37 | |
| 38 | using KeylessStateEventBase::KeylessStateEventBase; |
| 39 | |
| 40 | int invite() const { return content().invite; } |
| 41 | int kick() const { return content().kick; } |
| 42 | int ban() const { return content().ban; } |
| 43 | |
| 44 | int redact() const { return content().redact; } |
| 45 | |
| 46 | QHash<QString, int> events() const { return content().events; } |
| 47 | int eventsDefault() const { return content().eventsDefault; } |
| 48 | int stateDefault() const { return content().stateDefault; } |
| 49 | |
| 50 | QHash<QString, int> users() const { return content().users; } |
| 51 | int usersDefault() const { return content().usersDefault; } |
| 52 | |
| 53 | int roomNotification() const { return content().notifications.room; } |
| 54 | |
| 55 | int powerLevelForEvent(const QString& eventTypeId) const; |
| 56 | int powerLevelForState(const QString& eventTypeId) const; |
| 57 | int powerLevelForUser(const QString& userId) const; |
| 58 | }; |
| 59 | } // namespace Quotient |
| 60 |