1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- declare(strict_types = 1);
- namespace Component\FreeNetwork\Util\WebfingerResource;
- use App\Core\Event;
- use App\Entity\Note;
- use Component\FreeNetwork\Util\WebfingerResource;
- use PharIo\Manifest\InvalidUrlException;
- use XML_XRD;
- use XML_XRD_Element_Link;
- /**
- * WebFinger resource for Note objects
- *
- * @package GNUsocial
- *
- * @author Mikael Nordfeldth
- * @copyright 2013 Free Software Foundation, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- *
- * @see http://status.net/
- */
- class WebfingerResourceNote extends WebfingerResource
- {
- public function __construct(?Note $object = null)
- {
- // The type argument above verifies that it's our class
- parent::__construct($object);
- }
- /**
- * Update given XRD with self's data
- */
- public function updateXRD(XML_XRD $xrd)
- {
- if (Event::handle('StartWebFingerNoticeLinks', [$xrd, $this->object])) {
- if ($this->object->isLocal()) {
- $xrd->links[] = new XML_XRD_Element_Link(
- 'alternate',
- common_local_url(
- 'ApiStatusesShow',
- ['id' => $this->object->id,
- 'format' => 'atom', ],
- ),
- 'application/atom+xml',
- );
- $xrd->links[] = new XML_XRD_Element_Link(
- 'alternate',
- common_local_url(
- 'ApiStatusesShow',
- ['id' => $this->object->id,
- 'format' => 'json', ],
- ),
- 'application/json',
- );
- } else {
- try {
- $xrd->links[] = new XML_XRD_Element_Link(
- 'alternate',
- $this->object->getUrl(),
- 'text/html',
- );
- } catch (InvalidUrlException $e) {
- // don't do a fallback in webfinger
- }
- }
- Event::handle('EndWebFingerNoticeLinks', [$xrd, $this->object]);
- }
- }
- }
|