diff --git a/app/Jobs/SyndicateBookmarkToTwitter.php b/app/Jobs/SyndicateBookmarkToTwitter.php deleted file mode 100644 index 3aaac492..00000000 --- a/app/Jobs/SyndicateBookmarkToTwitter.php +++ /dev/null @@ -1,59 +0,0 @@ -request( - 'POST', - 'https://brid.gy/publish/webmention', - [ - 'form_params' => [ - 'source' => $this->bookmark->longurl, - 'target' => 'https://brid.gy/publish/twitter', - 'bridgy_omit_link' => 'maybe', - ], - ] - ); - //parse for syndication URL - if ($response->getStatusCode() === 201) { - $json = json_decode((string) $response->getBody()); - $syndicates = $this->bookmark->syndicates; - $syndicates['twitter'] = $json->url; - $this->bookmark->syndicates = $syndicates; - $this->bookmark->save(); - } - } -} diff --git a/app/Jobs/SyndicateNoteToTwitter.php b/app/Jobs/SyndicateNoteToTwitter.php deleted file mode 100644 index 4edf10c2..00000000 --- a/app/Jobs/SyndicateNoteToTwitter.php +++ /dev/null @@ -1,57 +0,0 @@ -request( - 'POST', - 'https://brid.gy/publish/webmention', - [ - 'form_params' => [ - 'source' => $this->note->longurl, - 'target' => 'https://brid.gy/publish/twitter', - 'bridgy_omit_link' => 'maybe', - ], - ] - ); - //parse for syndication URL - if ($response->getStatusCode() == 201) { - $json = json_decode((string) $response->getBody()); - $tweet_id = basename(parse_url($json->url, PHP_URL_PATH)); - $this->note->tweet_id = $tweet_id; - $this->note->save(); - } - } -} diff --git a/app/Models/Note.php b/app/Models/Note.php index e385d908..af70aca6 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -279,50 +279,6 @@ class Note extends Model return $oEmbed; } - /** - * Show a specific form of the note for twitter. - * - * That is we swap the contacts names for their known Twitter handles. - */ - public function getTwitterContentAttribute(): string - { - $this->getContacts(); - - // check for contacts - if ($this->contacts === null || count($this->contacts) === 0) { - return ''; - } - - // here we check the matched contact from the note corresponds to a contact - // in the database - if ( - count(array_unique(array_values($this->contacts))) === 1 - && array_unique(array_values($this->contacts))[0] === null - ) { - return ''; - } - - // swap in Twitter usernames - $swapped = preg_replace_callback( - self::USERNAMES_REGEX, - function ($matches) { - if (is_null($this->contacts[$matches[1]])) { - return $matches[0]; - } - - $contact = $this->contacts[$matches[1]]; - if ($contact->twitter) { - return '@' . $contact->twitter; - } - - return $contact->name; - }, - $this->getRawOriginal('note') - ); - - return $this->convertMarkdown($swapped); - } - /** * Scope a query to select a note via a NewBase60 id. */ diff --git a/app/Services/BookmarkService.php b/app/Services/BookmarkService.php index afed64fc..792cb81c 100644 --- a/app/Services/BookmarkService.php +++ b/app/Services/BookmarkService.php @@ -6,9 +6,7 @@ namespace App\Services; use App\Exceptions\InternetArchiveException; use App\Jobs\ProcessBookmark; -use App\Jobs\SyndicateBookmarkToTwitter; use App\Models\Bookmark; -use App\Models\SyndicationTarget; use App\Models\Tag; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; @@ -47,23 +45,6 @@ class BookmarkService extends Service $bookmark->tags()->save($tag); } - $mpSyndicateTo = null; - if (Arr::get($request, 'mp-syndicate-to')) { - $mpSyndicateTo = Arr::get($request, 'mp-syndicate-to'); - } - if (Arr::get($request, 'properties.mp-syndicate-to')) { - $mpSyndicateTo = Arr::get($request, 'properties.mp-syndicate-to'); - } - $mpSyndicateTo = Arr::wrap($mpSyndicateTo); - foreach ($mpSyndicateTo as $uid) { - $target = SyndicationTarget::where('uid', $uid)->first(); - if ($target && $target->service_name === 'Twitter') { - SyndicateBookmarkToTwitter::dispatch($bookmark); - - break; - } - } - ProcessBookmark::dispatch($bookmark); return $bookmark; diff --git a/app/Services/NoteService.php b/app/Services/NoteService.php index 28ee5104..9d6a47d4 100644 --- a/app/Services/NoteService.php +++ b/app/Services/NoteService.php @@ -6,7 +6,6 @@ namespace App\Services; use App\Jobs\SendWebMentions; use App\Jobs\SyndicateNoteToMastodon; -use App\Jobs\SyndicateNoteToTwitter; use App\Models\Media; use App\Models\Note; use App\Models\Place; @@ -50,11 +49,6 @@ class NoteService extends Service dispatch(new SendWebMentions($note)); - // Syndication targets - if (in_array('twitter', $this->getSyndicationTargets($request), true)) { - dispatch(new SyndicateNoteToTwitter($note)); - } - if (in_array('mastodon', $this->getSyndicationTargets($request), true)) { dispatch(new SyndicateNoteToMastodon($note)); } diff --git a/resources/views/likes/show.blade.php b/resources/views/likes/show.blade.php index dcf24369..281c561b 100644 --- a/resources/views/likes/show.blade.php +++ b/resources/views/likes/show.blade.php @@ -4,7 +4,4 @@ @section('content') @include('templates.like', ['like' => $like]) - - - @stop diff --git a/resources/views/notes/show.blade.php b/resources/views/notes/show.blade.php index 94cea5c5..fd554483 100644 --- a/resources/views/notes/show.blade.php +++ b/resources/views/notes/show.blade.php @@ -46,8 +46,6 @@

@endforeach @endif - - @stop @section('scripts') diff --git a/resources/views/templates/bookmark.blade.php b/resources/views/templates/bookmark.blade.php index eea2ff20..e6795fa3 100644 --- a/resources/views/templates/bookmark.blade.php +++ b/resources/views/templates/bookmark.blade.php @@ -26,7 +26,4 @@ @endforeach @endif -

🔖 {{ $bookmark->url }} 🔗 {{ $bookmark->longurl }}

- - diff --git a/resources/views/templates/note.blade.php b/resources/views/templates/note.blade.php index de6aea62..e8bc60f1 100644 --- a/resources/views/templates/note.blade.php +++ b/resources/views/templates/note.blade.php @@ -26,11 +26,6 @@ @endif @endforeach - @if ($note->twitter_content) -
- {!! $note->twitter_content !!} -
- @endif
diff --git a/tests/Feature/BookmarksTest.php b/tests/Feature/BookmarksTest.php index b1f25982..a00b8c37 100644 --- a/tests/Feature/BookmarksTest.php +++ b/tests/Feature/BookmarksTest.php @@ -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']); } diff --git a/tests/Feature/BridgyPosseTest.php b/tests/Feature/BridgyPosseTest.php deleted file mode 100644 index 885fb99c..00000000 --- a/tests/Feature/BridgyPosseTest.php +++ /dev/null @@ -1,30 +0,0 @@ -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); - } -} diff --git a/tests/Feature/MicropubControllerTest.php b/tests/Feature/MicropubControllerTest.php index 07009886..e3054a20 100644 --- a/tests/Feature/MicropubControllerTest.php +++ b/tests/Feature/MicropubControllerTest.php @@ -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); } diff --git a/tests/Feature/NotesControllerTest.php b/tests/Feature/NotesControllerTest.php index 19db5216..ec550437 100644 --- a/tests/Feature/NotesControllerTest.php +++ b/tests/Feature/NotesControllerTest.php @@ -68,7 +68,7 @@ class NotesControllerTest extends TestCase } /** @test */ - public function unknownNoteGives404() + public function unknownNoteGives404(): void { $response = $this->get('/notes/112233'); $response->assertNotFound(); diff --git a/tests/Unit/Jobs/SyndicateBookmarkToTwitterJobTest.php b/tests/Unit/Jobs/SyndicateBookmarkToTwitterJobTest.php deleted file mode 100644 index 8162bd83..00000000 --- a/tests/Unit/Jobs/SyndicateBookmarkToTwitterJobTest.php +++ /dev/null @@ -1,42 +0,0 @@ -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 . '"}', - ]); - } -} diff --git a/tests/Unit/Jobs/SyndicateNoteToTwitterJobTest.php b/tests/Unit/Jobs/SyndicateNoteToTwitterJobTest.php deleted file mode 100644 index bad6f897..00000000 --- a/tests/Unit/Jobs/SyndicateNoteToTwitterJobTest.php +++ /dev/null @@ -1,40 +0,0 @@ -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, - ]); - } -}