diff --git a/app/Profile.php b/app/Profile.php index e01ad368b..b386ffda6 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -303,4 +303,9 @@ class Profile extends Model ->whereFollowingId($this->id) ->exists(); } + + public function stories() + { + return $this->hasMany(Story::class); + } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 3448b3005..7e3b460f8 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -36,7 +36,6 @@ class AuthServiceProvider extends ServiceProvider 'read', 'write', 'follow', - 'push' ]); Passport::tokensCan([ diff --git a/app/Status.php b/app/Status.php index 5819d0961..ac04b31a4 100644 --- a/app/Status.php +++ b/app/Status.php @@ -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() diff --git a/app/Story.php b/app/Story.php index 104f0e58f..7473ea7f6 100644 --- a/app/Story.php +++ b/app/Story.php @@ -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(); } } diff --git a/database/migrations/2019_12_25_042317_update_stories_table.php b/database/migrations/2019_12_25_042317_update_stories_table.php new file mode 100644 index 000000000..da778225e --- /dev/null +++ b/database/migrations/2019_12_25_042317_update_stories_table.php @@ -0,0 +1,63 @@ +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'); + } +} diff --git a/resources/assets/js/story-compose.js b/resources/assets/js/story-compose.js new file mode 100644 index 000000000..d2af1dd2a --- /dev/null +++ b/resources/assets/js/story-compose.js @@ -0,0 +1,4 @@ +Vue.component( + 'story-compose', + require('./components/StoryCompose.vue').default +); \ No newline at end of file diff --git a/resources/assets/js/timeline.js b/resources/assets/js/timeline.js index 0e8b1488a..5858ac8e3 100644 --- a/resources/assets/js/timeline.js +++ b/resources/assets/js/timeline.js @@ -41,4 +41,9 @@ Vue.component( Vue.component( 'announcements-card', require('./components/AnnouncementsCard.vue').default +); + +Vue.component( + 'story-component', + require('./components/StoryTimelineComponent.vue').default ); \ No newline at end of file