1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class WebfingerAction extends XrdAction
- {
- protected $resource = null;
- protected $target = null;
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
-
- $this->resource = Discovery::normalize($this->trimmed('resource'));
- try {
- if (Event::handle('StartGetWebFingerResource', array($this->resource, &$this->target, $this->args))) {
- Event::handle('EndGetWebFingerResource', array($this->resource, &$this->target, $this->args));
- }
- } catch (NoSuchUserException $e) {
- throw new ServerException($e->getMessage(), 404);
- }
- if (!$this->target instanceof WebFingerResource) {
-
- throw new ServerException(_m('Resource not found in local database.'), 404);
- }
- return true;
- }
- protected function setXRD()
- {
- $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);
- }
- }
|