diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 7b7ddfa4f..c2e573ea9 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -10,6 +10,7 @@ use App\AccountInterstitial; use App\Media; use App\Profile; use App\Status; +use App\StatusView; use App\Transformer\ActivityPub\StatusTransformer; use App\Transformer\ActivityPub\Verb\Note; use App\User; @@ -59,6 +60,14 @@ class StatusController extends Controller } } + if($request->user() && $request->user()->profile_id != $status->profile_id) { + StatusView::firstOrCreate([ + 'status_id' => $status->id, + 'status_profile_id' => $status->profile_id, + 'profile_id' => $request->user()->profile_id + ]); + } + if ($request->wantsJson() && config('federation.activitypub.enabled')) { return $this->showActivityPub($request, $status); } diff --git a/app/StatusView.php b/app/StatusView.php new file mode 100644 index 000000000..569ae2cb4 --- /dev/null +++ b/app/StatusView.php @@ -0,0 +1,17 @@ +bigIncrements('id'); + $table->bigInteger('status_id')->unsigned()->nullable()->index(); + $table->bigInteger('status_profile_id')->unsigned()->nullable()->index(); + $table->bigInteger('profile_id')->unsigned()->nullable()->index(); + $table->unique(['status_id', 'profile_id']); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('status_views'); + } +}