Skip to content

Commit

Permalink
Add ReplyMessage event
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveRandom committed May 30, 2016
1 parent 1efbdde commit b94afbb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Chat/Event/Factory.php
Expand Up @@ -19,6 +19,7 @@ class Factory
StarMessage::TYPE_ID => StarMessage::class,
MentionMessage::TYPE_ID => MentionMessage::class,
DeleteMessage::TYPE_ID => DeleteMessage::class,
ReplyMessage::TYPE_ID => ReplyMessage::class,
];

/**
Expand Down
31 changes: 31 additions & 0 deletions src/Chat/Event/ReplyMessage.php
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);

namespace Room11\Jeeves\Chat\Event;

use Room11\Jeeves\Chat\Room\Room as ChatRoom;

class ReplyMessage extends MessageEvent
{
const TYPE_ID = 18;

private $parentId;
private $showParent;

public function __construct(array $data, ChatRoom $room)
{
parent::__construct($data, $room);

$this->parentId = $data['parent_id'] ?? 0;
$this->showParent = $data['show_parent'] ?? false;
}

public function getParentId(): int
{
return $this->parentId;
}

public function shouldShowParent(): bool
{
return $this->showParent;
}
}
3 changes: 2 additions & 1 deletion src/Chat/Message/Factory.php
Expand Up @@ -4,6 +4,7 @@

use Room11\Jeeves\Chat\Event\MentionMessage;
use Room11\Jeeves\Chat\Event\MessageEvent;
use Room11\Jeeves\Chat\Event\ReplyMessage;

class Factory
{
Expand All @@ -13,7 +14,7 @@ public function build(MessageEvent $event): Message
return new Command($event, $event->getRoom());
}

if ($event instanceof MentionMessage) {
if ($event instanceof MentionMessage || $event instanceof ReplyMessage) {
return new Conversation($event, $event->getRoom());
}

Expand Down

0 comments on commit b94afbb

Please sign in to comment.