From 7f9a73360cc756cbba9a70812b788d3b2059d840 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Tue, 20 Sep 2016 13:13:05 +0100 Subject: [PATCH 1/2] Fix job dispatching --- .../Commands/ReDownloadWebMentions.php | 2 +- .../Controllers/WebMentionsController.php | 2 +- app/Jobs/Job.php | 21 ------------------- app/Jobs/ProcessWebMention.php | 10 ++++----- app/Jobs/SaveProfileImage.php | 5 +++-- app/Jobs/SendWebMentions.php | 5 +++-- app/Jobs/SyndicateToTwitter.php | 5 +++-- app/Services/NoteService.php | 7 ++----- 8 files changed, 18 insertions(+), 39 deletions(-) delete mode 100644 app/Jobs/Job.php diff --git a/app/Console/Commands/ReDownloadWebMentions.php b/app/Console/Commands/ReDownloadWebMentions.php index e7269238..da686229 100644 --- a/app/Console/Commands/ReDownloadWebMentions.php +++ b/app/Console/Commands/ReDownloadWebMentions.php @@ -42,7 +42,7 @@ class ReDownloadWebMentions extends Command $webmentions = WebMention::all(); foreach ($webmentions as $webmention) { $this->info('Initiation re-download of ' . $webmention->source); - $this->dispatch(new DownloadWebMention($webmention->source)); + dispatch(new DownloadWebMention($webmention->source)); } } } diff --git a/app/Http/Controllers/WebMentionsController.php b/app/Http/Controllers/WebMentionsController.php index ad0a59fe..105c22b5 100644 --- a/app/Http/Controllers/WebMentionsController.php +++ b/app/Http/Controllers/WebMentionsController.php @@ -38,7 +38,7 @@ class WebMentionsController extends Controller $numbers = new Numbers(); try { $note = Note::findOrFail($numbers->b60tonum($noteId)); - $this->dispatch(new ProcessWebMention($note, $request->input('source'))); + dispatch(new ProcessWebMention($note, $request->input('source'))); } catch (ModelNotFoundException $e) { return new Response('This note doesn’t exist.', 400); } diff --git a/app/Jobs/Job.php b/app/Jobs/Job.php deleted file mode 100644 index 55ece29a..00000000 --- a/app/Jobs/Job.php +++ /dev/null @@ -1,21 +0,0 @@ -dispatch(new SaveProfileImage($microformats)); + dispatch(new SaveProfileImage($microformats)); $webmention->mf2 = json_encode($microformats); $webmention->save(); @@ -87,7 +87,7 @@ class ProcessWebMention extends Job implements ShouldQueue //no wemention in db so create new one $webmention = new WebMention(); $type = $parser->getMentionType($microformats); //throw error here? - $this->dispatch(new SaveProfileImage($microformats)); + dispatch(new SaveProfileImage($microformats)); $webmention->source = $this->source; $webmention->target = $this->note->longurl; $webmention->commentable_id = $this->note->id; diff --git a/app/Jobs/SaveProfileImage.php b/app/Jobs/SaveProfileImage.php index 8509a0d4..07d29a3c 100644 --- a/app/Jobs/SaveProfileImage.php +++ b/app/Jobs/SaveProfileImage.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use GuzzleHttp\Exception\RequestException; @@ -9,9 +10,9 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Jonnybarnes\WebmentionsParser\Authorship; use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException; -class SaveProfileImage extends Job implements ShouldQueue +class SaveProfileImage implements ShouldQueue { - use InteractsWithQueue, SerializesModels; + use InteractsWithQueue, Queueable, SerializesModels; protected $microformats; diff --git a/app/Jobs/SendWebMentions.php b/app/Jobs/SendWebMentions.php index 4799a426..15a3e4a5 100644 --- a/app/Jobs/SendWebMentions.php +++ b/app/Jobs/SendWebMentions.php @@ -4,13 +4,14 @@ namespace App\Jobs; use App\Note; use GuzzleHttp\Client; +use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; -class SendWebMentions extends Job implements ShouldQueue +class SendWebMentions implements ShouldQueue { - use InteractsWithQueue, SerializesModels; + use InteractsWithQueue, Queueable, SerializesModels; protected $note; diff --git a/app/Jobs/SyndicateToTwitter.php b/app/Jobs/SyndicateToTwitter.php index 377932f7..39035016 100644 --- a/app/Jobs/SyndicateToTwitter.php +++ b/app/Jobs/SyndicateToTwitter.php @@ -5,15 +5,16 @@ namespace App\Jobs; use Twitter; use App\Note; use App\Contact; +use Illuminate\Bus\Queueable; use Jonnybarnes\IndieWeb\Numbers; use Jonnybarnes\IndieWeb\NotePrep; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; -class SyndicateToTwitter extends Job implements ShouldQueue +class SyndicateToTwitter implements ShouldQueue { - use InteractsWithQueue, SerializesModels; + use InteractsWithQueue, Queueable, SerializesModels; protected $note; diff --git a/app/Services/NoteService.php b/app/Services/NoteService.php index 38cbe531..a4ad5ce1 100644 --- a/app/Services/NoteService.php +++ b/app/Services/NoteService.php @@ -7,12 +7,9 @@ use App\Place; use Illuminate\Http\Request; use App\Jobs\SendWebMentions; use App\Jobs\SyndicateToTwitter; -use Illuminate\Foundation\Bus\DispatchesJobs; class NoteService { - use DispatchesJobs; - /** * Create a new note. * @@ -57,7 +54,7 @@ class NoteService } } - $this->dispatch(new SendWebMentions($note)); + dispatch(new SendWebMentions($note)); if (//micropub request, syndication sent as array (is_array($request->input('syndicate-to')) @@ -68,7 +65,7 @@ class NoteService || //local admin cp request ($request->input('twitter') == true)) ) { - $this->dispatch(new SyndicateToTwitter($note)); + dispatch(new SyndicateToTwitter($note)); } return $note; From de2fbe32376b2291f6dfab2a37e0000fc88892e8 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Tue, 20 Sep 2016 13:14:37 +0100 Subject: [PATCH 2/2] Bump version number in changelog --- changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index ef74a156..b2158a6b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## Version 0.0.11.5 (2016-09-20) + - Fix job dispatching to more in line with Laravel 5.3 practices + ## Version 0.0.11.4 (2016-09-19) - Better console output for the new webmention commands