mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add StatusView model to store views for discover algorithm
This commit is contained in:
parent
ea0c1e80c6
commit
7a68ee948a
3 changed files with 61 additions and 0 deletions
|
@ -10,6 +10,7 @@ use App\AccountInterstitial;
|
||||||
use App\Media;
|
use App\Media;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Status;
|
use App\Status;
|
||||||
|
use App\StatusView;
|
||||||
use App\Transformer\ActivityPub\StatusTransformer;
|
use App\Transformer\ActivityPub\StatusTransformer;
|
||||||
use App\Transformer\ActivityPub\Verb\Note;
|
use App\Transformer\ActivityPub\Verb\Note;
|
||||||
use App\User;
|
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')) {
|
if ($request->wantsJson() && config('federation.activitypub.enabled')) {
|
||||||
return $this->showActivityPub($request, $status);
|
return $this->showActivityPub($request, $status);
|
||||||
}
|
}
|
||||||
|
|
17
app/StatusView.php
Normal file
17
app/StatusView.php
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StatusView extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'status_id',
|
||||||
|
'status_profile_id',
|
||||||
|
'profile_id'
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateStatusViewsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('status_views', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue