mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update AutospamUpdateCachedDataPipeline
This commit is contained in:
parent
053b30bca0
commit
5abc2445a7
1 changed files with 71 additions and 47 deletions
|
@ -29,7 +29,19 @@ class AutospamUpdateCachedDataPipeline implements ShouldQueue
|
|||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$spamExists = Storage::exists(AutospamService::MODEL_SPAM_PATH);
|
||||
if($spamExists) {
|
||||
$spam = json_decode(Storage::get(AutospamService::MODEL_SPAM_PATH), true);
|
||||
} else {
|
||||
$spam = [
|
||||
'documents' => [
|
||||
'spam' => 0
|
||||
],
|
||||
'words' => [
|
||||
'spam' => []
|
||||
]
|
||||
];
|
||||
}
|
||||
$newSpam = AutospamCustomTokens::whereCategory('spam')->get();
|
||||
foreach($newSpam as $ns) {
|
||||
$key = strtolower($ns->token);
|
||||
|
@ -44,7 +56,19 @@ class AutospamUpdateCachedDataPipeline implements ShouldQueue
|
|||
arsort($spam['words']['spam']);
|
||||
Storage::put(AutospamService::MODEL_SPAM_PATH, json_encode($spam, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
|
||||
|
||||
$hamExists = Storage::exists(AutospamService::MODEL_HAM_PATH);
|
||||
if($hamExists) {
|
||||
$ham = json_decode(Storage::get(AutospamService::MODEL_HAM_PATH), true);
|
||||
} else {
|
||||
$ham = [
|
||||
'documents' => [
|
||||
'ham' => 0
|
||||
],
|
||||
'words' => [
|
||||
'ham' => []
|
||||
]
|
||||
];
|
||||
}
|
||||
$newHam = AutospamCustomTokens::whereCategory('ham')->get();
|
||||
foreach($newHam as $ns) {
|
||||
$key = strtolower($ns->token);
|
||||
|
|
Loading…
Reference in a new issue