Consistent use of LOGKEY and make classes final where there downstream app shouldnt override them

This commit is contained in:
Deon George 2022-08-24 14:02:22 +10:00
parent 5f14be0cae
commit 8c4f3413f2
36 changed files with 195 additions and 51 deletions

View File

@ -9,7 +9,7 @@ use App\Http\Controllers\Controller;
use Slack\Client\Payload;
use Slack\Event\Factory as SlackEventFactory;
class EventsController extends Controller
final class EventsController extends Controller
{
private const LOGKEY = 'CEC';

View File

@ -10,7 +10,7 @@ use Slack\Client\Payload;
use Slack\Message;
use Slack\Interactive\Factory as InteractiveMessageFactory;
class InteractiveMessageController extends Controller
final class InteractiveMessageController extends Controller
{
private const LOGKEY = 'CIM';

View File

@ -9,7 +9,7 @@ use App\Http\Controllers\Controller;
use Slack\Client\Payload;
use Slack\Options\Factory as SlackOptionsFactory;
class InteractiveOptionsController extends Controller
final class InteractiveOptionsController extends Controller
{
private const LOGKEY = 'CIO';

View File

@ -12,7 +12,7 @@ use Slack\Command\Factory;
use Slack\Message;
use Slack\Message\Attachment;
class SlashCommandController extends Controller
final class SlashCommandController extends Controller
{
private const LOGKEY = 'CSC';

View File

@ -11,7 +11,7 @@ use Slack\Event\Factory as EventFactory;
use Slack\Interactive\Factory as InteractiveFactory;
use Slack\Options\Factory as OptionsFactory;
class CheckRequest
final class CheckRequest
{
private const LOGKEY = 'MCR';

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Log;
use Slack\Base;
class CheckSignature
final class CheckSignature
{
private const LOGKEY = 'MCS';
@ -67,4 +67,4 @@ class CheckSignature
return $next($request);
}
}
}

View File

@ -55,7 +55,7 @@ use Slack\Models\Channel;
* )
* )
*/
class BlockActions extends Base
final class BlockActions extends Base
{
private const LOGKEY = 'IBA';

View File

@ -2,24 +2,24 @@
namespace Slack\Interactive;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;
use Slack\Client\Payload;
class Factory {
private const LOGKEY = 'SIF';
protected const LOGKEY = 'SIF';
/**
* @var array event type to event class mapping
*/
public const map = [
'block_actions' => BlockActions::class,
//'interactive_message' => InteractiveMessage::class,
'interactive_message' => InteractiveMessage::class,
'shortcut' => Shortcut::class,
'view_closed' => ViewClosed::class,
//'view_submission' => ViewSubmission::class,
'view_submission' => ViewSubmission::class,
];
/**

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Log;
*
* @package Slack\Interactive
*/
class Unknown extends Base
final class Unknown extends Base
{
public function __construct(array $request)
{

View File

@ -65,7 +65,7 @@ use Illuminate\Support\Arr;
*/
class ViewClosed extends Base
{
private const LOGKEY = 'IVC';
protected const LOGKEY = 'IVC';
public function __get($key)
{

View File

@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Log;
use Slack\Models\{Channel,User};
use Slack\Exceptions\SlackException;
class DeleteChat extends Job
final class DeleteChat extends Job
{
private const LOGKEY = 'JDC';

View File

@ -9,7 +9,7 @@ use Slack\Models\Team;
class TeamUpdate extends Job
{
private const LOGKEY = 'JTU';
protected const LOGKEY = 'JTU';
/**
* Create a new job instance.

View File

@ -12,7 +12,7 @@ class AppHomeOpenedListener implements ShouldQueue
{
protected const LOGKEY = 'LAH';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -12,7 +12,7 @@ use Slack\Interactive\BlockActions;
* It's expected that the local application would implement this class completely, rather than using this
* modules implementation.
*/
abstract class BlockActionListener
class BlockActionListener
{
protected const LOGKEY = 'LBA';

View File

@ -11,7 +11,7 @@ class ChannelJoinListener implements ShouldQueue
{
protected const LOGKEY = 'LCJ';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class ChannelLeftListener implements ShouldQueue
{
protected const LOGKEY = 'LCL';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class InteractiveMessageListener implements ShouldQueue
{
protected const LOGKEY = 'LIM';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class MessageListener implements ShouldQueue
{
protected const LOGKEY = 'LM-';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class PinAddedListener implements ShouldQueue
{
protected const LOGKEY = 'LPA';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class PinRemovedListener implements ShouldQueue
{
protected const LOGKEY = 'LPR';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class ReactionAddedListener implements ShouldQueue
{
protected const LOGKEY = 'LRA';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -14,8 +14,7 @@ class ShortcutListener //implements ShouldQueue
{
protected const LOGKEY = 'LSC';
// Block actions arent queued, since slack expects a response to the request
//public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class ViewClosedListener implements ShouldQueue
{
protected const LOGKEY = 'LVC';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -11,7 +11,7 @@ class ViewSubmissionListener implements ShouldQueue
{
protected const LOGKEY = 'LVC';
public $queue = 'high';
public $queue = 'slack';
/**
* Handle the event.

View File

@ -23,7 +23,7 @@ use Slack\Response\Generic;
*/
final class Message extends BlockKit
{
protected const LOGKEY = 'SM-';
private const LOGKEY = 'SM-';
private const MAX_ATTACHMENTS = 20;

View File

@ -0,0 +1,147 @@
<?php
namespace Slack\Options;
use Illuminate\Support\Facades\Log;
use Slack\Message;
/**
* Class BlockSuggestion
(
[type] => block_suggestion
[user] => stdClass Object
(
[id] => U01QF1B0Y6B
[username] => deon
[name] => deon
[team_id] => T01QF14NSQP
)
[container] => stdClass Object
(
[type] => view
[view_id] => V034715K8GP
)
[api_app_id] => A4TCZ007N
[token] => Oow8S2EFvrZoS9z8N4nwf9Jo
[action_id] => system_include_brand
[block_id] => YME
[value] => abcdde
[team] => stdClass Object
(
[id] => T01QF14NSQP
[domain] => els953a-1
[enterprise_id] => E01R1P48JCU
[enterprise_name] => Leenooks Enteprise A
)
[enterprise] => stdClass Object
(
[id] => E01R1P48JCU
[name] => Leenooks Enteprise A
)
[is_enterprise_install] =>
[view] => stdClass Object
(
[id] => V034715K8GP
[team_id] => T01QF14NSQP
[type] => modal
[blocks] => Array
(
[0] => stdClass Object
(
[type] => section
[block_id] => YME
[text] => stdClass Object
(
[type] => mrkdwn
[text] => Select Brands:
[verbatim] =>
)
[accessory] => stdClass Object
(
[type] => multi_external_select
[action_id] => system_include_brand
[initial_options] => Array
(
)
[placeholder] => stdClass Object
(
[type] => plain_text
[text] => select...
[emoji] => 1
)
)
)
)
[private_metadata] =>
[callback_id] =>
[state] => stdClass Object
(
[values] => stdClass Object
(
[YME] => stdClass Object
(
[system_include_brand] => stdClass Object
(
[type] => multi_external_select
[selected_options] => Array
(
)
)
)
)
)
[hash] => 1645768594.IO10vEq1
[title] => stdClass Object
(
[type] => plain_text
[text] => Configure brands
[emoji] => 1
)
[clear_on_close] =>
[notify_on_close] =>
[close] =>
[submit] =>
[previous_view_id] =>
[root_view_id] => V034715K8GP
[app_id] => A4TCZ007N
[external_id] =>
[app_installed_team_id] => T01QF14NSQP
[bot_id] => B01RKPRAT0Q
)
)
*/
class BlockSuggestion extends Base
{
protected const LOGKEY = 'OIM';
public function __get($key)
{
switch ($key) {
case 'action_id':
case 'value':
return object_get($this->_data,$key);
case 'callback_id':
return object_get($this->_data,'view.'.$key);
default:
return parent::__get($key);
}
}
}

View File

@ -6,24 +6,25 @@ use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;
use Slack\Client\Payload;
use Slack\Interactive\Unknown;
class Factory {
private const LOGKEY = 'SOf';
protected const LOGKEY = 'SOf';
/**
* @var array event type to event class mapping
*/
public const map = [
//'interactive_message' => InteractiveMessage::class,
'block_suggestion' => BlockSuggestion::class,
'interactive_message' => InteractiveMessage::class,
];
/**
* Returns new event instance
*
* @param string $type
* @param Request $request
* @param string $type
* @param array $request
* @return Base
*/
public static function create(string $type,array $request)
@ -50,4 +51,4 @@ class Factory {
return $o;
}
}
}

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Log;
*
* @package Slack\Options
*/
class Unknown extends Base
final class Unknown extends Base
{
public function __construct(array $request)
{

View File

@ -10,9 +10,6 @@ use Slack\API;
use Slack\Channels\SlackBotChannel;
use Slack\Console\Commands\SlackSocketClient;
/**
* @todo For Lumen installs, this service provider is not required?
*/
class SlackServiceProvider extends ServiceProvider
{
/**

View File

@ -12,9 +12,9 @@ use Slack\Base as SlackBase;
*
* @note: This class is used for events not specifically created.
*/
class Base extends SlackBase implements \JsonSerializable
abstract class Base extends SlackBase implements \JsonSerializable
{
protected const LOGKEY = 'RB-';
private const LOGKEY = 'RB-';
/**
* Default Constructor Setup

View File

@ -4,7 +4,7 @@ namespace Slack\Response;
final class ChannelList extends Base
{
protected const LOGKEY = 'RCL';
private const LOGKEY = 'RCL';
/**
* Enable getting values for keys in the response

View File

@ -8,9 +8,9 @@ use Illuminate\Support\Collection;
/**
* This is a Slack Response from a GetHistory API call which is a message Chat
*/
class Chat extends Base
final class Chat extends Base
{
protected const LOGKEY = 'RC-';
private const LOGKEY = 'RC-';
/**
* Enable getting values for keys in the response

View File

@ -5,9 +5,9 @@ namespace Slack\Response;
/**
* This is a Generic Slack Response to API calls
*/
class Generic extends Base
final class Generic extends Base
{
protected const LOGKEY = 'RGE';
private const LOGKEY = 'RGE';
/**
* Enable getting values for keys in the response

View File

@ -9,7 +9,7 @@ namespace Slack\Response;
*/
final class Team extends Base
{
protected const LOGKEY = 'RT_';
private const LOGKEY = 'RT_';
/**
* Enable getting values for keys in the response

View File

@ -5,9 +5,9 @@ namespace Slack\Response;
/**
* This is the Slack Response to an Auth Test API call
*/
class Test extends Base
final class Test extends Base
{
protected const LOGKEY = 'RTE';
private const LOGKEY = 'RTE';
/**
* Enable getting values for keys in the response

View File

@ -9,7 +9,7 @@ namespace Slack\Response;
*/
final class User extends Base
{
protected const LOGKEY = 'RU_';
private const LOGKEY = 'RU_';
/**
* Enable getting values for keys in the response