mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
Add S3 + Stories
This commit is contained in:
parent
6bb8099583
commit
7faa9d8e61
7 changed files with 84 additions and 19 deletions
|
@ -303,4 +303,9 @@ class Profile extends Model
|
|||
->whereFollowingId($this->id)
|
||||
->exists();
|
||||
}
|
||||
|
||||
public function stories()
|
||||
{
|
||||
return $this->hasMany(Story::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ class AuthServiceProvider extends ServiceProvider
|
|||
'read',
|
||||
'write',
|
||||
'follow',
|
||||
'push'
|
||||
]);
|
||||
|
||||
Passport::tokensCan([
|
||||
|
|
|
@ -131,13 +131,9 @@ class Status extends Model
|
|||
$media = $this->firstMedia();
|
||||
$path = $media->media_path;
|
||||
$hash = is_null($media->processed_at) ? md5('unprocessed') : md5($media->created_at);
|
||||
if(config('pixelfed.cloud_storage') == true) {
|
||||
$url = Storage::disk(config('filesystems.cloud'))->url($path)."?v={$hash}";
|
||||
} else {
|
||||
$url = Storage::url($path)."?v={$hash}";
|
||||
}
|
||||
$url = $media->cdn_url ? $media->cdn_url . "?v={$hash}" : url(Storage::url($path)."?v={$hash}");
|
||||
|
||||
return url($url);
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function likes()
|
||||
|
|
|
@ -24,6 +24,8 @@ class Story extends Model
|
|||
*/
|
||||
protected $dates = ['published_at', 'expires_at'];
|
||||
|
||||
protected $fillable = ['profile_id'];
|
||||
|
||||
protected $visible = ['id'];
|
||||
|
||||
public function profile()
|
||||
|
@ -31,16 +33,6 @@ class Story extends Model
|
|||
return $this->belongsTo(Profile::class);
|
||||
}
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(StoryItem::class);
|
||||
}
|
||||
|
||||
public function reactions()
|
||||
{
|
||||
return $this->hasMany(StoryReaction::class);
|
||||
}
|
||||
|
||||
public function views()
|
||||
{
|
||||
return $this->hasMany(StoryView::class);
|
||||
|
@ -48,7 +40,8 @@ class Story extends Model
|
|||
|
||||
public function seen($pid = false)
|
||||
{
|
||||
$id = $pid ?? Auth::user()->profile->id;
|
||||
return $this->views()->whereProfileId($id)->exists();
|
||||
return StoryView::whereStoryId($this->id)
|
||||
->whereProfileId(Auth::user()->profile->id)
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateStoriesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::dropIfExists('stories');
|
||||
Schema::dropIfExists('story_items');
|
||||
Schema::dropIfExists('story_reactions');
|
||||
Schema::dropIfExists('story_views');
|
||||
|
||||
Schema::create('stories', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->bigInteger('profile_id')->unsigned()->index();
|
||||
$table->string('type')->nullable();
|
||||
$table->unsignedInteger('size')->nullable();
|
||||
$table->string('mime')->nullable();
|
||||
$table->smallInteger('duration')->unsigned();
|
||||
$table->string('path')->nullable();
|
||||
$table->string('cdn_url')->nullable();
|
||||
$table->boolean('public')->default(false)->index();
|
||||
$table->boolean('local')->default(false)->index();
|
||||
$table->unsignedInteger('view_count')->nullable();
|
||||
$table->unsignedInteger('comment_count')->nullable();
|
||||
$table->json('story')->nullable();
|
||||
$table->unique(['profile_id', 'path']);
|
||||
$table->timestamp('expires_at')->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('story_views', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->bigInteger('story_id')->unsigned()->index();
|
||||
$table->bigInteger('profile_id')->unsigned()->index();
|
||||
$table->unique(['profile_id', 'story_id']);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('stories');
|
||||
Schema::dropIfExists('story_views');
|
||||
}
|
||||
}
|
4
resources/assets/js/story-compose.js
vendored
Normal file
4
resources/assets/js/story-compose.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
Vue.component(
|
||||
'story-compose',
|
||||
require('./components/StoryCompose.vue').default
|
||||
);
|
5
resources/assets/js/timeline.js
vendored
5
resources/assets/js/timeline.js
vendored
|
@ -41,4 +41,9 @@ Vue.component(
|
|||
Vue.component(
|
||||
'announcements-card',
|
||||
require('./components/AnnouncementsCard.vue').default
|
||||
);
|
||||
|
||||
Vue.component(
|
||||
'story-component',
|
||||
require('./components/StoryTimelineComponent.vue').default
|
||||
);
|
Loading…
Reference in a new issue