Remove Twitter POSSE support
This commit is contained in:
parent
52b1220068
commit
88e1246f8b
15 changed files with 1 additions and 365 deletions
|
@ -5,9 +5,7 @@ declare(strict_types=1);
|
|||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\ProcessBookmark;
|
||||
use App\Jobs\SyndicateBookmarkToTwitter;
|
||||
use App\Models\Bookmark;
|
||||
use App\Models\SyndicationTarget;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Tests\TestCase;
|
||||
|
@ -37,25 +35,16 @@ class BookmarksTest extends TestCase
|
|||
{
|
||||
Queue::fake();
|
||||
|
||||
SyndicationTarget::factory()->create([
|
||||
'uid' => 'https://twitter.com/jonnybarnes',
|
||||
'service_name' => 'Twitter',
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'Authorization' => 'Bearer ' . $this->getToken(),
|
||||
])->post('/api/post', [
|
||||
'h' => 'entry',
|
||||
'bookmark-of' => 'https://example.org/blog-post',
|
||||
'mp-syndicate-to' => [
|
||||
'https://twitter.com/jonnybarnes',
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertJson(['response' => 'created']);
|
||||
|
||||
Queue::assertPushed(ProcessBookmark::class);
|
||||
Queue::assertPushed(SyndicateBookmarkToTwitter::class);
|
||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||
}
|
||||
|
||||
|
@ -64,52 +53,18 @@ class BookmarksTest extends TestCase
|
|||
{
|
||||
Queue::fake();
|
||||
|
||||
SyndicationTarget::factory()->create([
|
||||
'uid' => 'https://twitter.com/jonnybarnes',
|
||||
'service_name' => 'Twitter',
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'Authorization' => 'Bearer ' . $this->getToken(),
|
||||
])->json('POST', '/api/post', [
|
||||
'type' => ['h-entry'],
|
||||
'properties' => [
|
||||
'bookmark-of' => ['https://example.org/blog-post'],
|
||||
'mp-syndicate-to' => [
|
||||
'https://twitter.com/jonnybarnes',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertJson(['response' => 'created']);
|
||||
|
||||
Queue::assertPushed(ProcessBookmark::class);
|
||||
Queue::assertPushed(SyndicateBookmarkToTwitter::class);
|
||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function whenTheBookmarkIsMarkedForPostingToTwitterCheckWeInvokeTheCorrectJob(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
||||
SyndicationTarget::factory()->create([
|
||||
'uid' => 'https://twitter.com/jonnybarnes',
|
||||
'service_name' => 'Twitter',
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'Authorization' => 'Bearer ' . $this->getToken(),
|
||||
])->post('/api/post', [
|
||||
'h' => 'entry',
|
||||
'bookmark-of' => 'https://example.org/blog-post',
|
||||
'mp-syndicate-to' => 'https://twitter.com/jonnybarnes',
|
||||
]);
|
||||
|
||||
$response->assertJson(['response' => 'created']);
|
||||
|
||||
Queue::assertPushed(ProcessBookmark::class);
|
||||
Queue::assertPushed(SyndicateBookmarkToTwitter::class);
|
||||
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Contact;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BridgyPosseTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function notesWeWantCopiedToTwitterShouldHaveNecessaryMarkup(): void
|
||||
{
|
||||
Contact::factory()->create([
|
||||
'nick' => 'joe',
|
||||
'twitter' => 'joe__',
|
||||
]);
|
||||
$note = Note::factory()->create(['note' => 'Hi @joe']);
|
||||
|
||||
$response = $this->get($note->longurl);
|
||||
|
||||
$html = $response->content();
|
||||
$this->assertStringContainsString('Hi @joe__', $html);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ namespace Tests\Feature;
|
|||
|
||||
use App\Jobs\SendWebMentions;
|
||||
use App\Jobs\SyndicateNoteToMastodon;
|
||||
use App\Jobs\SyndicateNoteToTwitter;
|
||||
use App\Models\Media;
|
||||
use App\Models\Note;
|
||||
use App\Models\Place;
|
||||
|
@ -145,7 +144,6 @@ class MicropubControllerTest extends TestCase
|
|||
'h' => 'entry',
|
||||
'content' => $note,
|
||||
'mp-syndicate-to' => [
|
||||
'https://twitter.com/jonnybarnes',
|
||||
'https://mastodon.social/@jonnybarnes',
|
||||
],
|
||||
],
|
||||
|
@ -153,7 +151,6 @@ class MicropubControllerTest extends TestCase
|
|||
);
|
||||
$response->assertJson(['response' => 'created']);
|
||||
$this->assertDatabaseHas('notes', ['note' => $note]);
|
||||
Queue::assertPushed(SyndicateNoteToTwitter::class);
|
||||
Queue::assertPushed(SyndicateNoteToMastodon::class);
|
||||
}
|
||||
|
||||
|
@ -248,10 +245,6 @@ class MicropubControllerTest extends TestCase
|
|||
'path' => 'test-photo.jpg',
|
||||
'type' => 'image',
|
||||
]);
|
||||
SyndicationTarget::factory()->create([
|
||||
'uid' => 'https://twitter.com/jonnybarnes',
|
||||
'service_name' => 'Twitter',
|
||||
]);
|
||||
SyndicationTarget::factory()->create([
|
||||
'uid' => 'https://mastodon.social/@jonnybarnes',
|
||||
'service_name' => 'Mastodon',
|
||||
|
@ -267,7 +260,6 @@ class MicropubControllerTest extends TestCase
|
|||
'content' => [$note],
|
||||
'in-reply-to' => ['https://aaronpk.localhost'],
|
||||
'mp-syndicate-to' => [
|
||||
'https://twitter.com/jonnybarnes',
|
||||
'https://mastodon.social/@jonnybarnes',
|
||||
],
|
||||
'photo' => [config('filesystems.disks.s3.url') . '/test-photo.jpg'],
|
||||
|
@ -279,7 +271,6 @@ class MicropubControllerTest extends TestCase
|
|||
->assertStatus(201)
|
||||
->assertJson(['response' => 'created']);
|
||||
Queue::assertPushed(SendWebMentions::class);
|
||||
Queue::assertPushed(SyndicateNoteToTwitter::class);
|
||||
Queue::assertPushed(SyndicateNoteToMastodon::class);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class NotesControllerTest extends TestCase
|
|||
}
|
||||
|
||||
/** @test */
|
||||
public function unknownNoteGives404()
|
||||
public function unknownNoteGives404(): void
|
||||
{
|
||||
$response = $this->get('/notes/112233');
|
||||
$response->assertNotFound();
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Jobs;
|
||||
|
||||
use App\Jobs\SyndicateBookmarkToTwitter;
|
||||
use App\Models\Bookmark;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SyndicateBookmarkToTwitterJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function weSendBookmarksToTwitter(): void
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$randomNumber = $faker->randomNumber();
|
||||
$json = json_encode([
|
||||
'url' => 'https://twitter.com/' . $randomNumber,
|
||||
]);
|
||||
$mock = new MockHandler([
|
||||
new Response(201, ['Content-Type' => 'application/json'], $json),
|
||||
]);
|
||||
$handler = HandlerStack::create($mock);
|
||||
$client = new Client(['handler' => $handler]);
|
||||
|
||||
$bookmark = Bookmark::factory()->create();
|
||||
$job = new SyndicateBookmarkToTwitter($bookmark);
|
||||
$job->handle($client);
|
||||
|
||||
$this->assertDatabaseHas('bookmarks', [
|
||||
'syndicates' => '{"twitter": "https://twitter.com/' . $randomNumber . '"}',
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit\Jobs;
|
||||
|
||||
use App\Jobs\SyndicateNoteToTwitter;
|
||||
use App\Models\Note;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SyndicateNoteToTwitterJobTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @test */
|
||||
public function weSyndicateNotesToTwitter(): void
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
$randomNumber = $faker->randomNumber();
|
||||
$json = json_encode([
|
||||
'url' => 'https://twitter.com/i/web/status/' . $randomNumber,
|
||||
]);
|
||||
$mock = new MockHandler([
|
||||
new Response(201, ['Content-Type' => 'application/json'], $json),
|
||||
]);
|
||||
$handler = HandlerStack::create($mock);
|
||||
$client = new Client(['handler' => $handler]);
|
||||
|
||||
$note = Note::factory()->create();
|
||||
$job = new SyndicateNoteToTwitter($note);
|
||||
$job->handle($client);
|
||||
|
||||
$this->assertDatabaseHas('notes', [
|
||||
'tweet_id' => $randomNumber,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue