MTM Micropub improvements and WebMention fix #79
3 changed files with 60 additions and 2 deletions
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>
commit
0a13d27d6f
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -723,8 +723,8 @@ ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
|
|||
|
||||
CREATE TABLE public.webmentions (
|
||||
id integer NOT NULL,
|
||||
source character varying(255) NOT NULL,
|
||||
target character varying(255) NOT NULL,
|
||||
source text NOT NULL,
|
||||
target text NOT NULL,
|
||||
commentable_id integer,
|
||||
commentable_type character varying(255),
|
||||
type character varying(255),
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
public function webmention_repost_gets_deleted_when_repost_of_value_changes(): void
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue