diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index 0e62013f4..70401eba5 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -15,7 +15,8 @@ use App\{ Media, Notification, Profile, - Status + Status, + StatusArchived }; use App\Transformer\Api\{ AccountTransformer, @@ -39,6 +40,7 @@ use App\Jobs\VideoPipeline\{ use App\Services\NotificationService; use App\Services\MediaPathService; use App\Services\MediaBlocklistService; +use App\Services\StatusService; class BaseApiController extends Controller { @@ -286,4 +288,75 @@ class BaseApiController extends Controller return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); } + + public function archive(Request $request, $id) + { + abort_if(!$request->user(), 403); + + $status = Status::whereNull('in_reply_to_id') + ->whereNull('reblog_of_id') + ->whereProfileId($request->user()->profile_id) + ->findOrFail($id); + + if($status->scope === 'archived') { + return [200]; + } + + $archive = new StatusArchived; + $archive->status_id = $status->id; + $archive->profile_id = $status->profile_id; + $archive->original_scope = $status->scope; + $archive->save(); + + $status->scope = 'archived'; + $status->visibility = 'draft'; + $status->save(); + + StatusService::del($status->id); + + // invalidate caches + + return [200]; + } + + public function unarchive(Request $request, $id) + { + abort_if(!$request->user(), 403); + + $status = Status::whereNull('in_reply_to_id') + ->whereNull('reblog_of_id') + ->whereProfileId($request->user()->profile_id) + ->findOrFail($id); + + if($status->scope !== 'archived') { + return [200]; + } + + $archive = StatusArchived::whereStatusId($status->id) + ->whereProfileId($status->profile_id) + ->firstOrFail(); + + $status->scope = $archive->original_scope; + $status->visibility = $archive->original_scope; + $status->save(); + + $archive->delete(); + + return [200]; + } + + public function archivedPosts(Request $request) + { + abort_if(!$request->user(), 403); + + $statuses = Status::whereProfileId($request->user()->profile_id) + ->whereScope('archived') + ->orderByDesc('id') + ->simplePaginate(10); + + $fractal = new Fractal\Manager(); + $fractal->setSerializer(new ArraySerializer()); + $resource = new Fractal\Resource\Collection($statuses, new StatusStatelessTransformer()); + return $fractal->createData($resource)->toArray(); + } } diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 6395318af..0ca16f10e 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -616,6 +616,8 @@
+
How do I share a post with multiple photos or videos? @@ -43,7 +43,7 @@
+
How do I add a caption before sharing my photos or videos on Pixelfed? @@ -54,7 +54,7 @@
+
+
-+
+ - {{--+ {{--
What is the limit for photo and video file sizes? @@ -122,7 +122,7 @@
--}} - {{--+ {{--
When I share a photo, what's the image resolution? @@ -133,7 +133,7 @@
--}} - {{--+ {{--
Can I edit my post captions, photos or videos after sharing them? @@ -144,7 +144,7 @@
--}} -+
How can I disable comments/replies on my post? @@ -159,7 +159,7 @@
-+
How many people can I tag or mention in my comments or posts? @@ -171,4 +171,55 @@
-@endsection \ No newline at end of file ++ + + What does archive mean? + +
+ + + How can I archive my posts? + +
+ + + How do I unarchive my posts? + +