Compare commits
8 changed files with 5 additions and 94 deletions
|
|
@ -25,7 +25,7 @@ class Bookmark extends Model
|
||||||
return $this->belongsToMany('App\Models\Tag');
|
return $this->belongsToMany('App\Models\Tag');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function uri(): Attribute
|
protected function localUri(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::get(
|
return Attribute::get(
|
||||||
get: fn () => config('app.url').'/bookmarks/'.$this->id,
|
get: fn () => config('app.url').'/bookmarks/'.$this->id,
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,6 @@ class Like extends Model
|
||||||
use FilterHtml;
|
use FilterHtml;
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected function uri(): Attribute
|
|
||||||
{
|
|
||||||
return Attribute::get(
|
|
||||||
get: fn () => config('app.url').'/likes/'.$this->id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function url(): Attribute
|
protected function url(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::set(
|
return Attribute::set(
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class EntryHandler implements MicropubHandlerInterface
|
||||||
|
|
||||||
$dataArray = $data->toArray();
|
$dataArray = $data->toArray();
|
||||||
$location = match (true) {
|
$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['bookmark-of']) => resolve(BookmarkService::class)->create($dataArray)->uri,
|
||||||
isset($dataArray['name']) => resolve(ArticleService::class)->create($dataArray)->uri,
|
isset($dataArray['name']) => resolve(ArticleService::class)->create($dataArray)->uri,
|
||||||
default => resolve(NoteService::class)->create($dataArray)->uri,
|
default => resolve(NoteService::class)->create($dataArray)->uri,
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('notes', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('shorturl');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('notes', function (Blueprint $table) {
|
|
||||||
$table->string('shorturl', 20)->nullable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
</blockquote>
|
</blockquote>
|
||||||
@endisset
|
@endisset
|
||||||
<div>
|
<div>
|
||||||
<a href="{{ $like->uri }}"><time class="dt-published" datetime="{{ $like->updated_at->toISO8601String() }}" title="{{ $like->updated_at->toISO8601String() }}">{{ $like->updated_at->diffForHumans() }}</time></a>
|
<a href="/likes/{{ $like->id }}"><time class="dt-published" datetime="{{ $like->updated_at->toISO8601String() }}" title="{{ $like->updated_at->toISO8601String() }}">{{ $like->updated_at->diffForHumans() }}</time></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,10 @@ class BookmarksTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
public function bookmark_uri_attribute_returns_correct_url(): void
|
public function bookmark_local_uri_attribute_returns_correct_url(): void
|
||||||
{
|
{
|
||||||
$bookmark = Bookmark::factory()->create();
|
$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]
|
#[Test]
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ use App\Jobs\SendWebMentions;
|
||||||
use App\Jobs\SyndicateNoteToBluesky;
|
use App\Jobs\SyndicateNoteToBluesky;
|
||||||
use App\Jobs\SyndicateNoteToMastodon;
|
use App\Jobs\SyndicateNoteToMastodon;
|
||||||
use App\Models\Article;
|
use App\Models\Article;
|
||||||
use App\Models\Bookmark;
|
|
||||||
use App\Models\Like;
|
|
||||||
use App\Models\Media;
|
use App\Models\Media;
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
use App\Models\Place;
|
use App\Models\Place;
|
||||||
|
|
@ -885,50 +883,6 @@ class MicropubControllerTest extends TestCase
|
||||||
$this->assertStringStartsWith(config('app.url').'/blog/', $response->headers->get('Location'));
|
$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]
|
#[Test]
|
||||||
public function micropub_client_api_request_creates_an_unpublished_article_when_post_status_is_draft(): void
|
public function micropub_client_api_request_creates_an_unpublished_article_when_post_status_is_draft(): void
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,6 @@ class LikesTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
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]
|
#[Test]
|
||||||
public function we_can_set_the_author_url(): void
|
public function we_can_set_the_author_url(): void
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue