Remove references to short domain

This commit is contained in:
Jonny Barnes 2025-04-06 17:22:36 +01:00
parent 328c9badb4
commit 7a58287b34
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
27 changed files with 215 additions and 404 deletions

View file

@ -60,7 +60,7 @@ class PasskeysController extends Controller
// RP Entity i.e. the application // RP Entity i.e. the application
$rpEntity = PublicKeyCredentialRpEntity::create( $rpEntity = PublicKeyCredentialRpEntity::create(
config('app.name'), config('app.name'),
config('url.longurl'), config('app.url'),
); );
// User Entity // User Entity
@ -148,7 +148,7 @@ class PasskeysController extends Controller
); );
$securedRelyingPartyId = []; $securedRelyingPartyId = [];
if (App::environment('local', 'development')) { if (App::environment('local', 'development')) {
$securedRelyingPartyId = [config('url.longurl')]; $securedRelyingPartyId = [config('app.url')];
} }
$ceremonyStepManagerFactory->setSecuredRelyingPartyId($securedRelyingPartyId); $ceremonyStepManagerFactory->setSecuredRelyingPartyId($securedRelyingPartyId);
@ -165,7 +165,7 @@ class PasskeysController extends Controller
$publicKeyCredentialSource = $authenticatorAttestationResponseValidator->check( $publicKeyCredentialSource = $authenticatorAttestationResponseValidator->check(
authenticatorAttestationResponse: $publicKeyCredential->response, authenticatorAttestationResponse: $publicKeyCredential->response,
publicKeyCredentialCreationOptions: $publicKeyCredentialCreationOptions, publicKeyCredentialCreationOptions: $publicKeyCredentialCreationOptions,
request: config('url.longurl'), request: config('app.url'),
securedRelyingPartyId: $securedRelyingPartyId, securedRelyingPartyId: $securedRelyingPartyId,
); );
@ -258,7 +258,7 @@ class PasskeysController extends Controller
); );
$securedRelyingPartyId = []; $securedRelyingPartyId = [];
if (App::environment('local', 'development')) { if (App::environment('local', 'development')) {
$securedRelyingPartyId = [config('url.longurl')]; $securedRelyingPartyId = [config('app.url')];
} }
$ceremonyStepManagerFactory->setSecuredRelyingPartyId($securedRelyingPartyId); $ceremonyStepManagerFactory->setSecuredRelyingPartyId($securedRelyingPartyId);
@ -277,7 +277,7 @@ class PasskeysController extends Controller
credentialId: $publicKeyCredentialSource, credentialId: $publicKeyCredentialSource,
authenticatorAssertionResponse: $publicKeyCredential->response, authenticatorAssertionResponse: $publicKeyCredential->response,
publicKeyCredentialRequestOptions: $publicKeyCredentialRequestOptions, publicKeyCredentialRequestOptions: $publicKeyCredentialRequestOptions,
request: config('url.longurl'), request: config('app.url'),
userHandle: null, userHandle: null,
securedRelyingPartyId: $securedRelyingPartyId, securedRelyingPartyId: $securedRelyingPartyId,
); );

View file

