kopia lustrzana https://github.com/pixelfed/pixelfed
				
				
				
			Add StatusView model to store views for discover algorithm
							rodzic
							
								
									ea0c1e80c6
								
							
						
					
					
						commit
						7a68ee948a
					
				| 
						 | 
				
			
			@ -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);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Ładowanie…
	
		Reference in New Issue