diff --git a/src/API.php b/src/API.php index 30cc00a..a07f722 100644 --- a/src/API.php +++ b/src/API.php @@ -5,6 +5,7 @@ namespace Slack; use Illuminate\Support\Arr; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Log; +use Slack\Response\Chat; use Slack\Exceptions\{SlackAlreadyPinnedException, SlackChannelNotFoundException, SlackException, @@ -83,8 +84,9 @@ class API /** * Get Messages on a channel from a specific timestamp * - * @param $channel - * @param $timestamp + * @param $channel + * @param $timestamp + * @param int $limit * @return Generic * @throws \Exception */ @@ -126,16 +128,16 @@ class API /** * Get all messages from a thread * - * @param $channel - * @param $thread_ts - * @return Generic + * @param string $channel + * @param string $thread_ts + * @return Chat * @throws \Exception */ - public function getMessageHistory($channel,$thread_ts): Generic + public function getMessageHistory(string $channel,string $thread_ts): Chat { Log::debug(sprintf('%s:Get Message Threads for Message [%s] on Channel [%s]',static::LOGKEY,$thread_ts,$channel),['m'=>__METHOD__]); - return new Generic($this->execute('conversations.replies',['channel'=>$channel,'ts'=>$thread_ts])); + return new Chat($this->execute('conversations.replies',['channel'=>$channel,'ts'=>$thread_ts])); } /** diff --git a/src/Listeners/AppHomeOpenedListener.php b/src/Listeners/AppHomeOpenedListener.php index aca56b7..85a9318 100644 --- a/src/Listeners/AppHomeOpenedListener.php +++ b/src/Listeners/AppHomeOpenedListener.php @@ -10,7 +10,7 @@ use Slack\Event\AppHomeOpened; class AppHomeOpenedListener implements ShouldQueue { - private const LOGKEY = 'LAH'; + protected const LOGKEY = 'LAH'; public $queue = 'high'; diff --git a/src/Listeners/ChannelJoinListener.php b/src/Listeners/ChannelJoinListener.php index b35c88d..2c5de0d 100644 --- a/src/Listeners/ChannelJoinListener.php +++ b/src/Listeners/ChannelJoinListener.php @@ -9,7 +9,7 @@ use Slack\Event\MemberJoinedChannel; class ChannelJoinListener implements ShouldQueue { - private const LOGKEY = 'LCJ'; + protected const LOGKEY = 'LCJ'; public $queue = 'high'; diff --git a/src/Listeners/ChannelLeftListener.php b/src/Listeners/ChannelLeftListener.php index fc1a086..cde19e5 100644 --- a/src/Listeners/ChannelLeftListener.php +++ b/src/Listeners/ChannelLeftListener.php @@ -9,7 +9,7 @@ use Slack\Event\{Base,ChannelLeft,GroupLeft}; class ChannelLeftListener implements ShouldQueue { - private const LOGKEY = 'LCL'; + protected const LOGKEY = 'LCL'; public $queue = 'high'; diff --git a/src/Listeners/InteractiveMessageListener.php b/src/Listeners/InteractiveMessageListener.php index 24e23b5..e7e33e2 100644 --- a/src/Listeners/InteractiveMessageListener.php +++ b/src/Listeners/InteractiveMessageListener.php @@ -9,7 +9,7 @@ use Slack\Interactive\InteractiveMessage; class InteractiveMessageListener implements ShouldQueue { - private const LOGKEY = 'LIM'; + protected const LOGKEY = 'LIM'; public $queue = 'high'; diff --git a/src/Listeners/MessageListener.php b/src/Listeners/MessageListener.php index d9afced..81fd117 100644 --- a/src/Listeners/MessageListener.php +++ b/src/Listeners/MessageListener.php @@ -9,7 +9,7 @@ use Slack\Event\Message; class MessageListener implements ShouldQueue { - private const LOGKEY = 'LM-'; + protected const LOGKEY = 'LM-'; public $queue = 'high'; diff --git a/src/Listeners/PinAddedListener.php b/src/Listeners/PinAddedListener.php index 1926b8a..dad96a8 100644 --- a/src/Listeners/PinAddedListener.php +++ b/src/Listeners/PinAddedListener.php @@ -9,7 +9,7 @@ use Slack\Event\PinAdded; class PinAddedListener implements ShouldQueue { - private const LOGKEY = 'LPA'; + protected const LOGKEY = 'LPA'; public $queue = 'high'; diff --git a/src/Listeners/PinRemovedListener.php b/src/Listeners/PinRemovedListener.php index c6c27f8..4a6dc79 100644 --- a/src/Listeners/PinRemovedListener.php +++ b/src/Listeners/PinRemovedListener.php @@ -9,7 +9,7 @@ use Slack\Event\PinRemoved; class PinRemovedListener implements ShouldQueue { - private const LOGKEY = 'LPR'; + protected const LOGKEY = 'LPR'; public $queue = 'high'; diff --git a/src/Listeners/ReactionAddedListener.php b/src/Listeners/ReactionAddedListener.php index 48e1770..1a57175 100644 --- a/src/Listeners/ReactionAddedListener.php +++ b/src/Listeners/ReactionAddedListener.php @@ -9,7 +9,7 @@ use Slack\Event\ReactionAdded; class ReactionAddedListener implements ShouldQueue { - private const LOGKEY = 'LRA'; + protected const LOGKEY = 'LRA'; public $queue = 'high'; diff --git a/src/Listeners/ShortcutListener.php b/src/Listeners/ShortcutListener.php index 7d4d6c8..18529e4 100644 --- a/src/Listeners/ShortcutListener.php +++ b/src/Listeners/ShortcutListener.php @@ -10,7 +10,7 @@ use Slack\Message; class ShortcutListener //implements ShouldQueue { - private const LOGKEY = 'LSC'; + protected const LOGKEY = 'LSC'; // Block actions arent queued, since slack expects a response to the request //public $queue = 'high'; diff --git a/src/Listeners/ViewClosedListener.php b/src/Listeners/ViewClosedListener.php index b708f5f..89195f6 100644 --- a/src/Listeners/ViewClosedListener.php +++ b/src/Listeners/ViewClosedListener.php @@ -9,7 +9,7 @@ use Slack\Interactive\ViewClosed; class ViewClosedListener implements ShouldQueue { - private const LOGKEY = 'LVC'; + protected const LOGKEY = 'LVC'; public $queue = 'high'; diff --git a/src/Listeners/ViewSubmissionListener.php b/src/Listeners/ViewSubmissionListener.php index fdb8ec0..412d9cb 100644 --- a/src/Listeners/ViewSubmissionListener.php +++ b/src/Listeners/ViewSubmissionListener.php @@ -9,7 +9,7 @@ use Slack\Interactive\ViewSubmission; class ViewSubmissionListener implements ShouldQueue { - private const LOGKEY = 'LVC'; + protected const LOGKEY = 'LVC'; public $queue = 'high'; diff --git a/src/Response/Base.php b/src/Response/Base.php index 5aac955..c3303f0 100644 --- a/src/Response/Base.php +++ b/src/Response/Base.php @@ -50,10 +50,12 @@ class Base extends SlackBase implements \JsonSerializable // For interactive post responses, the channel ID is "channel" return object_get($this->_data,$key) ?: object_get($this->_data,'channel'); + case 'messages': // Used by getMessageHistory() + return collect(object_get($this->_data,$key)); + case 'team_id': case 'ts': case 'user_id': - case 'messages': // Used by getMessageHistory() case 'type': // Needed by URL verification return object_get($this->_data,$key); } diff --git a/src/Response/Chat.php b/src/Response/Chat.php new file mode 100644 index 0000000..74ba1cc --- /dev/null +++ b/src/Response/Chat.php @@ -0,0 +1,49 @@ +messages->skip(1); + } + + public function reply_count(): int + { + return $this->messages->first()->reply_count; + } + + public function user_count(): int + { + return $this->messages->first()->reply_users_count; + } +}