From 2ae0c2fa2a0bb5a7cd1fd9da1c6d2a6090126e67 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 19 Sep 2025 14:29:17 +0200 Subject: sending messages creates message event in database --- src/Events/RoomMessageEvent.php | 86 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/Events/RoomMessageEvent.php (limited to 'src/Events/RoomMessageEvent.php') diff --git a/src/Events/RoomMessageEvent.php b/src/Events/RoomMessageEvent.php new file mode 100644 index 0000000..3ccc408 --- /dev/null +++ b/src/Events/RoomMessageEvent.php @@ -0,0 +1,86 @@ + $this->type, + "sender" => $this->sender, + "event_id" => $this->id, + "origin_server_ts" => $this->originServerTimestamp->format("U.v"), + "content" => [ + "body" => $this->body, + "msgtype" => MessageType::TEXT, + ], + "unsigned" => [ + "age" => 1234, + "membership" => MembershipState::JOIN, + ], + "room_id" => $this->roomId, + ]; + } + + public static function fromDatabase(array $row): self + { + } + + public static function fetch(): ?self + { + } + + public static function fetchAll(): array + { + } + + public function insert(): bool + { + return !! Database::getInstance()->query( + << $this->id, + "type" => $this->type->value, + "sender" => $this->sender, + "origin_server_timestamp" => (new \DateTime("now"))->format("U.v"), + "content" => json_encode($this->content), + "unsigned" => json_encode($this->unsigned), + "room_id" => $this->roomId, + ] + ); + } + + public function update(): bool + { + } + + public function delete(): bool + { + } +} -- cgit v1.2.3