diff options
Diffstat (limited to 'src/Events')
| -rw-r--r-- | src/Events/Event.php | 20 | ||||
| -rw-r--r-- | src/Events/PresenceEvent.php | 40 | ||||
| -rw-r--r-- | src/Events/RoomMemberEvent.php | 36 | ||||
| -rw-r--r-- | src/Events/RoomMessageEvent.php | 86 | ||||
| -rw-r--r-- | src/Events/RoomNameEvent.php | 33 |
5 files changed, 0 insertions, 215 deletions
diff --git a/src/Events/Event.php b/src/Events/Event.php deleted file mode 100644 index 7dbf242..0000000 --- a/src/Events/Event.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -namespace App\Events; - -use App\Types\EventType; - -abstract class Event -{ - public function __construct( - protected EventType $type, - ) - {} - - abstract public function fromJson(string $json): self; - - /** - * @return array<string, mixed> - */ - abstract public function toJsonEncodeable(): array; -} diff --git a/src/Events/PresenceEvent.php b/src/Events/PresenceEvent.php deleted file mode 100644 index cd230c5..0000000 --- a/src/Events/PresenceEvent.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -namespace App\Events; - -use App\Types\EventType; -use App\Types\PresenceState; - -class PresenceEvent extends Event -{ - public function __construct( - private string $sender, - private string $avatarUrl = "mxc://localhost/wefuiwegh8742w", - private int $lastActiveAgo = 1234, - private bool $currentlyActive = false, - private PresenceState $presence = PresenceState::ONLINE, - private string $statusMessage = "", - ) - { - parent::__construct(EventType::PRESENCE); - } - - public function fromJson(string $json): self - { - } - - public function toJsonEncodeable(): array - { - return [ - "type" => $this->type, - "sender" => $this->sender, - "content" => [ - "avatar_url" => $this->avatarUrl, - "currently_active" => $this->currentlyActive, - "last_active_ago" => $this->lastActiveAgo, - "presence" => $this->presence, - "status_msg" => $this->statusMessage, - ], - ]; - } -} diff --git a/src/Events/RoomMemberEvent.php b/src/Events/RoomMemberEvent.php deleted file mode 100644 index 79ba0cc..0000000 --- a/src/Events/RoomMemberEvent.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace App\Events; - -use App\Types\EventType; -use App\Types\MembershipState; - -class RoomMemberEvent extends Event -{ - public function __construct( - private string $sender, - private string $stateKey, - private MembershipState $membership, - ) - { - parent::__construct(EventType::ROOM_MEMBER); - } - - public function fromJson(string $json): self - { - } - - public function toJsonEncodeable(): array - { - return [ - "type" => $this->type, - "sender" => $this->sender, - "state_key" => $this->stateKey, - "event_id" => "\$0", - "origin_server_ts" => time(), - "content" => [ - "membership" => $this->membership, - ], - ]; - } -} diff --git a/src/Events/RoomMessageEvent.php b/src/Events/RoomMessageEvent.php deleted file mode 100644 index 3ccc408..0000000 --- a/src/Events/RoomMessageEvent.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -namespace App\Events; - -use App\Database; -use App\Support\ConnectsToDatabase; -use App\Types\EventType; -use App\Types\MembershipState; -use App\Types\MessageType; - -class RoomMessageEvent extends Event implements ConnectsToDatabase -{ - public function __construct( - private string $id = "", - private string $sender = "", - private \DateTime $originServerTimestamp = new \DateTime("now"), - private array $content = [], - private array $unsigned = [], - private string $roomId = "", - ) - { - parent::__construct(EventType::ROOM_MESSAGE); - } - - public function fromJson(string $json): self - { - } - - public function toJsonEncodeable(): array - { - return [ - "type" => $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( - <<<SQL - insert into room_events (id, type, sender, origin_server_timestamp, content, unsigned, room_id) - values (:id, :type, :sender, to_timestamp(:origin_server_timestamp), :content, :unsigned, :room_id) - SQL, - [ - "id" => $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 - { - } -} diff --git a/src/Events/RoomNameEvent.php b/src/Events/RoomNameEvent.php deleted file mode 100644 index 279e6c1..0000000 --- a/src/Events/RoomNameEvent.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -namespace App\Events; - -use App\Types\EventType; - -class RoomNameEvent extends Event -{ - public function __construct( - private string $sender, - private string $stateKey, - private string $name, - ) - { - parent::__construct(EventType::ROOM_NAME); - } - - public function fromJson(string $json): self - { - } - - public function toJsonEncodeable(): array - { - return [ - "type" => $this->type, - "sender" => $this->sender, - "state_key" => $this->stateKey, - "content" => [ - "name" => $this->name, - ], - ]; - } -} |
