Преглед на файлове

Add AutospamCustomTokens model + migration

Daniel Supernault преди 2 години
родител
ревизия
75db5116b7
променени са 3 файла, в които са добавени 82 реда и са изтрити 0 реда
  1. 11 0
      app/Models/AutospamCustomTokens.php
  2. 37 0
      config/autospam.php
  3. 34 0
      database/migrations/2023_05_15_050604_create_autospam_custom_tokens_table.php

+ 11 - 0
app/Models/AutospamCustomTokens.php

@@ -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 - 0
config/autospam.php

@@ -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),
+    ]
+];

+ 34 - 0
database/migrations/2023_05_15_050604_create_autospam_custom_tokens_table.php

@@ -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');
+    }
+};