Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Merge requests
!1635
Development
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Development
development
into
master
Overview
0
Commits
21
Pipelines
1
Changes
7
Merged
Dominik Hebeler
requested to merge
development
into
master
4 years ago
Overview
0
Commits
21
Pipelines
1
Changes
7
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
db7cecf8
21 commits,
4 years ago
7 files
+
424
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
app/Console/Commands/LoadSpam.php
0 → 100644
+
64
−
0
Options
<?php
namespace
App\Console\Commands
;
use
Carbon
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Redis
;
class
LoadSpam
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'spam:load'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Loads a list of current Spams into redis'
;
/**
* Create a new command instance.
*
* @return void
*/
public
function
__construct
()
{
parent
::
__construct
();
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
handle
()
{
$filePath
=
\storage_path
(
'logs/metager/ban.txt'
);
$bans
=
[];
if
(
\file_exists
(
$filePath
))
{
$bans
=
json_decode
(
file_get_contents
(
$filePath
),
true
);
}
$bansToLoad
=
[];
foreach
(
$bans
as
$ban
)
{
$bannedUntil
=
Carbon
::
createFromFormat
(
"Y-m-d H:i:s"
,
$ban
[
"banned-until"
]);
if
(
$bannedUntil
->
isAfter
(
Carbon
::
now
()))
{
$bansToLoad
[]
=
$ban
[
"regexp"
];
}
}
Redis
::
pipeline
(
function
(
$redis
)
use
(
$bansToLoad
)
{
$redis
->
del
(
"spam"
);
foreach
(
$bansToLoad
as
$ban
)
{
$redis
->
rpush
(
"spam"
,
$ban
);
}
});
}
}
Loading