. */ if (!defined('GNUSOCIAL')) { exit(1); } /** * @package WebFingerPlugin * @author James Walker * @author Mikael Nordfeldth */ class WebfingerAction extends XrdAction { protected $resource = null; // string with the resource URI protected $target = null; // object of the WebFingerResource class protected function prepare(array $args=array()) { parent::prepare($args); // throws exception if resource is empty $this->resource = Discovery::normalize($this->trimmed('resource')); if (Event::handle('StartGetWebFingerResource', array($this->resource, &$this->target, $this->args))) { Event::handle('EndGetWebFingerResource', array($this->resource, &$this->target, $this->args)); } return true; } protected function setXRD() { if (!($this->target instanceof WebFingerResource)) { throw new Exception(_('Target not set for resource descriptor')); } $this->xrd->subject = $this->resource; foreach ($this->target->getAliases() as $alias) { if ($alias != $this->xrd->subject && !in_array($alias, $this->xrd->aliases)) { $this->xrd->aliases[] = $alias; } } $this->target->updateXRD($this->xrd); } }