Use JSON response for q=syndicate-to request
This commit is contained in:
parent
4f30955758
commit
88b30bb815
5 changed files with 26 additions and 16 deletions
|
@ -37,9 +37,7 @@ class MicropubClientController extends Controller
|
||||||
public function newNotePage(Request $request)
|
public function newNotePage(Request $request)
|
||||||
{
|
{
|
||||||
$url = $request->session()->get('me');
|
$url = $request->session()->get('me');
|
||||||
$syndication = $this->parseSyndicationTargets(
|
$syndication = $request->session()->get('syndication');
|
||||||
$request->session()->get('syndication')
|
|
||||||
);
|
|
||||||
|
|
||||||
return view('micropubnewnotepage', [
|
return view('micropubnewnotepage', [
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
|
@ -113,7 +111,7 @@ class MicropubClientController extends Controller
|
||||||
return redirect('notes/new')->withErrors('Bad response when refreshing syndication targets', 'endpoint');
|
return redirect('notes/new')->withErrors('Bad response when refreshing syndication targets', 'endpoint');
|
||||||
}
|
}
|
||||||
$body = (string) $response->getBody();
|
$body = (string) $response->getBody();
|
||||||
$syndication = str_replace(['&', '[]'], [';', ''], $body);
|
$syndication = $this->parseSyndicationTargets($body);
|
||||||
|
|
||||||
$request->session()->put('syndication', $syndication);
|
$request->session()->put('syndication', $syndication);
|
||||||
|
|
||||||
|
@ -321,10 +319,9 @@ class MicropubClientController extends Controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$syndicateTo = [];
|
$syndicateTo = [];
|
||||||
$parts = explode(';', $syndicationTargets);
|
$data = json_decode($syndicationTargets, true);
|
||||||
foreach ($parts as $part) {
|
foreach ($syndicateTo['syndicate-to'] as $syn) {
|
||||||
$target = explode('=', $part);
|
$syndicateTo[] = $syn['uid'];
|
||||||
$syndicateTo[] = urldecode($target[1]);
|
|
||||||
}
|
}
|
||||||
if (count($syndicateTo) > 0) {
|
if (count($syndicateTo) > 0) {
|
||||||
return $syndicateTo;
|
return $syndicateTo;
|
||||||
|
|
|
@ -108,12 +108,22 @@ class MicropubController extends Controller
|
||||||
}
|
}
|
||||||
//we have a valid token, is `syndicate-to` set?
|
//we have a valid token, is `syndicate-to` set?
|
||||||
if ($request->input('q') === 'syndicate-to') {
|
if ($request->input('q') === 'syndicate-to') {
|
||||||
$content = http_build_query([
|
return response()->json([
|
||||||
'syndicate-to' => 'twitter.com/jonnybarnes',
|
'syndicate-to' => [[
|
||||||
|
'uid' => 'https://twitter.com/jonnybarnes',
|
||||||
|
'name' => 'jonnybarnes on Twitter',
|
||||||
|
'service' => [
|
||||||
|
'name' => 'Twitter',
|
||||||
|
'url' => 'https://twitter.com',
|
||||||
|
'photo' => 'https://upload.wikimedia.org/wikipedia/en/9/9f/Twitter_bird_logo_2012.svg',
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'name' => 'jonnybarnes',
|
||||||
|
'url' => 'https://twitter.com/jonnybarnes',
|
||||||
|
'photo' => 'https://pbs.twimg.com/profile_images/1853565405/jmb-bw.jpg',
|
||||||
|
],
|
||||||
|
]],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (new Response($content, 200))
|
|
||||||
->header('Content-Type', 'application/x-www-form-urlencoded');
|
|
||||||
}
|
}
|
||||||
//nope, how about a geo URL?
|
//nope, how about a geo URL?
|
||||||
if (substr($request->input('q'), 0, 4) === 'geo:') {
|
if (substr($request->input('q'), 0, 4) === 'geo:') {
|
||||||
|
|
|
@ -50,9 +50,9 @@ class NoteService
|
||||||
if (//micropub request, syndication sent as array
|
if (//micropub request, syndication sent as array
|
||||||
(is_array($request->input('syndicate-to'))
|
(is_array($request->input('syndicate-to'))
|
||||||
&&
|
&&
|
||||||
(in_array('twitter.com/jonnybarnes', $request->input('syndicate-to')))
|
(in_array('https://twitter.com/jonnybarnes', $request->input('syndicate-to')))
|
||||||
|| //micropub request, syndication sent as string
|
|| //micropub request, syndication sent as string
|
||||||
($request->input('syndicate-to') == 'twitter.com/jonnybarnes')
|
($request->input('syndicate-to') == 'https://twitter.com/jonnybarnes')
|
||||||
|| //local admin cp request
|
|| //local admin cp request
|
||||||
($request->input('twitter') == true))
|
($request->input('twitter') == true))
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version {next}
|
||||||
|
- Use JSON for syndication endpoint query response
|
||||||
|
|
||||||
## Version 0.0.6.3 (2016-06-29)
|
## Version 0.0.6.3 (2016-06-29)
|
||||||
- Fix an issue with dispatching the syndication job
|
- Fix an issue with dispatching the syndication job
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class MicropubTest extends TestCase
|
||||||
public function testMicropubRequestForSyndication()
|
public function testMicropubRequestForSyndication()
|
||||||
{
|
{
|
||||||
$this->call('GET', $this->appurl . '/api/post', ['q' => 'syndicate-to'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
$this->call('GET', $this->appurl . '/api/post', ['q' => 'syndicate-to'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
$this->see('twitter.com%2Fjonnybarnes');
|
$this->seeJson(['uid' => 'https://twitter.com/jonnybarnes']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMicropubRequestForNearbyPlacesThatExist()
|
public function testMicropubRequestForNearbyPlacesThatExist()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue