From 88e1246f8bc254f3ab523311be3c91fb33bcf625 Mon Sep 17 00:00:00 2001
From: Jonny Barnes
Date: Sat, 8 Apr 2023 11:54:24 +0100
Subject: [PATCH] Remove Twitter POSSE support
---
app/Jobs/SyndicateBookmarkToTwitter.php | 59 -------------------
app/Jobs/SyndicateNoteToTwitter.php | 57 ------------------
app/Models/Note.php | 44 --------------
app/Services/BookmarkService.php | 19 ------
app/Services/NoteService.php | 6 --
resources/views/likes/show.blade.php | 3 -
resources/views/notes/show.blade.php | 2 -
resources/views/templates/bookmark.blade.php | 3 -
resources/views/templates/note.blade.php | 5 --
tests/Feature/BookmarksTest.php | 45 --------------
tests/Feature/BridgyPosseTest.php | 30 ----------
tests/Feature/MicropubControllerTest.php | 9 ---
tests/Feature/NotesControllerTest.php | 2 +-
.../SyndicateBookmarkToTwitterJobTest.php | 42 -------------
.../Jobs/SyndicateNoteToTwitterJobTest.php | 40 -------------
15 files changed, 1 insertion(+), 365 deletions(-)
delete mode 100644 app/Jobs/SyndicateBookmarkToTwitter.php
delete mode 100644 app/Jobs/SyndicateNoteToTwitter.php
delete mode 100644 tests/Feature/BridgyPosseTest.php
delete mode 100644 tests/Unit/Jobs/SyndicateBookmarkToTwitterJobTest.php
delete mode 100644 tests/Unit/Jobs/SyndicateNoteToTwitterJobTest.php
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
-
-
-
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)
-
- @endif