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