1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-21 23:32:39 +00:00

Add AutospamCustomTokens model + migration

This commit is contained in:
Daniel Supernault 2023-05-17 03:53:05 -06:00
parent 127343ccda
commit 75db5116b7
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AutospamCustomTokens extends Model
{
use HasFactory;
}

37
config/autospam.php Normal file
View file

@ -0,0 +1,37 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Enable Autospam
|--------------------------------------------------------------------------
|
| Autospam uses NLP and other techniques to detect and mitigate potential
| spam posts from users on your server.
| We recommend enabling this when you have open registrations, regardless
| of how many users you have.
|
*/
'enabled' => env('PF_BOUNCER_ENABLED', false),
/*
|--------------------------------------------------------------------------
| Ignored Tokens
|--------------------------------------------------------------------------
|
| Ignored tokens are for commonly used words that may impact the detection.
| These tokens should be lowercase and not contain spaces or non alpha-
| numerical characters and be in comma-separated format.
|
*/
'ignored_tokens' => env('PF_AUTOSPAM_IGNORED_TOKENS', 'the,a,of,and'),
'nlp' => [
'enabled' => false,
'spam_sample_limit' => env('PF_AUTOSPAM_NLP_SPAM_SAMPLE_LIMIT', 200),
]
];

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('autospam_custom_tokens', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('token')->index();
$table->integer('weight')->default(1)->index();
$table->boolean('is_spam')->default(true)->index();
$table->text('note')->nullable();
$table->string('category')->nullable()->index();
$table->boolean('active')->default(false)->index();
$table->unique(['token', 'category']);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('autospam_custom_tokens');
}
};