Add __set method to Job and auto-initialize _data, update Message to check for a Team if the message is being used in a slack API
This commit is contained in:
parent
905c207956
commit
1529f470fa
@ -7,6 +7,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
abstract class Job implements ShouldQueue
|
||||
{
|
||||
@ -23,14 +24,20 @@ abstract class Job implements ShouldQueue
|
||||
|
||||
use InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $_data = [];
|
||||
protected Collection $_data;
|
||||
|
||||
public function __get($key)
|
||||
{
|
||||
if (! isset($this->_data))
|
||||
$this->_data = collect();
|
||||
|
||||
return Arr::get($this->_data,$key);
|
||||
}
|
||||
|
||||
public function __set(string $key,$value) {
|
||||
if (! isset($this->_data))
|
||||
$this->_data = collect();
|
||||
|
||||
return $this->_data->put($key,$value);
|
||||
}
|
||||
}
|
@ -160,6 +160,9 @@ final class Message extends BlockKit
|
||||
if ($this->_data->get('blocks') && $this->_data->get('attachments'))
|
||||
throw new SlackSyntaxException('Message cannot have blocks and attachments.');
|
||||
|
||||
if ((! isset($this->o)) || (! $this->o->team))
|
||||
throw new SlackSyntaxException('Message needs to have a user or a channel to work out the team.');
|
||||
|
||||
$api = $this->o->team->slackAPI();
|
||||
|
||||
if ($this->ephemeral) {
|
||||
|
Loading…
Reference in New Issue
Block a user