diff --git a/app/Models/Bookmark.php b/app/Models/Bookmark.php index 5b37d84c..1c5ae6e4 100644 --- a/app/Models/Bookmark.php +++ b/app/Models/Bookmark.php @@ -25,7 +25,7 @@ class Bookmark extends Model return $this->belongsToMany('App\Models\Tag'); } - protected function uri(): Attribute + protected function localUri(): Attribute { return Attribute::get( get: fn () => config('app.url').'/bookmarks/'.$this->id, diff --git a/app/Models/Like.php b/app/Models/Like.php index 8f2521ef..44f25b91 100644 --- a/app/Models/Like.php +++ b/app/Models/Like.php @@ -18,13 +18,6 @@ class Like extends Model use FilterHtml; use HasFactory; - protected function uri(): Attribute - { - return Attribute::get( - get: fn () => config('app.url').'/likes/'.$this->id, - ); - } - protected function url(): Attribute { return Attribute::set( diff --git a/app/Services/Micropub/Handlers/EntryHandler.php b/app/Services/Micropub/Handlers/EntryHandler.php index 6b68b88c..d79a0418 100644 --- a/app/Services/Micropub/Handlers/EntryHandler.php +++ b/app/Services/Micropub/Handlers/EntryHandler.php @@ -35,7 +35,7 @@ class EntryHandler implements MicropubHandlerInterface $dataArray = $data->toArray(); $location = match (true) { - isset($dataArray['like-of']) => resolve(LikeService::class)->create($dataArray)->uri, + isset($dataArray['like-of']) => resolve(LikeService::class)->create($dataArray)->url, isset($dataArray['bookmark-of']) => resolve(BookmarkService::class)->create($dataArray)->uri, isset($dataArray['name']) => resolve(ArticleService::class)->create($dataArray)->uri, default => resolve(NoteService::class)->create($dataArray)->uri, diff --git a/database/migrations/2026_11_01_120000_drop_shorturl_from_notes_table.php b/database/migrations/2026_11_01_120000_drop_shorturl_from_notes_table.php deleted file mode 100644 index e4f73202..00000000 --- a/database/migrations/2026_11_01_120000_drop_shorturl_from_notes_table.php +++ /dev/null @@ -1,28 +0,0 @@ -dropColumn('shorturl'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('notes', function (Blueprint $table) { - $table->string('shorturl', 20)->nullable(); - }); - } -}; diff --git a/resources/views/templates/like.blade.php b/resources/views/templates/like.blade.php index 2a114761..5169a31e 100644 --- a/resources/views/templates/like.blade.php +++ b/resources/views/templates/like.blade.php @@ -20,7 +20,7 @@ @endisset
diff --git a/routes/web.php b/routes/web.php index d7e1ee2f..a9b46407 100644 --- a/routes/web.php +++ b/routes/web.php @@ -211,14 +211,14 @@ Route::get('note/{id}', [NotesController::class, 'redirect']); // for legacy not // Likes Route::prefix('likes')->group(function () { Route::get('/', [LikesController::class, 'index']); - Route::get('/{like}', [LikesController::class, 'show'])->whereNumber('like'); + Route::get('/{like}', [LikesController::class, 'show']); }); // Bookmarks Route::prefix('bookmarks')->group(function () { Route::get('/', [BookmarksController::class, 'index']); Route::redirect('/tagged', '/bookmarks'); - Route::get('/{bookmark}', [BookmarksController::class, 'show'])->whereNumber('bookmark'); + Route::get('/{bookmark}', [BookmarksController::class, 'show']); Route::get('/tagged/{tag}', [BookmarksController::class, 'tagged']); }); diff --git a/tests/Feature/BookmarksTest.php b/tests/Feature/BookmarksTest.php index 5c4db0d8..52dbb959 100644 --- a/tests/Feature/BookmarksTest.php +++ b/tests/Feature/BookmarksTest.php @@ -32,13 +32,6 @@ class BookmarksTest extends TestCase $response->assertViewIs('bookmarks.show'); } - #[Test] - public function non_numeric_bookmark_id_gives_not_found_response(): void - { - $response = $this->get('/bookmarks/twcamp^share|twsrc^ios'); - $response->assertNotFound(); - } - #[Test] public function when_bookmark_is_added_using_http_syntax_check_job_to_take_screenshot_is_invoked(): void { @@ -92,10 +85,10 @@ class BookmarksTest extends TestCase } #[Test] - public function bookmark_uri_attribute_returns_correct_url(): void + public function bookmark_local_uri_attribute_returns_correct_url(): void { $bookmark = Bookmark::factory()->create(); - $this->assertEquals(config('app.url').'/bookmarks/'.$bookmark->id, $bookmark->uri); + $this->assertEquals(config('app.url').'/bookmarks/'.$bookmark->id, $bookmark->local_uri); } #[Test] diff --git a/tests/Feature/LikesTest.php b/tests/Feature/LikesTest.php index b08f0d37..2bda91f3 100644 --- a/tests/Feature/LikesTest.php +++ b/tests/Feature/LikesTest.php @@ -178,11 +178,4 @@ class LikesTest extends TestCase $response = $this->get('/likes/202'); $response->assertNotFound(); } - - #[Test] - public function non_numeric_like_id_gives_not_found_response(): void - { - $response = $this->get('/likes/twcamp^share|twsrc^ios'); - $response->assertNotFound(); - } } diff --git a/tests/Feature/MicropubControllerTest.php b/tests/Feature/MicropubControllerTest.php index 7a350dc1..a2335bdd 100644 --- a/tests/Feature/MicropubControllerTest.php +++ b/tests/Feature/MicropubControllerTest.php @@ -8,8 +8,6 @@ use App\Jobs\SendWebMentions; use App\Jobs\SyndicateNoteToBluesky; use App\Jobs\SyndicateNoteToMastodon; use App\Models\Article; -use App\Models\Bookmark; -use App\Models\Like; use App\Models\Media; use App\Models\Note; use App\Models\Place; @@ -881,50 +879,6 @@ class MicropubControllerTest extends TestCase $this->assertStringStartsWith(config('app.url').'/blog/', $response->headers->get('Location')); } - #[Test] - public function micropub_client_api_request_for_a_like_returns_our_permalink_in_the_location_header(): void - { - Queue::fake(); - - $response = $this->postJson( - '/api/post', - [ - 'type' => ['h-entry'], - 'properties' => [ - 'like-of' => ['https://example.org/liked-post'], - ], - ], - ['HTTP_Authorization' => 'Bearer '.$this->getToken()] - ); - - $like = Like::where('url', 'https://example.org/liked-post')->sole(); - $response - ->assertStatus(201) - ->assertHeader('Location', config('app.url').'/likes/'.$like->id); - } - - #[Test] - public function micropub_client_api_request_for_a_bookmark_returns_our_permalink_in_the_location_header(): void - { - Queue::fake(); - - $response = $this->postJson( - '/api/post', - [ - 'type' => ['h-entry'], - 'properties' => [ - 'bookmark-of' => ['https://example.org/bookmarked-page'], - ], - ], - ['HTTP_Authorization' => 'Bearer '.$this->getToken()] - ); - - $bookmark = Bookmark::where('url', 'https://example.org/bookmarked-page')->sole(); - $response - ->assertStatus(201) - ->assertHeader('Location', config('app.url').'/bookmarks/'.$bookmark->id); - } - #[Test] public function micropub_client_api_request_creates_an_unpublished_article_when_post_status_is_draft(): void { diff --git a/tests/Unit/LikesTest.php b/tests/Unit/LikesTest.php index ef4c21f2..74412833 100644 --- a/tests/Unit/LikesTest.php +++ b/tests/Unit/LikesTest.php @@ -13,14 +13,6 @@ class LikesTest extends TestCase { use RefreshDatabase; - #[Test] - public function like_uri_attribute_returns_our_permalink(): void - { - $like = Like::factory()->create(); - - $this->assertEquals(config('app.url').'/likes/'.$like->id, $like->uri); - } - #[Test] public function we_can_set_the_author_url(): void {