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
* synidicate-to we respond with the known syndication endpoints.
*
* @todo Move the syndication endpoints into a .env variable
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/

View file

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

View file

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