Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1f4c5c9774 | ||
|
67f78b2f5d | ||
|
6c6d32b4eb | ||
|
1923f4486b |
@ -430,7 +430,7 @@ final class API
|
|||||||
|
|
||||||
case 'hash_conflict':
|
case 'hash_conflict':
|
||||||
if (App::environment() == 'local')
|
if (App::environment() == 'local')
|
||||||
file_put_contents('/tmp/hash_conflict.'.$method,print_r(json_decode(json_decode($parameters)->view),TRUE));
|
file_put_contents('/tmp/hash_conflict.'.$method,print_r($response,TRUE));
|
||||||
|
|
||||||
throw new SlackHashConflictException('Hash Conflict',$request->status());
|
throw new SlackHashConflictException('Hash Conflict',$request->status());
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ abstract class Base
|
|||||||
if (! $o->exists) {
|
if (! $o->exists) {
|
||||||
$o->team_id = $this->enterprise_id ? NULL : $this->team()->id;
|
$o->team_id = $this->enterprise_id ? NULL : $this->team()->id;
|
||||||
$o->enterprise_id = ($x=$this->enterprise())->exists ? $x->id : NULL;
|
$o->enterprise_id = ($x=$this->enterprise())->exists ? $x->id : NULL;
|
||||||
$o->active = TRUE;
|
$o->active = FALSE;
|
||||||
$o->save();
|
$o->save();
|
||||||
|
|
||||||
Log::debug(sprintf('%s: User Created in DB [%s] (%s)',self::LOGKEY,$this->user_id,$o->id));
|
Log::debug(sprintf('%s: User Created in DB [%s] (%s)',self::LOGKEY,$this->user_id,$o->id));
|
||||||
|
@ -67,7 +67,7 @@ final class MultiStaticSelect extends Element
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initial_options(array $initial=NULL): self
|
public function initial_options(Collection $initial=NULL): self
|
||||||
{
|
{
|
||||||
// No initial options.
|
// No initial options.
|
||||||
if (count($initial)) {
|
if (count($initial)) {
|
||||||
@ -77,7 +77,7 @@ final class MultiStaticSelect extends Element
|
|||||||
if (count($initial) > self::MAX_OPTIONS)
|
if (count($initial) > self::MAX_OPTIONS)
|
||||||
throw new SlackSyntaxException(sprintf('Can only have maximum %d options',self::MAX_OPTIONS));
|
throw new SlackSyntaxException(sprintf('Can only have maximum %d options',self::MAX_OPTIONS));
|
||||||
|
|
||||||
$this->initial_options = $this->options->filter(function($item) use ($initial) { return in_array($item['value'],$initial); });
|
$this->initial_options = $this->options->filter(function($item) use ($initial) { return $initial->contains($item['value']); });
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -89,7 +89,7 @@ final class Modal extends BlockKit
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear_on_close(bool $bool): self
|
public function clear_on_close(bool $bool=TRUE): self
|
||||||
{
|
{
|
||||||
if ($this->type != 'modal')
|
if ($this->type != 'modal')
|
||||||
throw new SlackSyntaxException(sprintf('clear_on_close is not required for %s',$this->type));
|
throw new SlackSyntaxException(sprintf('clear_on_close is not required for %s',$this->type));
|
||||||
@ -136,7 +136,7 @@ final class Modal extends BlockKit
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notify_on_close(bool $bool): self
|
public function notify_on_close(bool $bool=TRUE): self
|
||||||
{
|
{
|
||||||
if ($this->type != 'modal')
|
if ($this->type != 'modal')
|
||||||
throw new SlackSyntaxException(sprintf('notify_on_close is not required for %s',$this->type));
|
throw new SlackSyntaxException(sprintf('notify_on_close is not required for %s',$this->type));
|
||||||
|
@ -20,7 +20,7 @@ class BlockActionListener //implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected const LOGKEY = 'LBA';
|
protected const LOGKEY = 'LBA';
|
||||||
|
|
||||||
public $queue = 'slack';
|
// public $queue = 'slack';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
|
@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Http;
|
|||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
use Slack\Blockkit\Blocks;
|
use Slack\Blockkit\Blocks;
|
||||||
use Slack\Blockkit\Blocks\Context;
|
use Slack\Blockkit\Blocks\{Context,Divider,Section};
|
||||||
use Slack\Blockkit\Blocks\Elements\Text;
|
use Slack\Blockkit\Blocks\Elements\Text;
|
||||||
use Slack\Exceptions\{SlackException,SlackSyntaxException};
|
use Slack\Exceptions\{SlackException,SlackSyntaxException};
|
||||||
use Slack\Jobs\{DeleteChat,DeleteResponse};
|
use Slack\Jobs\{DeleteChat,DeleteResponse};
|
||||||
@ -124,6 +124,14 @@ final class Message extends BlockKit
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a helper method
|
||||||
|
public function divider(): self
|
||||||
|
{
|
||||||
|
$this->blocks->push(Divider::item());
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function forgetTS(): self
|
public function forgetTS(): self
|
||||||
{
|
{
|
||||||
$this->_data->forget('ts');
|
$this->_data->forget('ts');
|
||||||
@ -162,9 +170,6 @@ final class Message extends BlockKit
|
|||||||
if (! $delete && $this->selfdestruct)
|
if (! $delete && $this->selfdestruct)
|
||||||
$delete = $this->selfdestruct;
|
$delete = $this->selfdestruct;
|
||||||
|
|
||||||
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) && (! $this->o->user_team)))
|
if ((! isset($this->o)) || ((! $this->o->team) && (! $this->o->user_team)))
|
||||||
throw new SlackSyntaxException('Message needs to have a user or a channel to work out the team.');
|
throw new SlackSyntaxException('Message needs to have a user or a channel to work out the team.');
|
||||||
|
|
||||||
@ -178,10 +183,18 @@ final class Message extends BlockKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
Log::debug(sprintf('%s:Scheduling Delete of [%s:%s] on [%s]',static::LOGKEY,object_get($this->o,'channel_id',$this->o->id),$response->ts,$delete->format('Y-m-d')),['m'=>__METHOD__]);
|
Log::debug(sprintf('%s:Scheduling Delete of [%s:%s] on [%s]',static::LOGKEY,object_get($this->o,'channel_id',$this->o->id),$response->ts,$delete->format('Y-m-d H:i')),['m'=>__METHOD__,'r'=>$response,'message_ts'=>$response->ts]);
|
||||||
|
|
||||||
// Queue the delete of the message if requested
|
if ($this->o instanceof User) {
|
||||||
dispatch((new DeleteChat($this->o,$response->ts))->onQueue('slack')->delay($delete));
|
Log::error(sprintf('%s:Cannot schedule delete of [%s:%s] on user channels [%s]',static::LOGKEY,object_get($this->o,'channel_id',$this->o->id),$response->ts,$this->o->user_id),['m'=>__METHOD__]);
|
||||||
|
|
||||||
|
} elseif ($this->ephemeral) {
|
||||||
|
Log::error(sprintf('%s:Ignoring delete of [%s:%s] on ephemeral messages',static::LOGKEY,object_get($this->o,'channel_id',$this->o->id),$response->ts),['m'=>__METHOD__]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Queue the delete of the message if requested
|
||||||
|
dispatch((new DeleteChat($this->o,$response->ts))->onQueue('slack')->delay($delete));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
@ -250,6 +263,7 @@ final class Message extends BlockKit
|
|||||||
*
|
*
|
||||||
* @param Carbon $time
|
* @param Carbon $time
|
||||||
* @return Message
|
* @return Message
|
||||||
|
* @throws SlackSyntaxException
|
||||||
*/
|
*/
|
||||||
public function selfdestruct(Carbon $time): self
|
public function selfdestruct(Carbon $time): self
|
||||||
{
|
{
|
||||||
@ -292,6 +306,14 @@ final class Message extends BlockKit
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a helper method
|
||||||
|
public function spacer(): self
|
||||||
|
{
|
||||||
|
$this->blocks->push(Section::item(Text::item(' ')));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/* CONFIGURATION METHODS */
|
/* CONFIGURATION METHODS */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -396,6 +418,25 @@ final class Message extends BlockKit
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post the message to user
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function user(string $user): self
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set bot username (used with as_user)
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
public function username(string $user): self
|
public function username(string $user): self
|
||||||
{
|
{
|
||||||
$this->username = $user;
|
$this->username = $user;
|
||||||
|
@ -4,9 +4,9 @@ namespace Slack\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use Slack\Traits\ScopeActive;
|
||||||
|
|
||||||
use App\Models\Slack\Team as AppTeam;
|
use App\Models\Slack\Team as AppTeam;
|
||||||
use Slack\Traits\ScopeActive;
|
|
||||||
|
|
||||||
class Channel extends Model
|
class Channel extends Model
|
||||||
{
|
{
|
||||||
|
@ -55,8 +55,9 @@ abstract class Base extends SlackBase implements \JsonSerializable
|
|||||||
case 'scheduled_messages': // Used by scheduledMessagesList()
|
case 'scheduled_messages': // Used by scheduledMessagesList()
|
||||||
return collect(object_get($this->_data,$key));
|
return collect(object_get($this->_data,$key));
|
||||||
|
|
||||||
case 'team_id':
|
|
||||||
case 'ts':
|
case 'ts':
|
||||||
|
return object_get($this->_data,$key) ?: object_get($this->_data,'message_ts');
|
||||||
|
case 'team_id':
|
||||||
case 'user_id':
|
case 'user_id':
|
||||||
case 'type': // Needed by URL verification
|
case 'type': // Needed by URL verification
|
||||||
return object_get($this->_data,$key);
|
return object_get($this->_data,$key);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user