summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/Message
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2026-03-05 14:57:28 +0100
committerDaniel Weipert <git@mail.dweipert.de>2026-03-05 14:57:28 +0100
commitbd11271621bd3759cfd194ed0119c0dc28155fd0 (patch)
tree319b4790d4e2b05513abf023732ed6fb0717f603 /matrix-specification/Events/Message
parent2386148b8f048ba40d9f26cc97898bdcdc778ea2 (diff)
updateHEADmain
Diffstat (limited to 'matrix-specification/Events/Message')
-rw-r--r--matrix-specification/Events/Message/FormattedMessageEvent.php39
-rw-r--r--matrix-specification/Events/Message/MessageEvent.php35
-rw-r--r--matrix-specification/Events/Message/TextMessageEvent.php38
3 files changed, 112 insertions, 0 deletions
diff --git a/matrix-specification/Events/Message/FormattedMessageEvent.php b/matrix-specification/Events/Message/FormattedMessageEvent.php
new file mode 100644
index 0000000..92e73a1
--- /dev/null
+++ b/matrix-specification/Events/Message/FormattedMessageEvent.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Matrix\Events\Message;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\MessageFormat;
+use Matrix\Enums\MessageType;
+
+class FormattedMessageEvent extends MessageEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $body,
+ MessageType $msgtype,
+ ?MessageFormat $format = null,
+ ?string $formattedBody = null,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "body" => $body,
+ "format" => $format,
+ "formatted_body" => $formattedBody,
+ "msgtype" => $msgtype,
+ ], fn ($value) => ! is_null($value)),
+ $eventId,
+ $originServerTimestamp,
+ $roomId,
+ $sender,
+ EventType::ROOM_MESSAGE,
+ $unsigned,
+ );
+ }
+}
diff --git a/matrix-specification/Events/Message/MessageEvent.php b/matrix-specification/Events/Message/MessageEvent.php
new file mode 100644
index 0000000..c06475b
--- /dev/null
+++ b/matrix-specification/Events/Message/MessageEvent.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Matrix\Events\Message;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\MessageType;
+use Matrix\Events\ClientEvent;
+
+class MessageEvent extends ClientEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $body,
+ MessageType $msgtype,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "body" => $body,
+ "msgtype" => $msgtype,
+ ], fn ($value) => ! is_null($value)),
+ $eventId,
+ $originServerTimestamp,
+ $roomId,
+ $sender,
+ EventType::ROOM_MESSAGE,
+ $unsigned,
+ );
+ }
+}
diff --git a/matrix-specification/Events/Message/TextMessageEvent.php b/matrix-specification/Events/Message/TextMessageEvent.php
new file mode 100644
index 0000000..f51317e
--- /dev/null
+++ b/matrix-specification/Events/Message/TextMessageEvent.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Matrix\Events\Message;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\MessageFormat;
+use Matrix\Enums\MessageType;
+
+class TextMessageEvent extends FormattedMessageEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $body,
+ ?MessageFormat $format = null,
+ ?string $formattedBody = null,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "body" => $body,
+ "format" => $format,
+ "formatted_body" => $formattedBody,
+ "msgtype" => MessageType::TEXT,
+ ], fn ($value) => ! is_null($value)),
+ $eventId,
+ $originServerTimestamp,
+ $roomId,
+ $sender,
+ EventType::ROOM_MESSAGE,
+ $unsigned,
+ );
+ }
+}