Squashed commit of the following:

commit d0c1c0083ced0470500060f14d37cdfff3028795
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Dec 16 11:46:40 2016 +0000

    remove done @todo

commit f61a968bb8a7743c2b34ea3efcb25cfd73452cfc
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Dec 16 11:43:22 2016 +0000

    Comment for using empty array

commit 9ad7cde20d259ff4527d315049e3df83f145fe0f
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Dec 16 11:42:18 2016 +0000

    Syndication targets are now dynamically checked
This commit is contained in:
Jonny Barnes 2016-12-16 11:49:15 +00:00
parent 41058ae026
commit e8c847579c
3 changed files with 25 additions and 18 deletions

View file

@ -103,7 +103,6 @@ class MicropubController extends Controller
* appropriately. Further if the request has the query parameter * appropriately. Further if the request has the query parameter
* synidicate-to we respond with the known syndication endpoints. * synidicate-to we respond with the known syndication endpoints.
* *
* @todo Move the syndication endpoints into a .env variable
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */

View file

@ -72,28 +72,35 @@ class NoteService
dispatch(new SendWebMentions($note)); dispatch(new SendWebMentions($note));
//syndication targets //syndication targets
//string sent from either local admin CP or micropub //from admin CP
if ($request->input('twitter') == true if ($request->input('twitter')) {
|| $request->input('syndicate-to') == 'https://twitter.com/jonnybarnes') {
dispatch(new SyndicateToTwitter($note)); dispatch(new SyndicateToTwitter($note));
} }
if ($request->input('facebook') == true if ($request->input('facebook')) {
|| $request->input('syndicate-to') == 'https://facebook.com/jonnybarnes') {
dispatch(new SyndicateToFacebook($note)); dispatch(new SyndicateToFacebook($note));
} }
//from a micropub request
//micropub request, syndication sent as array $targets = array_pluck(config('syndication.targets'), 'uid', 'service.name');
if ((is_array($request->input('syndicate-to'))) if (is_string($request->input('syndicate-to'))) {
&& $service = array_search($request->input('syndicate-to'));
(in_array('https://twitter.com/jonnybarnes', $request->input('syndicate-to'))) if ($service == 'Twitter') {
) { dispatch(new SyndicateToTwitter($note));
dispatch(new SyndicateToTwitter($note)); }
if ($service == 'Facebook') {
dispatch(new SyndicateToFacebook($note));
}
} }
if ((is_array($request->input('syndicate-to'))) if (is_array($request->input('syndicate-to'))) {
&& foreach ($targets as $service => $target) {
(in_array('https://facebook.com/jonnybarnes', $request->input('syndicate-to'))) if (in_array($target, $request->input('syndicate-to'))) {
) { if ($service == 'Twitter') {
dispatch(new SyndicateToFacebook($note)); dispatch(new SyndicateToTwitter($note));
}
if ($service == 'Facebook') {
dispatch(new SyndicateToFacebook($note));
}
}
}
} }
return $note; return $note;

View file

@ -6,6 +6,7 @@
*/ */
return [ return [
// if you dont have any targets, then set this to 'targets' => [];
'targets' => [ 'targets' => [
[ [
'uid' => 'https://twitter.com/jonnybarnes', 'uid' => 'https://twitter.com/jonnybarnes',