@ -122,8 +122,8 @@ class FeedsController extends Controller
foreach ($notes as $key => $note) { foreach ($notes as $key => $note) {
$data['items'][$key] = [ $data['items'][$key] = [
'id' => $note->longurl, 'id' => $note->uri,
'url' => $note->longurl, 'url' => $note->uri,
'content_text' => $note->content, 'content_text' => $note->content,
'date_published' => $note->created_at->tz('UTC')->toRfc3339String(), 'date_published' => $note->created_at->tz('UTC')->toRfc3339String(),
'date_modified' => $note->updated_at->tz('UTC')->toRfc3339String(), 'date_modified' => $note->updated_at->tz('UTC')->toRfc3339String(),
@ -164,7 +164,7 @@ class FeedsController extends Controller
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.display_name'), 'name' => config('user.display_name'),
'url' => config('url.longurl'), 'url' => config('app.url'),
], ],
'children' => $items, 'children' => $items,
], 200, [ ], 200, [
@ -183,8 +183,8 @@ class FeedsController extends Controller
$items[] = [ $items[] = [
'type' => 'entry', 'type' => 'entry',
'published' => $note->created_at, 'published' => $note->created_at,
'uid' => $note->longurl, 'uid' => $note->uri,
'url' => $note->longurl, 'url' => $note->uri,
'content' => [ 'content' => [
'text' => $note->getRawOriginal('note'), 'text' => $note->getRawOriginal('note'),
'html' => $note->note, 'html' => $note->note,
@ -200,7 +200,7 @@ class FeedsController extends Controller
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.display_name'), 'name' => config('user.display_name'),
'url' => config('url.longurl'), 'url' => config('app.url'),
], ],
'children' => $items, 'children' => $items,
], 200, [ ], 200, [

View file

@ -1,55 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
/**
* @psalm-suppress UnusedClass
*/
class ShortURLsController extends Controller
{
/*
|--------------------------------------------------------------------------
| Short URL Controller
|--------------------------------------------------------------------------
|
| This redirects the short urls to long ones
|
*/
/**
* Redirect from '/' to the long url.
*/
public function baseURL(): RedirectResponse
{
return redirect(config('app.url'));
}
/**
* Redirect from '/@' to a twitter profile.
*/
public function twitter(): RedirectResponse
{
return redirect('https://twitter.com/jonnybarnes');
}
/**
* Redirect a short url of this site out to a long one based on post type.
*
* Further redirects may happen.
*/
public function expandType(string $type, string $postId): RedirectResponse
{
if ($type === 't') {
$type = 'notes';
}
if ($type === 'b') {
$type = 'blog/s';
}
return redirect(config('app.url') . '/' . $type . '/' . $postId);
}
}

View file

@ -53,7 +53,7 @@ class ProcessWebMention implements ShouldQueue
// check webmention still references target // check webmention still references target
// we try each type of mention (reply/like/repost) // we try each type of mention (reply/like/repost)
if ($webmention->type === 'in-reply-to') { if ($webmention->type === 'in-reply-to') {
if ($parser->checkInReplyTo($microformats, $this->note->longurl) === false) { if ($parser->checkInReplyTo($microformats, $this->note->uri) === false) {
// it doesnt so delete // it doesnt so delete
$webmention->delete(); $webmention->delete();
@ -67,7 +67,7 @@ class ProcessWebMention implements ShouldQueue
return; return;
} }
if ($webmention->type === 'like-of') { if ($webmention->type === 'like-of') {
if ($parser->checkLikeOf($microformats, $this->note->longurl) === false) { if ($parser->checkLikeOf($microformats, $this->note->uri) === false) {
// it doesnt so delete // it doesnt so delete
$webmention->delete(); $webmention->delete();
@ -75,7 +75,7 @@ class ProcessWebMention implements ShouldQueue
} // note we dont need to do anything if it still is a like } // note we dont need to do anything if it still is a like
} }
if ($webmention->type === 'repost-of') { if ($webmention->type === 'repost-of') {
if ($parser->checkRepostOf($microformats, $this->note->longurl) === false) { if ($parser->checkRepostOf($microformats, $this->note->uri) === false) {
// it doesnt so delete // it doesnt so delete
$webmention->delete(); $webmention->delete();
@ -89,7 +89,7 @@ class ProcessWebMention implements ShouldQueue
$type = $parser->getMentionType($microformats); // throw error here? $type = $parser->getMentionType($microformats); // throw error here?
dispatch(new SaveProfileImage($microformats)); dispatch(new SaveProfileImage($microformats));
$webmention->source = $this->source; $webmention->source = $this->source;
$webmention->target = $this->note->longurl; $webmention->target = $this->note->uri;
$webmention->commentable_id = $this->note->id; $webmention->commentable_id = $this->note->id;
$webmention->commentable_type = Note::class; $webmention->commentable_type = Note::class;
$webmention->type = $type; $webmention->type = $type;

View file

@ -45,7 +45,7 @@ class SendWebMentions implements ShouldQueue
$guzzle = resolve(Client::class); $guzzle = resolve(Client::class);
$guzzle->post($endpoint, [ $guzzle->post($endpoint, [
'form_params' => [ 'form_params' => [
'source' => $this->note->longurl, 'source' => $this->note->uri,
'target' => $url, 'target' => $url,
], ],
]); ]);
@ -61,7 +61,7 @@ class SendWebMentions implements ShouldQueue
public function discoverWebmentionEndpoint(string $url): ?string public function discoverWebmentionEndpoint(string $url): ?string
{ {
// lets not send webmentions to myself // lets not send webmentions to myself
if (parse_url($url, PHP_URL_HOST) === config('url.longurl')) { if (parse_url($url, PHP_URL_HOST) === parse_url(config('app.url'), PHP_URL_HOST)) {
return null; return null;
} }
if (Str::startsWith($url, '/notes/tagged/')) { if (Str::startsWith($url, '/notes/tagged/')) {

View file

@ -26,7 +26,7 @@ class Bookmark extends Model
return $this->belongsToMany('App\Models\Tag'); return $this->belongsToMany('App\Models\Tag');
} }
protected function longurl(): Attribute protected function local_uri(): Attribute
{ {
return Attribute::get( return Attribute::get(
get: fn () => config('app.url') . '/bookmarks/' . $this->id, get: fn () => config('app.url') . '/bookmarks/' . $this->id,

View file

@ -124,7 +124,7 @@ class Note extends Model
public function getNoteAttribute(?string $value): ?string public function getNoteAttribute(?string $value): ?string
{ {
if ($value === null && $this->place !== null) { if ($value === null && $this->place !== null) {
$value = '📍: <a href="' . $this->place->longurl . '">' . $this->place->name . '</a>'; $value = '📍: <a href="' . $this->place->uri . '">' . $this->place->name . '</a>';
} }
// if $value is still null, just return null // if $value is still null, just return null
@ -172,16 +172,11 @@ class Note extends Model
return (string) resolve(Numbers::class)->numto60($this->id); return (string) resolve(Numbers::class)->numto60($this->id);
} }
public function getLongurlAttribute(): string public function getUriAttribute(): string
{ {
return config('app.url') . '/notes/' . $this->nb60id; return config('app.url') . '/notes/' . $this->nb60id;
} }
public function getShorturlAttribute(): string
{
return config('url.shorturl') . '/notes/' . $this->nb60id;
}
public function getIso8601Attribute(): string public function getIso8601Attribute(): string
{ {
return $this->updated_at->toISO8601String(); return $this->updated_at->toISO8601String();

View file

@ -74,24 +74,10 @@ class Place extends Model
])); ]));
} }
protected function longurl(): Attribute
{
return Attribute::get(
get: fn ($value, $attributes) => config('app.url') . '/places/' . $attributes['slug'],
);
}
protected function shorturl(): Attribute
{
return Attribute::get(
get: fn ($value, $attributes) => config('url.shorturl') . '/places/' . $attributes['slug'],
);
}
protected function uri(): Attribute protected function uri(): Attribute
{ {
return Attribute::get( return Attribute::get(
get: fn () => $this->longurl, get: static fn ($value, $attributes) => config('app.url') . '/places/' . $attributes['slug'],
); );
} }

View file

@ -27,6 +27,6 @@ class HCardService
$data['longitude'] = Arr::get($request, 'longitude'); $data['longitude'] = Arr::get($request, 'longitude');
} }
return resolve(PlaceService::class)->createPlace($data)->longurl; return resolve(PlaceService::class)->createPlace($data)->uri;
} }
} }

View file

@ -18,17 +18,17 @@ class HEntryService
public function process(array $request, ?string $client = null): ?string public function process(array $request, ?string $client = null): ?string
{ {
if (Arr::get($request, 'properties.like-of') || Arr::get($request, 'like-of')) { if (Arr::get($request, 'properties.like-of') || Arr::get($request, 'like-of')) {
return resolve(LikeService::class)->create($request)->longurl; return resolve(LikeService::class)->create($request)->url;
} }
if (Arr::get($request, 'properties.bookmark-of') || Arr::get($request, 'bookmark-of')) { if (Arr::get($request, 'properties.bookmark-of') || Arr::get($request, 'bookmark-of')) {
return resolve(BookmarkService::class)->create($request)->longurl; return resolve(BookmarkService::class)->create($request)->uri;
} }
if (Arr::get($request, 'properties.name') || Arr::get($request, 'name')) { if (Arr::get($request, 'properties.name') || Arr::get($request, 'name')) {
return resolve(ArticleService::class)->create($request)->longurl; return resolve(ArticleService::class)->create($request)->link;
} }
return resolve(NoteService::class)->create($request, $client)->longurl; return resolve(NoteService::class)->create($request, $client)->uri;
} }
} }

View file

@ -1,32 +0,0 @@
<?php
/*
* Here we set the long and short URLs our app shall use
* You can override these settings in the .env file
*/
return [
/*
|--------------------------------------------------------------------------
| Application Long URL
|--------------------------------------------------------------------------
|
| The long URL for the application
|
*/
'longurl' => env('APP_LONGURL', 'longurl.local'),
/*
|--------------------------------------------------------------------------
| Application Short URL
|--------------------------------------------------------------------------
|
| The short URL for the application
|
*/
'shorturl' => env('APP_SHORTURL', 'shorturl.local'),
];

View file

@ -3,7 +3,7 @@
<channel> <channel>
<title>{{ config('user.display_name') }}</title> <title>{{ config('user.display_name') }}</title>
<atom:link href="{{ config('app.url') }}/blog/feed.rss" rel="self" type="application/rss+xml" /> <atom:link href="{{ config('app.url') }}/blog/feed.rss" rel="self" type="application/rss+xml" />
<description>An RSS feed of the blog posts found on {{ config('url.longurl') }}</description> <description>An RSS feed of the blog posts found on {{ config('app.url') }}</description>
<link>{{ config('app.url') }}/blog</link> <link>{{ config('app.url') }}/blog</link>
<lastBuildDate>{{ $buildDate }}</lastBuildDate> <lastBuildDate>{{ $buildDate }}</lastBuildDate>
<ttl>1800</ttl> <ttl>1800</ttl>

View file

@ -7,15 +7,15 @@
@foreach($bookmarks as $bookmark) @foreach($bookmarks as $bookmark)
<div class="h-entry"> <div class="h-entry">
<div class="bookmark-link"> <div class="bookmark-link">
<a class="u-bookmark-of<?php if ($bookmark->name !== null) { echo ' h-cite'; } ?>" href="{{ $bookmark->url }}"> <a class="u-bookmark-of<?php if ($bookmark->name !== null) { echo ' h-cite'; } ?>" href="{{ $bookmark->uri }}">
@isset($bookmark->name) @isset($bookmark->name)
{{ $bookmark->name }} {{ $bookmark->name }}
@endisset @endisset
@empty($bookmark->name) @empty($bookmark->name)
{{ $bookmark->url }} {{ $bookmark->uri }}
@endempty @endempty
</a> &nbsp; <a href="{{ $bookmark->longurl }}">🔗</a> </a> &nbsp; <a href="{{ $bookmark->uri }}">🔗</a>
</div> </div>
@isset($bookmark->content) @isset($bookmark->content)
<p>{{ $bookmark->content }}</p> <p>{{ $bookmark->content }}</p>

View file

@ -8,15 +8,15 @@
@foreach($bookmarks as $bookmark) @foreach($bookmarks as $bookmark)
<div class="h-entry"> <div class="h-entry">
<div class="bookmark-link"> <div class="bookmark-link">
<a class="u-bookmark-of<?php if ($bookmark->name !== null) { echo ' h-cite'; } ?>" href="{{ $bookmark->url }}"> <a class="u-bookmark-of<?php if ($bookmark->name !== null) { echo ' h-cite'; } ?>" href="{{ $bookmark->uri }}">
@isset($bookmark->name) @isset($bookmark->name)
{{ $bookmark->name }} {{ $bookmark->name }}
@endisset @endisset
@empty($bookmark->name) @empty($bookmark->name)
{{ $bookmark->url }} {{ $bookmark->uri }}
@endempty @endempty
</a> &nbsp; <a href="{{ $bookmark->longurl }}">🔗</a> </a> &nbsp; <a href="{{ $bookmark->uri }}">🔗</a>
</div> </div>
@isset($bookmark->content) @isset($bookmark->content)
<p>{{ $bookmark->content }}</p> <p>{{ $bookmark->content }}</p>

View file

@ -8,8 +8,8 @@
@foreach($notes as $note) @foreach($notes as $note)
<entry> <entry>
<title>{{ strip_tags($note->note) }}</title> <title>{{ strip_tags($note->note) }}</title>
<link href="{{ $note->longurl }}" /> <link href="{{ $note->uri }}" />
<id>{{ $note->longurl }}</id> <id>{{ $note->uri }}</id>
<updated>{{ $note->updated_at->toAtomString() }}</updated> <updated>{{ $note->updated_at->toAtomString() }}</updated>
<content type="html">{{ $note->note }}</content> <content type="html">{{ $note->note }}</content>
<author> <author>

View file

@ -3,7 +3,7 @@
<channel> <channel>
<title>{{ config('user.display_name') }}</title> <title>{{ config('user.display_name') }}</title>
<atom:link href="{{ config('app.url') }}/notes/feed.rss" rel="self" type="application/rss+xml" /> <atom:link href="{{ config('app.url') }}/notes/feed.rss" rel="self" type="application/rss+xml" />
<description>An RSS feed of the notes found on {{ config('url.longurl') }}</description> <description>An RSS feed of the notes found on {{ config('app.url') }}</description>
<link>{{ config('app.url') }}/notes</link> <link>{{ config('app.url') }}/notes</link>
<lastBuildDate>{{ $buildDate }}</lastBuildDate> <lastBuildDate>{{ $buildDate }}</lastBuildDate>
<ttl>1800</ttl> <ttl>1800</ttl>
@ -16,8 +16,8 @@
{!! $note->note !!} {!! $note->note !!}
]]> ]]>
</description> </description>
<link>{{ $note->longurl }}</link> <link>{{ $note->uri }}</link>
<guid>{{ $note->longurl}}</guid> <guid>{{ $note->uri}}</guid>
<pubDate>{{ $note->pubdate }}</pubDate> <pubDate>{{ $note->pubdate }}</pubDate>
</item> </item>
@endforeach @endforeach

