[PLUGIN][Pinboard] Refactor and cleanup code
This commit is contained in:
@@ -17,7 +17,9 @@ use App\Util\Exception\ClientException;
|
||||
use App\Util\Exception\ServerException;
|
||||
use App\Util\Formatting;
|
||||
use Component\Conversation\Conversation;
|
||||
use Component\Link\Link;
|
||||
use Component\Tag\Entity\NoteTag;
|
||||
use Component\Tag\Tag;
|
||||
use Datetime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
@@ -29,8 +31,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Component\Tag\Tag;
|
||||
use Component\Link\Link;
|
||||
|
||||
class APIv1 extends Controller
|
||||
{
|
||||
@@ -82,7 +82,7 @@ class APIv1 extends Controller
|
||||
return null;
|
||||
}
|
||||
[$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();
|
||||
} else {
|
||||
return null;
|
||||
@@ -108,7 +108,7 @@ class APIv1 extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Pin[] $pins
|
||||
* @param Pin[] $pins
|
||||
* @param string[] $tags
|
||||
*/
|
||||
private function filterByTags(array $pins, array $tags): array
|
||||
@@ -270,7 +270,7 @@ class APIv1 extends Controller
|
||||
$user = $check;
|
||||
}
|
||||
|
||||
$url = $this->string('url');
|
||||
$url = $this->string('url');
|
||||
if (\is_null($url)) {
|
||||
throw new ClientException('URL must be provided');
|
||||
}
|
||||
@@ -409,4 +409,15 @@ class APIv1 extends Controller
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user