notice.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * WebFinger resource for Notice objects
  4. *
  5. * @package GNUsocial
  6. * @author Mikael Nordfeldth
  7. * @copyright 2013 Free Software Foundation, Inc.
  8. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  9. * @link http://status.net/
  10. */
  11. class WebFingerResource_Notice extends WebFingerResource
  12. {
  13. public function __construct(Notice $object)
  14. {
  15. // The type argument above verifies that it's our class
  16. parent::__construct($object);
  17. }
  18. public function updateXRD(XML_XRD $xrd)
  19. {
  20. if (Event::handle('StartWebFingerNoticeLinks', array($xrd, $this->object))) {
  21. if ($this->object->isLocal()) {
  22. $xrd->links[] = new XML_XRD_Element_Link('alternate',
  23. common_local_url('ApiStatusesShow',
  24. array('id'=>$this->object->id,
  25. 'format'=>'atom')),
  26. 'application/atom+xml');
  27. $xrd->links[] = new XML_XRD_Element_Link('alternate',
  28. common_local_url('ApiStatusesShow',
  29. array('id'=>$this->object->id,
  30. 'format'=>'json')),
  31. 'application/json');
  32. } else {
  33. try {
  34. $xrd->links[] = new XML_XRD_Element_Link('alternate',
  35. $this->object->getUrl(),
  36. 'text/html');
  37. } catch (InvalidUrlException $e) {
  38. // don't do a fallback in webfinger
  39. }
  40. }
  41. Event::handle('EndWebFingerNoticeLinks', array($xrd, $this->object));
  42. }
  43. }
  44. }