2021-04-02 19:20:02 +02:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-02 19:20:02 +02:00
|
|
|
/**
|
2022-02-19 17:06:11 +01:00
|
|
|
* @copyright 2021 Ad Aures
|
2021-04-02 19:20:02 +02:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-23 13:05:16 +02:00
|
|
|
namespace Modules\Fediverse\Controllers;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
|
|
|
use CodeIgniter\Controller;
|
2021-05-19 18:35:13 +02:00
|
|
|
use CodeIgniter\Exceptions\PageNotFoundException;
|
|
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
2021-04-02 19:20:02 +02:00
|
|
|
use Exception;
|
2021-08-23 13:05:16 +02:00
|
|
|
use Modules\Fediverse\WebFinger;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
|
|
|
class WebFingerController extends Controller
|
|
|
|
{
|
2021-05-06 16:00:48 +02:00
|
|
|
public function index(): ResponseInterface
|
2021-04-02 19:20:02 +02:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
$webfinger = new WebFinger($this->request->getGet('resource'));
|
2021-05-14 19:59:35 +02:00
|
|
|
} catch (Exception) {
|
2021-04-02 19:20:02 +02:00
|
|
|
// return 404, actor not found
|
2021-05-06 16:00:48 +02:00
|
|
|
throw PageNotFoundException::forPageNotFound();
|
2021-04-02 19:20:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->response->setJSON($webfinger->toArray());
|
|
|
|
}
|
|
|
|
}
|