View file

@ -34,7 +34,7 @@
@if($note->client) via <a class="client" href="{{ $note->client->client_url }}">{{ $note->client->client_name }}</a>@endif @if($note->client) via <a class="client" href="{{ $note->client->client_url }}">{{ $note->client->client_name }}</a>@endif
@if($note->place) @if($note->place)
@if($note->getOriginal('note')) @if($note->getOriginal('note'))
in <span class="p-location h-card"><a class="p-name u-url" href="{{ $note->place->longurl }}">{{ $note->address }}</a><data class="p-latitude" value="{{ $note->place->latitude }}"></data><data class="p-longitude" value="{{ $note->place->longitude }}"></data></span> in <span class="p-location h-card"><a class="p-name u-url" href="{{ $note->place->uri }}">{{ $note->address }}</a><data class="p-latitude" value="{{ $note->place->latitude }}"></data><data class="p-longitude" value="{{ $note->place->longitude }}"></data></span>
@endif @endif
@elseif($note->address) @elseif($note->address)
in <span class="p-location h-adr">{!! $note->address !!}<data class="p-latitude" value="{{ $note->latitude }}"></data><data class="p-longitude" value="{{ $note->longitude }}"></data></span> in <span class="p-location h-adr">{!! $note->address !!}<data class="p-latitude" value="{{ $note->latitude }}"></data><data class="p-longitude" value="{{ $note->longitude }}"></data></span>

View file

@ -23,7 +23,6 @@ use App\Http\Controllers\MicropubMediaController;
use App\Http\Controllers\NotesController; use App\Http\Controllers\NotesController;
use App\Http\Controllers\PlacesController; use App\Http\Controllers\PlacesController;
use App\Http\Controllers\SearchController; use App\Http\Controllers\SearchController;
use App\Http\Controllers\ShortURLsController;
use App\Http\Controllers\WebMentionsController; use App\Http\Controllers\WebMentionsController;
use App\Http\Middleware\CorsHeaders; use App\Http\Middleware\CorsHeaders;
use App\Http\Middleware\MyAuthMiddleware; use App\Http\Middleware\MyAuthMiddleware;
@ -41,7 +40,6 @@ use Illuminate\Support\Facades\Route;
| |
*/ */
Route::domain(config('url.longurl'))->group(function () {
Route::get('/', [FrontPageController::class, 'index']); Route::get('/', [FrontPageController::class, 'index']);
// Static project page // Static project page
@ -223,19 +221,3 @@ Route::domain(config('url.longurl'))->group(function () {
// Search // Search
Route::get('search', [SearchController::class, 'search']); Route::get('search', [SearchController::class, 'search']);
});
// Short URL
Route::domain(config('url.shorturl'))->group(function () {
Route::get('/', [ShortURLsController::class, 'baseURL']);
Route::get('@', [ShortURLsController::class, 'twitter']);
Route::get('{type}/{id}', [ShortURLsController::class, 'expandType'])->where(
[
'type' => '[bt]',
'id' => '[0-9A-HJ-NP-Z_a-km-z]+',
]
);
Route::get('h/{id}', [ShortURLsController::class, 'redirect']);
});

View file

@ -64,7 +64,7 @@ class FeedsTest extends TestCase
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.display_name'), 'name' => config('user.display_name'),
'url' => config('url.longurl'), 'url' => config('app.url'),
], ],
'children' => [[ 'children' => [[
'type' => 'entry', 'type' => 'entry',
@ -122,7 +122,7 @@ class FeedsTest extends TestCase
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.display_name'), 'name' => config('user.display_name'),
'url' => config('url.longurl'), 'url' => config('app.url'),
], ],
'children' => [[ 'children' => [[
'type' => 'entry', 'type' => 'entry',

View file

@ -299,7 +299,7 @@ class MicropubControllerTest extends TestCase
'type' => ['h-entry'], 'type' => ['h-entry'],
'properties' => [ 'properties' => [
'content' => [$note], 'content' => [$note],
'location' => [$place->longurl], 'location' => [$place->uri],
], ],
], ],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()] ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
@ -499,7 +499,7 @@ class MicropubControllerTest extends TestCase
'/api/post', '/api/post',
[ [
'action' => 'update', 'action' => 'update',
'url' => $note->longurl, 'url' => $note->uri,
'replace' => [ 'replace' => [
'content' => ['replaced content'], 'content' => ['replaced content'],
], ],
@ -519,7 +519,7 @@ class MicropubControllerTest extends TestCase
'/api/post', '/api/post',
[ [
'action' => 'update', 'action' => 'update',
'url' => $note->longurl, 'url' => $note->uri,
'add' => [ 'add' => [
'syndication' => [ 'syndication' => [
'https://www.swarmapp.com/checkin/123', 'https://www.swarmapp.com/checkin/123',
@ -546,7 +546,7 @@ class MicropubControllerTest extends TestCase
'/api/post', '/api/post',
[ [
'action' => 'update', 'action' => 'update',
'url' => $note->longurl, 'url' => $note->uri,
'add' => [ 'add' => [
'photo' => ['https://example.org/photo.jpg'], 'photo' => ['https://example.org/photo.jpg'],
], ],
@ -607,7 +607,7 @@ class MicropubControllerTest extends TestCase
'/api/post', '/api/post',
[ [
'action' => 'update', 'action' => 'update',
'url' => $note->longurl, 'url' => $note->uri,
'morph' => [ // or any other unsupported update type 'morph' => [ // or any other unsupported update type
'syndication' => ['https://www.swarmapp.com/checkin/123'], 'syndication' => ['https://www.swarmapp.com/checkin/123'],
], ],
@ -646,7 +646,7 @@ class MicropubControllerTest extends TestCase
'/api/post', '/api/post',
[ [
'action' => 'update', 'action' => 'update',
'url' => $note->longurl, 'url' => $note->uri,
'replace' => [ 'replace' => [
'syndication' => [ 'syndication' => [
'https://www.swarmapp.com/checkin/the-id', 'https://www.swarmapp.com/checkin/the-id',

View file

@ -31,7 +31,7 @@ class NotesControllerTest extends TestCase
public function specificNotePageLoads(): void public function specificNotePageLoads(): void
{ {
$note = Note::factory()->create(); $note = Note::factory()->create();
$response = $this->get($note->longurl); $response = $this->get($note->uri);
$response->assertViewHas('note'); $response->assertViewHas('note');
} }
@ -51,7 +51,7 @@ class NotesControllerTest extends TestCase
{ {
$note = Note::factory()->create(); $note = Note::factory()->create();
$response = $this->get('/note/' . $note->id); $response = $this->get('/note/' . $note->id);
$response->assertRedirect($note->longurl); $response->assertRedirect($note->uri);
} }
/** /**

View file

@ -30,7 +30,7 @@ class PlacesTest extends TestCase
public function singlePlacePageLoads(): void public function singlePlacePageLoads(): void
{ {
$place = Place::factory()->create(); $place = Place::factory()->create();
$response = $this->get($place->longurl); $response = $this->get($place->uri);
$response->assertViewHas('place', $place); $response->assertViewHas('place', $place);
} }

View file

@ -1,39 +0,0 @@
<?php
declare(strict_types=1);
namespace Tests\Feature;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ShortURLsControllerTest extends TestCase
{
#[Test]
public function shortDomainRedirectsToLongDomain(): void
{
$response = $this->get('https://' . config('url.shorturl'));
$response->assertRedirect(config('app.url'));
}
#[Test]
public function shortDomainSlashAtRedirectsToTwitter(): void
{
$response = $this->get('https://' . config('url.shorturl') . '/@');
$response->assertRedirect('https://twitter.com/jonnybarnes');
}
#[Test]
public function shortDomainSlashTRedirectsToLongDomainSlashNotes(): void
{
$response = $this->get('https://' . config('url.shorturl') . '/t/E');
$response->assertRedirect(config('app.url') . '/notes/E');
}
#[Test]
public function shortDomainSlashBRedirectsToLongDomainSlashBlog(): void
{
$response = $this->get('https://' . config('url.shorturl') . '/b/1');
$response->assertRedirect(config('app.url') . '/blog/s/1');
}
}

View file

@ -82,7 +82,7 @@ class WebMentionsControllerTest extends TestCase
$response = $this->call('POST', '/webmention', [ $response = $this->call('POST', '/webmention', [
'source' => 'https://example.org/post/123', 'source' => 'https://example.org/post/123',
'target' => $note->longurl, 'target' => $note->uri,
]); ]);
$response->assertStatus(202); $response->assertStatus(202);

View file

@ -94,12 +94,12 @@ class ProcessWebMentionJobTest extends TestCase
$source = 'https://aaronpk.localhost/reply/1'; $source = 'https://aaronpk.localhost/reply/1';
WebMention::factory()->create([ WebMention::factory()->create([
'source' => $source, 'source' => $source,
'target' => $note->longurl, 'target' => $note->uri,
]); ]);
$html = <<<HTML $html = <<<HTML
<div class="h-entry"> <div class="h-entry">
<p>In reply to <a class="u-in-reply-to" href="{$note->longurl}">a note</a></p> <p>In reply to <a class="u-in-reply-to" href="{$note->uri}">a note</a></p>
<div class="e-content">Updated reply</div> <div class="e-content">Updated reply</div>
</div> </div>
HTML; HTML;
@ -117,7 +117,7 @@ class ProcessWebMentionJobTest extends TestCase
'source' => $source, 'source' => $source,
'type' => 'in-reply-to', 'type' => 'in-reply-to',
// phpcs:ignore Generic.Files.LineLength.TooLong // phpcs:ignore Generic.Files.LineLength.TooLong
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"content": [{"html": "Updated reply", "value": "Updated reply"}], "in-reply-to": ["' . $note->longurl . '"]}}], "rel-urls": []}', 'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"content": [{"html": "Updated reply", "value": "Updated reply"}], "in-reply-to": ["' . $note->uri . '"]}}], "rel-urls": []}',
]); ]);
} }

View file

@ -115,14 +115,6 @@ class NotesTest extends TestCase
$this->assertEquals($expected, $note->note); $this->assertEquals($expected, $note->note);
} }
#[Test]
public function shorturlMethodReturnsExpectedValue(): void
{
$note = Note::factory()->make();
$note->id = 14;
$this->assertEquals(config('url.shorturl') . '/notes/E', $note->shorturl);
}
#[Test] #[Test]
public function weGetLatitudeLongitudeValuesOfAssociatedPlaceOfNote(): void public function weGetLatitudeLongitudeValuesOfAssociatedPlaceOfNote(): void
{ {
@ -382,11 +374,11 @@ class NotesTest extends TestCase
public function markdown_content_gets_converted(): void public function markdown_content_gets_converted(): void
{ {
$note = Note::factory()->create([ $note = Note::factory()->create([
'note' => 'The best search engine? https://duckduckgo.com', 'note' => 'The best search engine? https://kagi.com',
]); ]);
$this->assertSame( $this->assertSame(
'<p>The best search engine? <a href="https://duckduckgo.com">https://duckduckgo.com</a></p>' . PHP_EOL, '<p>The best search engine? <a href="https://kagi.com">https://kagi.com</a></p>' . PHP_EOL,
$note->note $note->note
); );
} }

View file

@ -40,24 +40,6 @@ class PlacesTest extends TestCase
$this->assertEquals('the-bridgewater-pub', $nearby[0]->slug); $this->assertEquals('the-bridgewater-pub', $nearby[0]->slug);
} }
#[Test]
public function getLongurl(): void
{
$place = Place::factory()->create([
'name' => 'The Bridgewater Pub',
]);
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->longurl);
}
#[Test]
public function getShorturl()
{
$place = Place::factory()->create([
'name' => 'The Bridgewater Pub',
]);
$this->assertEquals(config('url.shorturl') . '/places/the-bridgewater-pub', $place->shorturl);
}
#[Test] #[Test]
public function getUri(): void public function getUri(): void
{ {