diff --git a/app/Http/Controllers/Admin/SyndicationTargetsController.php b/app/Http/Controllers/Admin/SyndicationTargetsController.php
new file mode 100644
index 00000000..f8c93260
--- /dev/null
+++ b/app/Http/Controllers/Admin/SyndicationTargetsController.php
@@ -0,0 +1,99 @@
+validate([
+ 'uid' => 'required|string',
+ 'name' => 'required|string',
+ ]);
+
+ SyndicationTarget::create($validated);
+
+ return redirect('/admin/syndication');
+ }
+
+ /**
+ * Show a form to edit a syndication target.
+ *
+ * @param SyndicationTarget $syndicationTarget
+ * @return View
+ */
+ public function edit(SyndicationTarget $syndicationTarget): View
+ {
+ return view('admin.syndication.edit', [
+ 'syndication_target' => $syndicationTarget,
+ ]);
+ }
+
+ /**
+ * Process the request to edit a client name.
+ *
+ * @param Request $request
+ * @param SyndicationTarget $syndicationTarget
+ * @return RedirectResponse
+ */
+ public function update(Request $request, SyndicationTarget $syndicationTarget): RedirectResponse
+ {
+ $validated = $request->validate([
+ 'uid' => 'required|string',
+ 'name' => 'required|string',
+ ]);
+
+ $syndicationTarget->update($validated);
+
+ return redirect('/admin/syndication');
+ }
+
+ /**
+ * Process a request to delete a client.
+ *
+ * @param SyndicationTarget $syndicationTarget
+ * @return RedirectResponse
+ */
+ public function destroy(SyndicationTarget $syndicationTarget): RedirectResponse
+ {
+ $syndicationTarget->delete();
+
+ return redirect('/admin/syndication');
+ }
+}
diff --git a/app/Http/Controllers/MicropubController.php b/app/Http/Controllers/MicropubController.php
index ea7d1413..b540ca18 100644
--- a/app/Http/Controllers/MicropubController.php
+++ b/app/Http/Controllers/MicropubController.php
@@ -6,11 +6,13 @@ namespace App\Http\Controllers;
use App\Http\Responses\MicropubResponses;
use App\Models\Place;
+use App\Models\SyndicationTarget;
use App\Services\Micropub\HCardService;
use App\Services\Micropub\HEntryService;
use App\Services\Micropub\UpdateService;
use App\Services\TokenService;
use Illuminate\Http\JsonResponse;
+use Illuminate\Http\Request;
use Lcobucci\JWT\Encoding\CannotDecodeContent;
use Lcobucci\JWT\Token\InvalidTokenStructure;
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
@@ -43,13 +45,14 @@ class MicropubController extends Controller
* This function receives an API request, verifies the authenticity
* then passes over the info to the relevant Service class.
*
+ * @param Request $request
* @return JsonResponse
*/
- public function post(): JsonResponse
+ public function post(Request $request): JsonResponse
{
try {
- $tokenData = $this->tokenService->validateToken(request()->input('access_token'));
- } catch (RequiredConstraintsViolated | InvalidTokenStructure | CannotDecodeContent $exception) {
+ $tokenData = $this->tokenService->validateToken($request->input('access_token'));
+ } catch (RequiredConstraintsViolated | InvalidTokenStructure | CannotDecodeContent) {
$micropubResponses = new MicropubResponses();
return $micropubResponses->invalidTokenResponse();
@@ -61,15 +64,15 @@ class MicropubController extends Controller
return $micropubResponses->tokenHasNoScopeResponse();
}
- $this->logMicropubRequest(request()->all());
+ $this->logMicropubRequest($request->all());
- if ((request()->input('h') == 'entry') || (request()->input('type.0') == 'h-entry')) {
- if (stristr($tokenData->claims()->get('scope'), 'create') === false) {
+ if (($request->input('h') === 'entry') || ($request->input('type.0') === 'h-entry')) {
+ if (stripos($tokenData->claims()->get('scope'), 'create') === false) {
$micropubResponses = new MicropubResponses();
return $micropubResponses->insufficientScopeResponse();
}
- $location = $this->hentryService->process(request()->all(), $this->getCLientId());
+ $location = $this->hentryService->process($request->all(), $this->getCLientId());
return response()->json([
'response' => 'created',
@@ -77,13 +80,13 @@ class MicropubController extends Controller
], 201)->header('Location', $location);
}
- if (request()->input('h') == 'card' || request()->input('type.0') == 'h-card') {
- if (stristr($tokenData->claims()->get('scope'), 'create') === false) {
+ if ($request->input('h') === 'card' || $request->input('type.0') === 'h-card') {
+ if (stripos($tokenData->claims()->get('scope'), 'create') === false) {
$micropubResponses = new MicropubResponses();
return $micropubResponses->insufficientScopeResponse();
}
- $location = $this->hcardService->process(request()->all());
+ $location = $this->hcardService->process($request->all());
return response()->json([
'response' => 'created',
@@ -91,14 +94,14 @@ class MicropubController extends Controller
], 201)->header('Location', $location);
}
- if (request()->input('action') == 'update') {
- if (stristr($tokenData->claims()->get('scope'), 'update') === false) {
+ if ($request->input('action') === 'update') {
+ if (stripos($tokenData->claims()->get('scope'), 'update') === false) {
$micropubResponses = new MicropubResponses();
return $micropubResponses->insufficientScopeResponse();
}
- return $this->updateService->process(request()->all());
+ return $this->updateService->process($request->all());
}
return response()->json([
@@ -121,21 +124,19 @@ class MicropubController extends Controller
{
try {
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
- } catch (RequiredConstraintsViolated | InvalidTokenStructure $exception) {
- $micropubResponses = new MicropubResponses();
-
- return $micropubResponses->invalidTokenResponse();
+ } catch (RequiredConstraintsViolated | InvalidTokenStructure) {
+ return (new MicropubResponses())->invalidTokenResponse();
}
if (request()->input('q') === 'syndicate-to') {
return response()->json([
- 'syndicate-to' => config('syndication.targets'),
+ 'syndicate-to' => SyndicationTarget::all(),
]);
}
- if (request()->input('q') == 'config') {
+ if (request()->input('q') === 'config') {
return response()->json([
- 'syndicate-to' => config('syndication.targets'),
+ 'syndicate-to' => SyndicationTarget::all(),
'media-endpoint' => route('media-endpoint'),
]);
}
diff --git a/app/Models/SyndicationTarget.php b/app/Models/SyndicationTarget.php
new file mode 100644
index 00000000..85d674c1
--- /dev/null
+++ b/app/Models/SyndicationTarget.php
@@ -0,0 +1,84 @@
+
+ */
+ protected $visible = [
+ 'uid',
+ 'name',
+ 'service',
+ 'user',
+ ];
+
+ /**
+ * The accessors to append to the model's array form.
+ *
+ * @var array
+ */
+ protected $appends = [
+ 'service',
+ 'user',
+ ];
+
+ /**
+ * Get the service data as a single attribute.
+ *
+ * @vreturn Attribute
+ */
+ protected function service(): Attribute
+ {
+ return Attribute::get(
+ get: fn ($value, $attributes) => [
+ 'name' => $attributes['service_name'],
+ 'url' => $attributes['service_url'],
+ 'photo' => $attributes['service_photo'],
+ ],
+ );
+ }
+
+ /**
+ * Get the user data as a single attribute.
+ *
+ * @vreturn Attribute
+ */
+ protected function user(): Attribute
+ {
+ return Attribute::get(
+ get: fn ($value, $attributes) => [
+ 'name' => $attributes['user_name'],
+ 'url' => $attributes['user_url'],
+ 'photo' => $attributes['user_photo'],
+ ],
+ );
+ }
+}
diff --git a/app/Services/BookmarkService.php b/app/Services/BookmarkService.php
index 2bf71d5f..d9012912 100644
--- a/app/Services/BookmarkService.php
+++ b/app/Services/BookmarkService.php
@@ -8,6 +8,7 @@ use App\Exceptions\InternetArchiveException;
use App\Jobs\ProcessBookmark;
use App\Jobs\SyndicateBookmarkToTwitter;
use App\Models\Bookmark;
+use App\Models\SyndicationTarget;
use App\Models\Tag;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
@@ -52,7 +53,6 @@ class BookmarkService
$bookmark->tags()->save($tag);
}
- $targets = Arr::pluck(config('syndication.targets'), 'uid', 'service.name');
$mpSyndicateTo = null;
if (Arr::get($request, 'mp-syndicate-to')) {
$mpSyndicateTo = Arr::get($request, 'mp-syndicate-to');
@@ -60,18 +60,13 @@ class BookmarkService
if (Arr::get($request, 'properties.mp-syndicate-to')) {
$mpSyndicateTo = Arr::get($request, 'properties.mp-syndicate-to');
}
- if (is_string($mpSyndicateTo)) {
- $service = array_search($mpSyndicateTo, $targets);
- if ($service == 'Twitter') {
+ $mpSyndicateTo = Arr::wrap($mpSyndicateTo);
+ foreach ($mpSyndicateTo as $uid) {
+ $target = SyndicationTarget::where('uid', $uid)->first();
+ if ($target && $target->service_name === 'Twitter') {
SyndicateBookmarkToTwitter::dispatch($bookmark);
- }
- }
- if (is_array($mpSyndicateTo)) {
- foreach ($mpSyndicateTo as $uid) {
- $service = array_search($uid, $targets);
- if ($service == 'Twitter') {
- SyndicateBookmarkToTwitter::dispatch($bookmark);
- }
+
+ break;
}
}
diff --git a/app/Services/Micropub/HEntryService.php b/app/Services/Micropub/HEntryService.php
index bf19201f..2f8a2779 100644
--- a/app/Services/Micropub/HEntryService.php
+++ b/app/Services/Micropub/HEntryService.php
@@ -21,19 +21,13 @@ class HEntryService
public function process(array $request, ?string $client = null): ?string
{
if (Arr::get($request, 'properties.like-of') || Arr::get($request, 'like-of')) {
- $like = resolve(LikeService::class)->createLike($request);
-
- return $like->longurl;
+ return resolve(LikeService::class)->createLike($request)->longurl;
}
if (Arr::get($request, 'properties.bookmark-of') || Arr::get($request, 'bookmark-of')) {
- $bookmark = resolve(BookmarkService::class)->createBookmark($request);
-
- return $bookmark->longurl;
+ return resolve(BookmarkService::class)->createBookmark($request)->longurl;
}
- $note = resolve(NoteService::class)->createNote($request, $client);
-
- return $note->longurl;
+ return resolve(NoteService::class)->createNote($request, $client)->longurl;
}
}
diff --git a/app/Services/NoteService.php b/app/Services/NoteService.php
index 9c4dd357..57458389 100644
--- a/app/Services/NoteService.php
+++ b/app/Services/NoteService.php
@@ -9,6 +9,7 @@ use App\Jobs\SyndicateNoteToTwitter;
use App\Models\Media;
use App\Models\Note;
use App\Models\Place;
+use App\Models\SyndicationTarget;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
@@ -18,7 +19,7 @@ class NoteService
* Create a new note.
*
* @param array $request Data from request()->all()
- * @param string $client
+ * @param string|null $client
* @return Note
*/
public function createNote(array $request, ?string $client = null): Note
@@ -52,11 +53,9 @@ class NoteService
dispatch(new SendWebMentions($note));
- //syndication targets
- if (count($this->getSyndicationTargets($request)) > 0) {
- if (in_array('twitter', $this->getSyndicationTargets($request))) {
- dispatch(new SyndicateNoteToTwitter($note));
- }
+ // Syndication targets
+ if (in_array('twitter', $this->getSyndicationTargets($request), true)) {
+ dispatch(new SyndicateNoteToTwitter($note));
}
return $note;
@@ -206,22 +205,14 @@ class NoteService
private function getSyndicationTargets(array $request): array
{
$syndication = [];
- $targets = Arr::pluck(config('syndication.targets'), 'uid', 'service.name');
$mpSyndicateTo = Arr::get($request, 'mp-syndicate-to') ?? Arr::get($request, 'properties.mp-syndicate-to');
- if (is_string($mpSyndicateTo)) {
- $service = array_search($mpSyndicateTo, $targets);
- if ($service == 'Twitter') {
+ $mpSyndicateTo = Arr::wrap($mpSyndicateTo);
+ foreach ($mpSyndicateTo as $uid) {
+ $target = SyndicationTarget::where('uid', $uid)->first();
+ if ($target && $target->service_name === 'Twitter') {
$syndication[] = 'twitter';
}
}
- if (is_array($mpSyndicateTo)) {
- foreach ($mpSyndicateTo as $uid) {
- $service = array_search($uid, $targets);
- if ($service == 'Twitter') {
- $syndication[] = 'twitter';
- }
- }
- }
return $syndication;
}
diff --git a/composer.lock b/composer.lock
index 8df6fa84..767787be 100644
--- a/composer.lock
+++ b/composer.lock
@@ -58,16 +58,16 @@
},
{
"name": "aws/aws-sdk-php",
- "version": "3.238.4",
+ "version": "3.240.0",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
- "reference": "3b87356aea911fa7a5596802a27baefe59062ee6"
+ "reference": "95186e6a40670196cc2f9f752a38b863aa45a890"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3b87356aea911fa7a5596802a27baefe59062ee6",
- "reference": "3b87356aea911fa7a5596802a27baefe59062ee6",
+ "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/95186e6a40670196cc2f9f752a38b863aa45a890",
+ "reference": "95186e6a40670196cc2f9f752a38b863aa45a890",
"shasum": ""
},
"require": {
@@ -146,9 +146,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
- "source": "https://github.com/aws/aws-sdk-php/tree/3.238.4"
+ "source": "https://github.com/aws/aws-sdk-php/tree/3.240.0"
},
- "time": "2022-10-13T18:18:23+00:00"
+ "time": "2022-10-21T20:17:33+00:00"
},
{
"name": "brick/math",
@@ -581,23 +581,23 @@
},
{
"name": "doctrine/inflector",
- "version": "2.0.5",
+ "version": "2.0.6",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
- "reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392"
+ "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/inflector/zipball/ade2b3bbfb776f27f0558e26eed43b5d9fe1b392",
- "reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392",
+ "url": "https://api.github.com/repos/doctrine/inflector/zipball/d9d313a36c872fd6ee06d9a6cbcf713eaa40f024",
+ "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
- "doctrine/coding-standard": "^9",
+ "doctrine/coding-standard": "^10",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.3",
@@ -652,7 +652,7 @@
],
"support": {
"issues": "https://github.com/doctrine/inflector/issues",
- "source": "https://github.com/doctrine/inflector/tree/2.0.5"
+ "source": "https://github.com/doctrine/inflector/tree/2.0.6"
},
"funding": [
{
@@ -668,7 +668,7 @@
"type": "tidelift"
}
],
- "time": "2022-09-07T09:01:28+00:00"
+ "time": "2022-10-20T09:10:12+00:00"
},
{
"name": "doctrine/lexer",
@@ -1741,16 +1741,16 @@
},
{
"name": "laravel/framework",
- "version": "v9.35.1",
+ "version": "v9.36.4",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
- "reference": "79aed20f54b6ab75f926bf7d0dd7a5043ceb774a"
+ "reference": "15ce569fd93124e8e2257c24e3ed85b9ef9951d6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/framework/zipball/79aed20f54b6ab75f926bf7d0dd7a5043ceb774a",
- "reference": "79aed20f54b6ab75f926bf7d0dd7a5043ceb774a",
+ "url": "https://api.github.com/repos/laravel/framework/zipball/15ce569fd93124e8e2257c24e3ed85b9ef9951d6",
+ "reference": "15ce569fd93124e8e2257c24e3ed85b9ef9951d6",
"shasum": ""
},
"require": {
@@ -1762,7 +1762,7 @@
"fruitcake/php-cors": "^1.2",
"laravel/serializable-closure": "^1.2.2",
"league/commonmark": "^2.2",
- "league/flysystem": "^3.0.16",
+ "league/flysystem": "^3.8.0",
"monolog/monolog": "^2.0",
"nesbot/carbon": "^2.62.1",
"nunomaduro/termwind": "^1.13",
@@ -1839,7 +1839,7 @@
"league/flysystem-read-only": "^3.3",
"league/flysystem-sftp-v3": "^3.0",
"mockery/mockery": "^1.5.1",
- "orchestra/testbench-core": "^7.8",
+ "orchestra/testbench-core": "^7.11",
"pda/pheanstalk": "^4.0",
"phpstan/phpstan": "^1.4.7",
"phpunit/phpunit": "^9.5.8",
@@ -1923,7 +1923,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
- "time": "2022-10-11T17:30:47+00:00"
+ "time": "2022-10-20T16:11:03+00:00"
},
{
"name": "laravel/horizon",
@@ -2455,16 +2455,16 @@
},
{
"name": "league/flysystem",
- "version": "3.6.0",
+ "version": "3.10.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
- "reference": "8eded334b9894dc90ebdcb7be81e3a1c9413f709"
+ "reference": "9857d7208a94fc63c7bf09caf223280e59ac7274"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8eded334b9894dc90ebdcb7be81e3a1c9413f709",
- "reference": "8eded334b9894dc90ebdcb7be81e3a1c9413f709",
+ "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/9857d7208a94fc63c7bf09caf223280e59ac7274",
+ "reference": "9857d7208a94fc63c7bf09caf223280e59ac7274",
"shasum": ""
},
"require": {
@@ -2480,7 +2480,7 @@
},
"require-dev": {
"async-aws/s3": "^1.5",
- "async-aws/simple-s3": "^1.0",
+ "async-aws/simple-s3": "^1.1",
"aws/aws-sdk-php": "^3.198.1",
"composer/semver": "^3.0",
"ext-fileinfo": "*",
@@ -2526,7 +2526,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
- "source": "https://github.com/thephpleague/flysystem/tree/3.6.0"
+ "source": "https://github.com/thephpleague/flysystem/tree/3.10.1"
},
"funding": [
{
@@ -2542,25 +2542,25 @@
"type": "tidelift"
}
],
- "time": "2022-10-13T20:05:14+00:00"
+ "time": "2022-10-21T18:57:47+00:00"
},
{
"name": "league/flysystem-aws-s3-v3",
- "version": "3.6.0",
+ "version": "3.10.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git",
- "reference": "5518ab783314c91bfd781b81fea912f553afb323"
+ "reference": "95825edc5463006853e64338a4d96a977e8a10ca"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/5518ab783314c91bfd781b81fea912f553afb323",
- "reference": "5518ab783314c91bfd781b81fea912f553afb323",
+ "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/95825edc5463006853e64338a4d96a977e8a10ca",
+ "reference": "95825edc5463006853e64338a4d96a977e8a10ca",
"shasum": ""
},
"require": {
"aws/aws-sdk-php": "^3.132.4",
- "league/flysystem": "^3.6.0",
+ "league/flysystem": "^3.10.0",
"league/mime-type-detection": "^1.0.0",
"php": "^8.0.2"
},
@@ -2596,7 +2596,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem-aws-s3-v3/issues",
- "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.6.0"
+ "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.10.0"
},
"funding": [
{
@@ -2612,7 +2612,7 @@
"type": "tidelift"
}
],
- "time": "2022-10-13T19:38:48+00:00"
+ "time": "2022-10-20T21:00:57+00:00"
},
{
"name": "league/glide",
@@ -3505,16 +3505,16 @@
},
{
"name": "nunomaduro/termwind",
- "version": "v1.14.0",
+ "version": "v1.14.1",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/termwind.git",
- "reference": "10065367baccf13b6e30f5e9246fa4f63a79eb1d"
+ "reference": "86fc30eace93b9b6d4c844ba6de76db84184e01b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/10065367baccf13b6e30f5e9246fa4f63a79eb1d",
- "reference": "10065367baccf13b6e30f5e9246fa4f63a79eb1d",
+ "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/86fc30eace93b9b6d4c844ba6de76db84184e01b",
+ "reference": "86fc30eace93b9b6d4c844ba6de76db84184e01b",
"shasum": ""
},
"require": {
@@ -3571,7 +3571,7 @@
],
"support": {
"issues": "https://github.com/nunomaduro/termwind/issues",
- "source": "https://github.com/nunomaduro/termwind/tree/v1.14.0"
+ "source": "https://github.com/nunomaduro/termwind/tree/v1.14.1"
},
"funding": [
{
@@ -3587,7 +3587,7 @@
"type": "github"
}
],
- "time": "2022-08-01T11:03:24+00:00"
+ "time": "2022-10-17T15:20:29+00:00"
},
{
"name": "p3k/http",
@@ -7172,16 +7172,16 @@
},
{
"name": "vlucas/phpdotenv",
- "version": "v5.4.1",
+ "version": "v5.5.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
- "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f"
+ "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/264dce589e7ce37a7ba99cb901eed8249fbec92f",
- "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f",
+ "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7",
+ "reference": "1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7",
"shasum": ""
},
"require": {
@@ -7196,15 +7196,19 @@
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"ext-filter": "*",
- "phpunit/phpunit": "^7.5.20 || ^8.5.21 || ^9.5.10"
+ "phpunit/phpunit": "^7.5.20 || ^8.5.30 || ^9.5.25"
},
"suggest": {
"ext-filter": "Required to use the boolean validator."
},
"type": "library",
"extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": true
+ },
"branch-alias": {
- "dev-master": "5.4-dev"
+ "dev-master": "5.5-dev"
}
},
"autoload": {
@@ -7236,7 +7240,7 @@
],
"support": {
"issues": "https://github.com/vlucas/phpdotenv/issues",
- "source": "https://github.com/vlucas/phpdotenv/tree/v5.4.1"
+ "source": "https://github.com/vlucas/phpdotenv/tree/v5.5.0"
},
"funding": [
{
@@ -7248,7 +7252,7 @@
"type": "tidelift"
}
],
- "time": "2021-12-12T23:22:04+00:00"
+ "time": "2022-10-16T01:01:54+00:00"
},
{
"name": "voku/portable-ascii",
@@ -9750,25 +9754,30 @@
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.6.1",
+ "version": "1.6.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "77a32518733312af16a44300404e945338981de3"
+ "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3",
- "reference": "77a32518733312af16a44300404e945338981de3",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
+ "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0",
+ "php": "^7.4 || ^8.0",
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
"ext-tokenizer": "*",
- "psalm/phar": "^4.8"
+ "phpstan/extension-installer": "^1.1",
+ "phpstan/phpstan": "^1.8",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpunit/phpunit": "^9.5",
+ "rector/rector": "^0.13.9",
+ "vimeo/psalm": "^4.25"
},
"type": "library",
"extra": {
@@ -9794,9 +9803,9 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
- "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1"
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2"
},
- "time": "2022-03-15T21:29:03+00:00"
+ "time": "2022-10-14T12:47:21+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -11492,16 +11501,16 @@
},
{
"name": "spatie/laravel-ignition",
- "version": "1.5.1",
+ "version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-ignition.git",
- "reference": "75d465ec577abb432af1ca9b33683d5a6e921eb9"
+ "reference": "f2336fc79d99aab5cf27fa4aebe5e9c9ecf3808a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/75d465ec577abb432af1ca9b33683d5a6e921eb9",
- "reference": "75d465ec577abb432af1ca9b33683d5a6e921eb9",
+ "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/f2336fc79d99aab5cf27fa4aebe5e9c9ecf3808a",
+ "reference": "f2336fc79d99aab5cf27fa4aebe5e9c9ecf3808a",
"shasum": ""
},
"require": {
@@ -11578,7 +11587,7 @@
"type": "github"
}
],
- "time": "2022-10-04T10:14:31+00:00"
+ "time": "2022-10-14T12:24:21+00:00"
},
{
"name": "spatie/laravel-ray",
diff --git a/config/syndication.php b/config/syndication.php
deleted file mode 100644
index 7a0a92f9..00000000
--- a/config/syndication.php
+++ /dev/null
@@ -1,26 +0,0 @@
- [];
- 'targets' => [
- [
- 'uid' => 'https://twitter.com/jonnybarnes',
- 'name' => 'jonnybarnes on Twitter',
- 'service' => [
- 'name' => 'Twitter',
- 'url' => 'https://twitter.com',
- 'photo' => 'https://upload.wikimedia.org/wikipedia/commons/4/4f/Twitter-logo.svg',
- ],
- 'user' => [
- 'name' => 'jonnybarnes',
- 'url' => 'https://twitter.com/jonnybarnes',
- 'photo' => 'https://pbs.twimg.com/profile_images/875422855932121089/W628ZI8w_400x400.jpg',
- ],
- ],
- ],
-];
diff --git a/database/factories/SyndicationTargetFactory.php b/database/factories/SyndicationTargetFactory.php
new file mode 100644
index 00000000..c877c9d4
--- /dev/null
+++ b/database/factories/SyndicationTargetFactory.php
@@ -0,0 +1,30 @@
+
+ */
+class SyndicationTargetFactory extends Factory
+{
+ /**
+ * Define the model's default state.
+ *
+ * @return array No saved syndication targets.
+ Create a new syndication target?
+ New Syndication Target
+
+@stop
diff --git a/resources/views/admin/syndication/edit.blade.php b/resources/views/admin/syndication/edit.blade.php
new file mode 100644
index 00000000..400ff5d4
--- /dev/null
+++ b/resources/views/admin/syndication/edit.blade.php
@@ -0,0 +1,52 @@
+@extends('master')
+
+@section('title')Edit Syndication Target « Admin CP « @stop
+
+@section('content')
+ Edit syndication target
+
+
+
+@stop
diff --git a/resources/views/admin/syndication/index.blade.php b/resources/views/admin/syndication/index.blade.php
new file mode 100644
index 00000000..513e2c76
--- /dev/null
+++ b/resources/views/admin/syndication/index.blade.php
@@ -0,0 +1,22 @@
+@extends('master')
+
+@section('title')List Syndication Targets « Admin CP « @stop
+
+@section('content')
+ Syndication Targets
+ @if($targets->isEmpty())
+
+ @foreach($targets as $target)
+
+ @endif
+
+ You can either create new syndication targets, + or edit them. +
@stop diff --git a/routes/web.php b/routes/web.php index 4d83f871..f721a2df 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,6 +18,7 @@ use App\Http\Controllers\Admin\HomeController; use App\Http\Controllers\Admin\LikesController as AdminLikesController; use App\Http\Controllers\Admin\NotesController as AdminNotesController; use App\Http\Controllers\Admin\PlacesController as AdminPlacesController; +use App\Http\Controllers\Admin\SyndicationTargetsController; use App\Http\Controllers\ArticlesController; use App\Http\Controllers\AuthController; use App\Http\Controllers\BookmarksController; @@ -122,6 +123,16 @@ Route::group(['domain' => config('url.longurl')], function () { Route::put('/{id}', [AdminLikesController::class, 'update']); Route::delete('/{id}', [AdminLikesController::class, 'destroy']); }); + + // Syndication Targets + Route::group(['prefix' => 'syndication'], function () { + Route::get('/', [SyndicationTargetsController::class, 'index']); + Route::get('/create', [SyndicationTargetsController::class, 'create']); + Route::post('/', [SyndicationTargetsController::class, 'store']); + Route::get('/{syndicationTarget}/edit', [SyndicationTargetsController::class, 'edit']); + Route::put('/{syndicationTarget}', [SyndicationTargetsController::class, 'update']); + Route::delete('/{syndicationTarget}', [SyndicationTargetsController::class, 'destroy']); + }); }); // Blog pages using ArticlesController diff --git a/tests/Feature/BookmarksTest.php b/tests/Feature/BookmarksTest.php index 8b298dbf..b1f25982 100644 --- a/tests/Feature/BookmarksTest.php +++ b/tests/Feature/BookmarksTest.php @@ -7,6 +7,7 @@ namespace Tests\Feature; use App\Jobs\ProcessBookmark; use App\Jobs\SyndicateBookmarkToTwitter; use App\Models\Bookmark; +use App\Models\SyndicationTarget; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Queue; use Tests\TestCase; @@ -36,6 +37,11 @@ class BookmarksTest extends TestCase { Queue::fake(); + SyndicationTarget::factory()->create([ + 'uid' => 'https://twitter.com/jonnybarnes', + 'service_name' => 'Twitter', + ]); + $response = $this->withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), ])->post('/api/post', [ @@ -58,6 +64,11 @@ class BookmarksTest extends TestCase { Queue::fake(); + SyndicationTarget::factory()->create([ + 'uid' => 'https://twitter.com/jonnybarnes', + 'service_name' => 'Twitter', + ]); + $response = $this->withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), ])->json('POST', '/api/post', [ @@ -82,6 +93,11 @@ class BookmarksTest extends TestCase { Queue::fake(); + SyndicationTarget::factory()->create([ + 'uid' => 'https://twitter.com/jonnybarnes', + 'service_name' => 'Twitter', + ]); + $response = $this->withHeaders([ 'Authorization' => 'Bearer ' . $this->getToken(), ])->post('/api/post', [ diff --git a/tests/Feature/MicropubControllerTest.php b/tests/Feature/MicropubControllerTest.php index 688ca1b8..12604ad3 100644 --- a/tests/Feature/MicropubControllerTest.php +++ b/tests/Feature/MicropubControllerTest.php @@ -9,6 +9,7 @@ use App\Jobs\SyndicateNoteToTwitter; use App\Models\Media; use App\Models\Note; use App\Models\Place; +use App\Models\SyndicationTarget; use Carbon\Carbon; use Faker\Factory; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -51,10 +52,18 @@ class MicropubControllerTest extends TestCase } /** @test */ - public function micropubClientsCanRequestSyndicationTargets(): void + public function micropubClientsCanRequestSyndicationTargetsCanBeEmpty(): void { $response = $this->get('/api/post?q=syndicate-to', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]); - $response->assertJsonFragment(['uid' => 'https://twitter.com/jonnybarnes']); + $response->assertJsonFragment(['syndicate-to' => []]); + } + + /** @test */ + public function micropubClientsCanRequestSyndicationTargetsPopulatesFromModel(): void + { + $syndicationTarget = SyndicationTarget::factory()->create(); + $response = $this->get('/api/post?q=syndicate-to', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]); + $response->assertJsonFragment(['uid' => $syndicationTarget->uid]); } /** @test */ @@ -91,7 +100,7 @@ class MicropubControllerTest extends TestCase public function micropubClientCanRequestEndpointConfig(): void { $response = $this->get('/api/post?q=config', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]); - $response->assertJsonFragment(['uid' => 'https://twitter.com/jonnybarnes']); + $response->assertJsonFragment(['media-endpoint' => route('media-endpoint')]); } /** @test */ @@ -117,6 +126,12 @@ class MicropubControllerTest extends TestCase public function micropubClientCanRequestTheNewNoteIsSyndicatedToTwitter(): void { Queue::fake(); + + SyndicationTarget::factory()->create([ + 'uid' => 'https://twitter.com/jonnybarnes', + 'service_name' => 'Twitter', + ]); + $faker = Factory::create(); $note = $faker->text; $response = $this->post( @@ -224,6 +239,11 @@ class MicropubControllerTest extends TestCase 'path' => 'test-photo.jpg', 'type' => 'image', ]); + SyndicationTarget::factory()->create([ + 'uid' => 'https://twitter.com/jonnybarnes', + 'service_name' => 'Twitter', + ]); + $faker = Factory::create(); $note = $faker->text; $response = $this->postJson(