From e1684d85d2251f4daea47d136dfc2428c41d4598 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 12:01:13 -0600 Subject: [PATCH 01/12] Update footer --- resources/views/layouts/partial/footer.blade.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/resources/views/layouts/partial/footer.blade.php b/resources/views/layouts/partial/footer.blade.php index d5dd33bcf..be0e22778 100644 --- a/resources/views/layouts/partial/footer.blade.php +++ b/resources/views/layouts/partial/footer.blade.php @@ -7,11 +7,8 @@ Terms Privacy API - Directory - Profiles - Hashtags Language - Powered by PixelFed + Powered by PixelFed

From a799920e4f848a9f88a83286cfac4011089652c8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 12:16:34 -0600 Subject: [PATCH 02/12] Add .gitignore to html purify storage cache --- storage/purify/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 storage/purify/.gitignore diff --git a/storage/purify/.gitignore b/storage/purify/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/storage/purify/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file From 621c36a3bc990959918aa787ed000c55d4926017 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 12:20:58 -0600 Subject: [PATCH 03/12] Add Collection model --- app/Collection.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/Collection.php diff --git a/app/Collection.php b/app/Collection.php new file mode 100644 index 000000000..2f6034f4e --- /dev/null +++ b/app/Collection.php @@ -0,0 +1,10 @@ + Date: Wed, 17 Oct 2018 12:21:13 -0600 Subject: [PATCH 04/12] Add CollectionItem model --- app/CollectionItem.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/CollectionItem.php diff --git a/app/CollectionItem.php b/app/CollectionItem.php new file mode 100644 index 000000000..a4578e09c --- /dev/null +++ b/app/CollectionItem.php @@ -0,0 +1,10 @@ + Date: Wed, 17 Oct 2018 12:21:39 -0600 Subject: [PATCH 05/12] Add DirectMessage model --- app/DirectMessage.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 app/DirectMessage.php diff --git a/app/DirectMessage.php b/app/DirectMessage.php new file mode 100644 index 000000000..accc92f7f --- /dev/null +++ b/app/DirectMessage.php @@ -0,0 +1,29 @@ +hasOne(Status::class, 'id', 'status_id'); + } + + public function url() + { + return url('/i/message/' . $this->to_id . '/' . $this->id); + } + + public function author() + { + return $this->hasOne(Profile::class, 'id', 'from_id'); + } + + public function me() + { + return Auth::user()->profile->id === $this->from_id; + } +} From 31b34570c0ff520358b2a7adf128ccc93ec3ae79 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 12:22:35 -0600 Subject: [PATCH 06/12] Update BaseApiController --- .../Controllers/Api/BaseApiController.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index f55c15ce3..bf72d0d0a 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -6,8 +6,11 @@ use App\Avatar; use App\Http\Controllers\AvatarController; use App\Http\Controllers\Controller; use App\Jobs\AvatarPipeline\AvatarOptimize; +use App\Jobs\ImageOptimizePipeline\ImageOptimize; +use App\Media; use App\Profile; use App\Transformer\Api\AccountTransformer; +use App\Transformer\Api\MediaTransformer; use App\Transformer\Api\StatusTransformer; use Auth; use Cache; @@ -115,4 +118,44 @@ class BaseApiController extends Controller 'msg' => 'Avatar successfully updated', ]); } + + public function uploadMedia(Request $request) + { + $this->validate($request, [ + 'file.*' => function() { + return [ + 'required', + 'mimes:' . config('pixelfed.media_types'), + 'max:' . config('pixelfed.max_photo_size'), + ]; + }, + ]); + $user = Auth::user(); + $profile = $user->profile; + $monthHash = hash('sha1', date('Y').date('m')); + $userHash = hash('sha1', $user->id.(string) $user->created_at); + $photo = $request->file('file'); + + $storagePath = "public/m/{$monthHash}/{$userHash}"; + $path = $photo->store($storagePath); + $hash = \hash_file('sha256', $photo); + + $media = new Media(); + $media->status_id = null; + $media->profile_id = $profile->id; + $media->user_id = $user->id; + $media->media_path = $path; + $media->original_sha256 = $hash; + $media->size = $photo->getClientSize(); + $media->mime = $photo->getClientMimeType(); + $media->filter_class = null; + $media->filter_name = null; + $media->save(); + + ImageOptimize::dispatch($media); + $resource = new Fractal\Resource\Item($media, new MediaTransformer()); + $res = $this->fractal->createData($resource)->toArray(); + + return response()->json($res); + } } From f7b3263ab3d8a655a2511bb142d3f69efbfe2589 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 12:40:04 -0600 Subject: [PATCH 07/12] Update bookmarkform.js --- resources/assets/js/components/bookmarkform.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/assets/js/components/bookmarkform.js b/resources/assets/js/components/bookmarkform.js index dd67747ae..14d096adb 100644 --- a/resources/assets/js/components/bookmarkform.js +++ b/resources/assets/js/components/bookmarkform.js @@ -1,6 +1,5 @@ $(document).ready(function() { - - $('.bookmark-form').submit(function(e) { + $(document).on('submit', '.bookmark-form', function(e) { e.preventDefault(); var el = $(this); var id = el.data('id'); From a74b20324bd8ff8503dc517e1215f8e50742c5c7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 12:40:39 -0600 Subject: [PATCH 08/12] Update commentform,js --- resources/assets/js/components/commentform.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/commentform.js b/resources/assets/js/components/commentform.js index c9d4f9477..3f0482718 100644 --- a/resources/assets/js/components/commentform.js +++ b/resources/assets/js/components/commentform.js @@ -35,9 +35,9 @@ $(document).ready(function() { var comments = el.parents().eq(1).find('.comments'); } - var comment = '

' + username + ''+ reply + '1s

'; + var comment = '

' + username + ''+ reply + '

'; - comments.append(comment); + comments.prepend(comment); commentform.val(''); commentform.blur(); From 58b9ef4dbb8ed41c7cc9ab01a0e1d24a494b2d5a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 12:41:54 -0600 Subject: [PATCH 09/12] Add PostComments vue component --- .../assets/js/components/PostComments.vue | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 resources/assets/js/components/PostComments.vue diff --git a/resources/assets/js/components/PostComments.vue b/resources/assets/js/components/PostComments.vue new file mode 100644 index 000000000..a75bda6cf --- /dev/null +++ b/resources/assets/js/components/PostComments.vue @@ -0,0 +1,147 @@ + + + + + + \ No newline at end of file From 5b90bec1b32ce76b441d8879dd14ca44ee526c1d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 18:11:51 -0600 Subject: [PATCH 10/12] Add new migration --- ...update_follower_table_add_remote_flags.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/migrations/2018_10_17_233623_update_follower_table_add_remote_flags.php diff --git a/database/migrations/2018_10_17_233623_update_follower_table_add_remote_flags.php b/database/migrations/2018_10_17_233623_update_follower_table_add_remote_flags.php new file mode 100644 index 000000000..7838179de --- /dev/null +++ b/database/migrations/2018_10_17_233623_update_follower_table_add_remote_flags.php @@ -0,0 +1,34 @@ +boolean('local_profile')->default(true)->index()->after('following_id'); + $table->boolean('local_following')->default(true)->index()->after('local_profile'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('followers', function (Blueprint $table) { + $table->dropColumn('local_profile'); + $table->dropColumn('local_following'); + }); + } +} From 32df6a82ac01f63a61f7c6393d1b2ae098546744 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 18:16:37 -0600 Subject: [PATCH 11/12] Remove sharedInbox until ready --- app/Transformer/ActivityPub/ProfileTransformer.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Transformer/ActivityPub/ProfileTransformer.php b/app/Transformer/ActivityPub/ProfileTransformer.php index c576b38b3..d270e8c18 100644 --- a/app/Transformer/ActivityPub/ProfileTransformer.php +++ b/app/Transformer/ActivityPub/ProfileTransformer.php @@ -39,9 +39,10 @@ class ProfileTransformer extends Fractal\TransformerAbstract 'owner' => $profile->permalink(), 'publicKeyPem' => $profile->public_key, ], - 'endpoints' => [ - 'sharedInbox' => config('routes.api.sharedInbox'), - ], + // remove shared inbox support until proper support + // 'endpoints' => [ + // 'sharedInbox' => config('routes.api.sharedInbox'), + // ], 'icon' => [ 'type' => 'Image', 'mediaType' => 'image/jpeg', From 89b17126038757e39932c84380ca35d110934a47 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 17 Oct 2018 18:23:29 -0600 Subject: [PATCH 12/12] Update StatusController --- app/Http/Controllers/StatusController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 77962b1be..fb5682cb9 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -110,7 +110,10 @@ class StatusController extends Controller $status->profile_id = $profile->id; $status->caption = strip_tags($request->caption); $status->is_nsfw = $cw; + + // TODO: remove deprecated visibility in favor of scope $status->visibility = $visibility; + $status->scope = $visibility; $status->save();