Browse Source

Update StatusController, set missing reblog/share type

Daniel Supernault 3 năm trước cách đây
mục cha
commit
548a12a4c2

+ 1 - 0
app/Http/Controllers/Api/ApiV1Controller.php

@@ -2247,6 +2247,7 @@ class ApiV1Controller extends Controller
 		$share = Status::firstOrCreate([
 			'profile_id' => $user->profile_id,
 			'reblog_of_id' => $status->id,
+			'type' => 'share',
 			'in_reply_to_profile_id' => $status->profile_id,
 			'scope' => 'public',
 			'visibility' => 'public'

+ 1 - 0
app/Http/Controllers/StatusController.php

@@ -254,6 +254,7 @@ class StatusController extends Controller
 			$share->profile_id = $profile->id;
 			$share->reblog_of_id = $status->id;
 			$share->in_reply_to_profile_id = $status->profile_id;
+			$share->type = 'share';
 			$share->save();
 			$count++;
 			SharePipeline::dispatch($share);

+ 32 - 0
database/migrations/2022_02_13_091135_add_missing_reblog_of_id_types_to_statuses_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Status;
+
+class AddMissingReblogOfIdTypesToStatusesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Status::whereNotNull('reblog_of_id')
+        	->whereNull('type')
+        	->update([
+        		'type' => 'share'
+        	]);
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+    }
+}