From 1d5fdb1a746f59c7e162f913afe25c93a76ae6e4 Mon Sep 17 00:00:00 2001 From: Oscar Cedano Date: Sun, 4 Oct 2026 15:52:39 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20feat:=20changing=20resource=20folde?= =?UTF-8?q?r=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Cursor Grok 4.7 --- .../Media/TemporaryImageStorageInterface.php | 4 ++-- .../Report/Usecases/ReportUsecase.php | 16 ++++++++------ openapi.yaml | 22 +++++++++---------- tests/Feature/PublicReportControllerTest.php | 4 ++-- tests/Feature/StoreOrganizationReportTest.php | 4 +++- tests/Feature/StoreScammerReportTest.php | 4 +++- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/Application/Media/TemporaryImageStorageInterface.php b/app/Application/Media/TemporaryImageStorageInterface.php index 283bab5..f78a7c8 100644 --- a/app/Application/Media/TemporaryImageStorageInterface.php +++ b/app/Application/Media/TemporaryImageStorageInterface.php @@ -6,7 +6,7 @@ interface TemporaryImageStorageInterface { - public const string PROFILE_PICTURE_DIRECTORY = 'tmp/reports/profile'; + public const string PROFILE_PICTURE_DIRECTORY = 'tmp/reports/profiles'; public const string PROOF_DIRECTORY = 'tmp/reports/proofs'; @@ -21,7 +21,7 @@ public function uploadProof(UploadedFile $file): string; /** * Copy a published temporary file into a permanent public directory. * - * $location is a public-disk path such as `/storage/tmp/reports/profile/file.jpg`, + * $location is a public-disk path such as `/storage/tmp/reports/profiles/file.jpg`, * or the absolute public URL of that file. The file must exist directly inside * $sourceDirectory. Returns the relative permanent path. */ diff --git a/app/Application/Report/Usecases/ReportUsecase.php b/app/Application/Report/Usecases/ReportUsecase.php index b1d9bf0..761addb 100644 --- a/app/Application/Report/Usecases/ReportUsecase.php +++ b/app/Application/Report/Usecases/ReportUsecase.php @@ -31,11 +31,13 @@ class ReportUsecase implements ReportUsecaseInterface { - public const string AVATAR_DIRECTORY = 'reports/organizations/avatars'; + public const string ORGANIZATION_PROFILE_DIRECTORY = 'reports/organizations/profiles'; - public const string SCAMMER_AVATAR_DIRECTORY = 'reports/scammers/avatars'; + public const string SCAMMER_PROFILE_DIRECTORY = 'reports/scammers/profiles'; - public const string PROOF_DIRECTORY = 'reports/proofs'; + public const string ORGANIZATION_PROOF_DIRECTORY = 'reports/organizations/proofs'; + + public const string SCAMMER_PROOF_DIRECTORY = 'reports/scammers/proofs'; public function __construct( private SearchRepositoryInterface $search, @@ -81,7 +83,7 @@ public function storeOrganization(StoreOrganizationReportCommand $command): arra $avatarPath = $this->copyTemporary( $command->profilePicture, TemporaryImageStorageInterface::PROFILE_PICTURE_DIRECTORY, - self::AVATAR_DIRECTORY, + self::ORGANIZATION_PROFILE_DIRECTORY, 'profile_picture', ); $copied[] = $avatarPath; @@ -93,7 +95,7 @@ public function storeOrganization(StoreOrganizationReportCommand $command): arra $path = $this->copyTemporary( $url, TemporaryImageStorageInterface::PROOF_DIRECTORY, - self::PROOF_DIRECTORY, + self::ORGANIZATION_PROOF_DIRECTORY, 'proofs.'.$index, ); $copied[] = $path; @@ -176,7 +178,7 @@ public function storeScammer(StoreScammerReportCommand $command): array $avatarPath = $this->copyTemporary( $command->profilePicture, TemporaryImageStorageInterface::PROFILE_PICTURE_DIRECTORY, - self::SCAMMER_AVATAR_DIRECTORY, + self::SCAMMER_PROFILE_DIRECTORY, 'profile_picture', ); $copied[] = $avatarPath; @@ -188,7 +190,7 @@ public function storeScammer(StoreScammerReportCommand $command): array $path = $this->copyTemporary( $url, TemporaryImageStorageInterface::PROOF_DIRECTORY, - self::PROOF_DIRECTORY, + self::SCAMMER_PROOF_DIRECTORY, 'proofs.'.$index, ); $copied[] = $path; diff --git a/openapi.yaml b/openapi.yaml index 07b05fe..1a9f7f7 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -380,7 +380,7 @@ paths: description: | Accepts a JPG or PNG image up to 5 MB. The original is stored on the raw disk and must pass image moderation before a 640×640 cover is published on - the public disk under `tmp/reports/profile`. The response path is + the public disk under `tmp/reports/profiles`. The response path is the public URL of that file. Uploading the same image again returns the existing URL while the file is still present. A rejected image is moved to quarantine and the response does not include its path; it responds @@ -405,7 +405,7 @@ paths: schema: $ref: "#/components/schemas/StoredImagePath" example: - path: http://localhost:9000/storage/tmp/reports/profile/8f3c1a.jpg + path: http://localhost:9000/storage/tmp/reports/profiles/8f3c1a.jpg "422": $ref: "#/components/responses/ValidationFailed" "429": @@ -464,7 +464,7 @@ paths: platform and reference is reused, and a payment method that already exists for the same type and reference is reused. A trashed match is restored. `profile_picture` and `proofs` are public-disk paths previously returned by - the temporary media endpoints, such as `/storage/tmp/reports/profile/file.jpg`, + the temporary media endpoints, such as `/storage/tmp/reports/profiles/file.jpg`, and the files must still be present. The report is stored without a user and is active. requestBody: @@ -476,7 +476,7 @@ paths: example: title: Fake store took my money description: They never shipped the order. - profile_picture: /storage/tmp/reports/profile/8f3c1a.jpg + profile_picture: /storage/tmp/reports/profiles/8f3c1a.jpg proofs: - /storage/tmp/reports/proofs/8f3c1a.jpg - /storage/tmp/reports/proofs/9a4d2b.png @@ -516,7 +516,7 @@ paths: platform and reference is reused, and a payment method that already exists for the same type and reference is reused. A trashed match is restored. `profile_picture` and `proofs` are public-disk paths previously returned by - the temporary media endpoints, such as `/storage/tmp/reports/profile/file.jpg`, + the temporary media endpoints, such as `/storage/tmp/reports/profiles/file.jpg`, and the files must still be present. The report is stored without a user and is active. requestBody: @@ -528,7 +528,7 @@ paths: example: title: Called me about a prize description: They asked for a transfer to release the prize. - profile_picture: /storage/tmp/reports/profile/8f3c1a.jpg + profile_picture: /storage/tmp/reports/profiles/8f3c1a.jpg proofs: - /storage/tmp/reports/proofs/8f3c1a.jpg - /storage/tmp/reports/proofs/9a4d2b.png @@ -737,7 +737,7 @@ components: type: string format: uri description: Public URL of the stored image. - example: http://localhost:9000/storage/tmp/reports/profile/8f3c1a.jpg + example: http://localhost:9000/storage/tmp/reports/profiles/8f3c1a.jpg StoredImagePaths: type: object required: [paths] @@ -768,8 +768,8 @@ components: type: - string - "null" - description: Public-disk path of a file under `tmp/reports/profile`. - example: /storage/tmp/reports/profile/8f3c1a.jpg + description: Public-disk path of a file under `tmp/reports/profiles`. + example: /storage/tmp/reports/profiles/8f3c1a.jpg proofs: type: array items: @@ -870,8 +870,8 @@ components: type: - string - "null" - description: Public-disk path of a file under `tmp/reports/profile`. - example: /storage/tmp/reports/profile/8f3c1a.jpg + description: Public-disk path of a file under `tmp/reports/profiles`. + example: /storage/tmp/reports/profiles/8f3c1a.jpg proofs: type: array items: diff --git a/tests/Feature/PublicReportControllerTest.php b/tests/Feature/PublicReportControllerTest.php index 422f9ae..6b0bbc3 100644 --- a/tests/Feature/PublicReportControllerTest.php +++ b/tests/Feature/PublicReportControllerTest.php @@ -44,7 +44,7 @@ public function test_stores_jpg_and_png_profile_pictures_for_scammers_and_organi $extension = pathinfo($filename, PATHINFO_EXTENSION); $url = $response->json('path'); - $prefix = config('filesystems.disks.public.url').'/tmp/reports/profile/'; + $prefix = config('filesystems.disks.public.url').'/tmp/reports/profiles/'; $this->assertStringStartsWith($prefix, $url); $this->assertStringEndsWith('.'.$extension, $url); @@ -94,7 +94,7 @@ public function passes(string $contents): bool $quarantined = Storage::disk('quarantine')->allFiles(); $this->assertCount(1, $quarantined); - $this->assertStringStartsWith('tmp/reports/profile/', $quarantined[0]); + $this->assertStringStartsWith('tmp/reports/profiles/', $quarantined[0]); $this->assertSame($contents, Storage::disk('quarantine')->get($quarantined[0])); $this->assertSame([], Storage::disk('public')->allFiles()); $this->assertSame([], Storage::disk('raw')->allFiles()); diff --git a/tests/Feature/StoreOrganizationReportTest.php b/tests/Feature/StoreOrganizationReportTest.php index 245a63e..74dea19 100644 --- a/tests/Feature/StoreOrganizationReportTest.php +++ b/tests/Feature/StoreOrganizationReportTest.php @@ -65,7 +65,7 @@ public function test_creates_an_organization_report_with_contacts_payment_method $this->assertSame('Tienda Falsa', $organization->name); $this->assertTrue($organization->reports()->whereKey($report->id)->exists()); - $this->assertStringStartsWith('reports/organizations/avatars/', $organization->profile_picture_path); + $this->assertStringStartsWith('reports/organizations/profiles/', $organization->profile_picture_path); $this->assertSame('avatar', Storage::disk('public')->get($organization->profile_picture_path)); $this->assertTrue(Storage::disk('public')->exists(TemporaryImageStorageInterface::PROFILE_PICTURE_DIRECTORY.'/avatar.jpg')); @@ -76,6 +76,8 @@ public function test_creates_an_organization_report_with_contacts_payment_method Storage::disk('public')->get($storedProofs[0]->path), Storage::disk('public')->get($storedProofs[1]->path), ]); + $this->assertStringStartsWith('reports/organizations/proofs/', $storedProofs[0]->path); + $this->assertStringStartsWith('reports/organizations/proofs/', $storedProofs[1]->path); $this->assertTrue(Storage::disk('public')->exists(TemporaryImageStorageInterface::PROOF_DIRECTORY.'/one.jpg')); $this->assertTrue(Storage::disk('public')->exists(TemporaryImageStorageInterface::PROOF_DIRECTORY.'/two.png')); diff --git a/tests/Feature/StoreScammerReportTest.php b/tests/Feature/StoreScammerReportTest.php index 568ca74..d87f771 100644 --- a/tests/Feature/StoreScammerReportTest.php +++ b/tests/Feature/StoreScammerReportTest.php @@ -65,7 +65,7 @@ public function test_creates_a_scammer_report_with_contacts_payment_methods_and_ $this->assertSame('Juan Perez', $scammer->name); $this->assertTrue($scammer->reports()->whereKey($report->id)->exists()); - $this->assertStringStartsWith('reports/scammers/avatars/', $scammer->profile_picture_path); + $this->assertStringStartsWith('reports/scammers/profiles/', $scammer->profile_picture_path); $this->assertSame('avatar', Storage::disk('public')->get($scammer->profile_picture_path)); $this->assertTrue(Storage::disk('public')->exists(TemporaryImageStorageInterface::PROFILE_PICTURE_DIRECTORY.'/avatar.jpg')); @@ -76,6 +76,8 @@ public function test_creates_a_scammer_report_with_contacts_payment_methods_and_ Storage::disk('public')->get($storedProofs[0]->path), Storage::disk('public')->get($storedProofs[1]->path), ]); + $this->assertStringStartsWith('reports/scammers/proofs/', $storedProofs[0]->path); + $this->assertStringStartsWith('reports/scammers/proofs/', $storedProofs[1]->path); $this->assertTrue(Storage::disk('public')->exists(TemporaryImageStorageInterface::PROOF_DIRECTORY.'/one.jpg')); $this->assertTrue(Storage::disk('public')->exists(TemporaryImageStorageInterface::PROOF_DIRECTORY.'/two.png'));