[PLUGIN][Pinboard] Refactor and cleanup code
This commit is contained in:
parent
74ffd261b8
commit
539104ec33
|
@ -17,7 +17,9 @@ use App\Util\Exception\ClientException;
|
||||||
use App\Util\Exception\ServerException;
|
use App\Util\Exception\ServerException;
|
||||||
use App\Util\Formatting;
|
use App\Util\Formatting;
|
||||||
use Component\Conversation\Conversation;
|
use Component\Conversation\Conversation;
|
||||||
|
use Component\Link\Link;
|
||||||
use Component\Tag\Entity\NoteTag;
|
use Component\Tag\Entity\NoteTag;
|
||||||
|
use Component\Tag\Tag;
|
||||||
use Datetime;
|
use Datetime;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
@ -29,8 +31,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||||
use Component\Tag\Tag;
|
|
||||||
use Component\Link\Link;
|
|
||||||
|
|
||||||
class APIv1 extends Controller
|
class APIv1 extends Controller
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ class APIv1 extends Controller
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
[$id, $token] = explode(':', $input);
|
[$id, $token] = explode(':', $input);
|
||||||
if (filter_var($id, FILTER_VALIDATE_INT) !== false) {
|
if (filter_var($id, \FILTER_VALIDATE_INT) !== false) {
|
||||||
return Token::get((int) $id, $token)?->getUser();
|
return Token::get((int) $id, $token)?->getUser();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -409,4 +409,15 @@ class APIv1 extends Controller
|
||||||
|
|
||||||
return self::respond($tags_freq);
|
return self::respond($tags_freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function unimplmented(Request $request)
|
||||||
|
{
|
||||||
|
$check = self::preCheck();
|
||||||
|
if (!$check instanceof LocalUser) {
|
||||||
|
return $check;
|
||||||
|
} else {
|
||||||
|
$user = $check;
|
||||||
|
}
|
||||||
|
return self::respond(['result_code' => 'something went wrong', 'reason' => 'Unimplemented']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,54 +44,26 @@ class Pinboard extends Plugin
|
||||||
|
|
||||||
public function onAddRoute(Router $r): bool
|
public function onAddRoute(Router $r): bool
|
||||||
{
|
{
|
||||||
$r->connect(
|
$r->connect(self::controller_route, '/pinboard/settings', C\Settings::class, options: ['method' => 'post']);
|
||||||
self::controller_route,
|
|
||||||
'/pinboard/settings',
|
|
||||||
C\Settings::class,
|
|
||||||
options: ['method' => 'post'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$r->connect(
|
$r->connect('pinboard_posts_update', '/pinboard/v1/posts/update', [C\APIv1::class, 'posts_update']);
|
||||||
'pinboard_posts_update',
|
$r->connect('pinboard_posts_add', '/pinboard/v1/posts/add', [C\APIv1::class, 'posts_add']);
|
||||||
'/pinboard/v1/posts/update',
|
$r->connect('pinboard_posts_delete', '/pinboard/v1/posts/delete', [C\APIv1::class, 'posts_delete']);
|
||||||
[C\APIv1::class, 'posts_update'],
|
$r->connect('pinboard_posts_get', '/pinboard/v1/posts/get', [C\APIv1::class, 'posts_get']);
|
||||||
);
|
$r->connect('pinboard_posts_recent', '/pinboard/v1/posts/recent', [C\APIv1::class, 'posts_recent']);
|
||||||
|
$r->connect('pinboard_posts_all', '/pinboard/v1/posts/all', [C\APIv1::class, 'posts_all']);
|
||||||
|
|
||||||
$r->connect(
|
$r->connect('pinboard_posts_dates', '/pinboard/v1/posts/dates', [C\APIv1::class, 'unimplemented']);
|
||||||
'pinboard_posts_add',
|
$r->connect('pinboard_posts_suggest', '/pinboard/v1/posts/suggest', [C\APIv1::class, 'unimplemented']);
|
||||||
'/pinboard/v1/posts/add',
|
|
||||||
[C\APIv1::class, 'posts_add'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$r->connect(
|
$r->connect('pinboard_tags_get', '/pinboard/v1/tags/get', [C\APIv1::class, 'tags_get']);
|
||||||
'pinboard_posts_delete',
|
|
||||||
'/pinboard/v1/posts/delete',
|
|
||||||
[C\APIv1::class, 'posts_delete'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$r->connect(
|
$r->connect('pinboard_tags_delete', '/pinboard/v1/tags/delete', [C\APIv1::class, 'unimplemented']);
|
||||||
'pinboard_posts_get',
|
$r->connect('pinboard_tags_rename', '/pinboard/v1/tags/rename', [C\APIv1::class, 'unimplemented']);
|
||||||
'/pinboard/v1/posts/get',
|
$r->connect('pinboard_user_secret', '/pinboard/v1/user/secret', [C\APIv1::class, 'unimplemented']);
|
||||||
[C\APIv1::class, 'posts_get'],
|
$r->connect('pinboard_user_api_token', '/pinboard/v1/user/api_token', [C\APIv1::class, 'unimplemented']);
|
||||||
);
|
$r->connect('pinboard_notes_list', '/pinboard/v1/notes/list', [C\APIv1::class, 'unimplemented']);
|
||||||
|
$r->connect('pinboard_notes_id', '/pinboard/v1/notes/{id}', [C\APIv1::class, 'unimplemented']);
|
||||||
$r->connect(
|
|
||||||
'pinboard_posts_recent',
|
|
||||||
'/pinboard/v1/posts/recent',
|
|
||||||
[C\APIv1::class, 'posts_recent'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$r->connect(
|
|
||||||
'pinboard_posts_all',
|
|
||||||
'/pinboard/v1/posts/all',
|
|
||||||
[C\APIv1::class, 'posts_all'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$r->connect(
|
|
||||||
'pinboard_tags_get',
|
|
||||||
'/pinboard/v1/tags/get',
|
|
||||||
[C\APIv1::class, 'tags_get'],
|
|
||||||
);
|
|
||||||
|
|
||||||
return Event::next;
|
return Event::next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user