MTM Micropub improvements and WebMention fix #79

Merged
jonny merged 4 commits from develop into main 2026-03-14 17:39:59 +01:00
3 changed files with 60 additions and 2 deletions
Showing only changes of commit 0a13d27d6f - Show all commits

Expand webmentions source and target columns to text

Long brid.gy Bluesky source URLs exceed 255 characters, causing
SQLSTATE[22001] errors. Changed source and target from varchar(255)
to text (no performance impact in PostgreSQL).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Jonny Barnes 2026-03-14 16:32:22 +00:00
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8

View file

@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('webmentions', function (Blueprint $table) {
$table->text('source')->change();
$table->text('target')->change();
});
}
public function down(): void
{
Schema::table('webmentions', function (Blueprint $table) {
$table->string('source')->change();
$table->string('target')->change();
});
}
};

View file

@ -723,8 +723,8 @@ ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
CREATE TABLE public.webmentions ( CREATE TABLE public.webmentions (
id integer NOT NULL, id integer NOT NULL,
source character varying(255) NOT NULL, source text NOT NULL,
target character varying(255) NOT NULL, target text NOT NULL,
commentable_id integer, commentable_id integer,
commentable_type character varying(255), commentable_type character varying(255),
type character varying(255), type character varying(255),

View file

@ -195,6 +195,38 @@ class ProcessWebMentionJobTest extends TestCase
]); ]);
} }
#[Test]
public function webmention_with_long_source_url_gets_saved(): void
{
Queue::fake();
$parser = new Parser;
$html = <<<'HTML'
<div class="h-entry">
I liked <a class="u-like-of" href="/notes/1">a note</a>.
</div>
HTML;
$html = str_replace('href="', 'href="' . config('app.url'), $html);
$mock = new MockHandler([
new Response(200, [], $html),
]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$note = Note::factory()->create();
// Simulate a long brid.gy Bluesky source URL (well over 255 characters)
$source = 'https://brid.gy/comment/bluesky/did:plc:n3jhgiq2ykctnpgzlm6p6b25/at%253A%252F%252Fdid%253Aplc%253An3jhgiq2ykctnpgzlm6p6b25%252Fapp.bsky.feed.post%252F3mfekjuhykb2k/at%253A%252F%252Fdid%253Aplc%253Afsfuwigo5juzdwp23hyianzg%252Fapp.bsky.feed.post%252F3mfemw4rrvs2t';
$job = new ProcessWebMention($note, $source);
$job->handle($parser, $client);
$this->assertGreaterThan(255, strlen($source));
$this->assertDatabaseHas('webmentions', [
'source' => $source,
]);
}
#[Test] #[Test]
public function webmention_repost_gets_deleted_when_repost_of_value_changes(): void public function webmention_repost_gets_deleted_when_repost_of_value_changes(): void
{ {