Add option to not process bots during import

This commit is contained in:
Deon George
2021-09-11 00:38:11 +10:00
parent e8a9508391
commit 72bc9790d1
2 changed files with 18 additions and 11 deletions

View File

@@ -19,11 +19,13 @@ class MessageProcess implements ShouldQueue
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private Message $msg;
private bool $skipbot;
public function __construct(Message $msg)
public function __construct(Message $msg,bool $skipbot=FALSE)
{
// Some checks
$this->msg = $msg;
$this->skipbot = $skipbot;
}
/**
@@ -48,11 +50,12 @@ class MessageProcess implements ShouldQueue
$processed = FALSE;
// If the message is to a bot, we'll process it
foreach (config('process.robots') as $class) {
if ($processed = $class::handle($this->msg)) {
break;
if (! $this->skipbot)
foreach (config('process.robots') as $class) {
if ($processed = $class::handle($this->msg)) {
break;
}
}
}
// We'll ignore messages from *fix users
if (in_array(strtolower($this->msg->user_from),['filefix','areafix'])) {
@@ -218,11 +221,12 @@ class MessageProcess implements ShouldQueue
));
// If the message is to a bot, we'll process it
foreach (config('process.echomail') as $class) {
if ($class::handle($this->msg)) {
break;
if (! $this->skipbot)
foreach (config('process.echomail') as $class) {
if ($class::handle($this->msg)) {
break;
}
}
}
}
}
}