summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/Room/PowerLevelsEvent.php
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Events/Room/PowerLevelsEvent.php')
-rw-r--r--matrix-specification/Events/Room/PowerLevelsEvent.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/matrix-specification/Events/Room/PowerLevelsEvent.php b/matrix-specification/Events/Room/PowerLevelsEvent.php
new file mode 100644
index 0000000..8b609f3
--- /dev/null
+++ b/matrix-specification/Events/Room/PowerLevelsEvent.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class PowerLevelsEvent extends StateEvent
+{
+ /**
+ * @param ?array<string, int> $events This is a mapping from event type to power level required.
+ * @param ?array<string, int> $notifications This is a mapping from key to power level for that notifications key.
+ * @param ?array<string, int> $events This is a mapping from user_id to power level for that user.
+ */
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ ?int $ban = 50,
+ ?array $events = null,
+ ?int $eventsDefault = 0,
+ ?int $invite = 0,
+ ?int $kick = 50,
+ ?array $notifications = null, # TODO: https://spec.matrix.org/v1.17/client-server-api/#mroompower_levels_notifications
+ ?int $redact = 50,
+ ?int $stateDefault = 50,
+ ?array $users = null,
+ ?int $usersDefault = 0,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "ban" => $ban,
+ "events" => $events,
+ "events_default" => $eventsDefault,
+ "invite" => $invite,
+ "kick" => $kick,
+ "notifications" => $notifications,
+ "redact" => $redact,
+ "state_default" => $stateDefault,
+ "users" => $users,
+ "users_default" => $usersDefault,
+ ], fn ($value) => ! is_null($value)),
+ $eventId,
+ $originServerTimestamp,
+ $roomId,
+ $sender,
+ $stateKey,
+ EventType::ROOM_POWER_LEVELS,
+ $unsigned,
+ );
+ }
+}