Syndicate bookmarks via jobs
This commit is contained in:
parent
917a673f05
commit
f007b24065
9 changed files with 161 additions and 10 deletions
|
@ -8,6 +8,8 @@ use App\Tag;
|
|||
use App\Bookmark;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Jobs\ProcessBookmark;
|
||||
use App\Jobs\SyndicateBookmarkToTwitter;
|
||||
use App\Jobs\SyndicateBookmarkToFacebook;
|
||||
|
||||
class BookmarkService
|
||||
{
|
||||
|
@ -47,6 +49,35 @@ class BookmarkService
|
|||
$bookmark->tags()->save($tag);
|
||||
}
|
||||
|
||||
$targets = array_pluck(config('syndication.targets'), 'uid', 'service.name');
|
||||
$mpSyndicateTo = null;
|
||||
if ($request->has('mp-syndicate-to')) {
|
||||
$mpSyndicateTo = $request->input('mp-syndicate-to');
|
||||
}
|
||||
if ($request->has('properties.mp-syndicate-to')) {
|
||||
$mpSyndicateTo = $request->input('properties.mp-syndicate-to');
|
||||
}
|
||||
if (is_string($mpSyndicateTo)) {
|
||||
$service = array_search($mpSyndicateTo, $targets);
|
||||
if ($service == 'Twitter') {
|
||||
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
||||
}
|
||||
if ($service == 'Facebook') {
|
||||
SyndicateBookmarkToFacebook::dispatch($bookmark);
|
||||
}
|
||||
}
|
||||
if (is_array($mpSyndicateTo)) {
|
||||
foreach ($mpSyndicateTo as $uid) {
|
||||
$service = array_search($uid, $targets);
|
||||
if ($service == 'Twitter') {
|
||||
SyndicateBookmarkToTwitter::dispatch($bookmark);
|
||||
}
|
||||
if ($service == 'Facebook') {
|
||||
SyndicateBookmarkToFacebook::dispatch($bookmark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProcessBookmark::dispatch($bookmark);
|
||||
|
||||
return $bookmark;
|
||||
|
|
|
@ -105,10 +105,10 @@ class NoteService
|
|||
|
||||
//syndication targets
|
||||
if (in_array('twitter', $data['syndicate'])) {
|
||||
dispatch(new SyndicateToTwitter($note));
|
||||
dispatch(new SyndicateNoteToTwitter($note));
|
||||
}
|
||||
if (in_array('facebook', $data['syndicate'])) {
|
||||
dispatch(new SyndicateToFacebook($note));
|
||||
dispatch(new SyndicateNoteToFacebook($note));
|
||||
}
|
||||
|
||||
return $note;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue