2010-03-04 04:20:04 +00:00
|
|
|
<?php
|
2020-09-08 10:42:51 +01:00
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
2010-03-04 04:20:04 +00:00
|
|
|
|
|
|
|
/**
|
2020-09-08 10:42:51 +01:00
|
|
|
* @package WebFingerPlugin
|
|
|
|
* @author James Walker <james@status.net>
|
|
|
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
|
|
|
* @copyright 2010 StatusNet, Inc.
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2010-03-04 04:20:04 +00:00
|
|
|
*/
|
|
|
|
|
2020-09-08 10:42:51 +01:00
|
|
|
defined('GNUSOCIAL') || die();
|
2010-03-04 04:20:04 +00:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
class OwnerxrdAction extends WebfingerAction
|
2010-03-04 04:20:04 +00:00
|
|
|
{
|
2013-09-30 16:13:03 +01:00
|
|
|
protected $defaultformat = 'xml';
|
2010-03-04 04:20:04 +00:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
protected function prepare(array $args=array())
|
2010-03-04 04:20:04 +00:00
|
|
|
{
|
2013-09-30 16:13:03 +01:00
|
|
|
$user = User::siteOwner();
|
2010-09-03 00:35:04 +01:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
$nick = common_canonical_nickname($user->nickname);
|
|
|
|
$args['resource'] = 'acct:' . $nick . '@' . common_config('site', 'server');
|
2010-03-04 04:20:04 +00:00
|
|
|
|
2020-09-08 10:42:51 +01:00
|
|
|
// We have now set $args['resource'] to the configured value, since
|
2013-09-30 16:13:03 +01:00
|
|
|
// only this local site configuration knows who the owner is!
|
|
|
|
parent::prepare($args);
|
2010-09-03 00:35:04 +01:00
|
|
|
|
2013-09-30 16:13:03 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function setXRD()
|
|
|
|
{
|
|
|
|
parent::setXRD();
|
2010-03-04 04:20:04 +00:00
|
|
|
|
|
|
|
// Check to see if a $config['webfinger']['owner'] has been set
|
2013-09-30 16:13:03 +01:00
|
|
|
// and then make sure 'subject' is set to that primary identity.
|
2020-09-08 10:42:51 +01:00
|
|
|
if (!empty($owner = common_config('webfinger', 'owner'))) {
|
2013-09-30 16:13:03 +01:00
|
|
|
$this->xrd->aliases[] = $this->xrd->subject;
|
2010-03-04 04:20:04 +00:00
|
|
|
$this->xrd->subject = Discovery::normalize($owner);
|
|
|
|
} else {
|
2013-09-30 16:13:03 +01:00
|
|
|
$this->xrd->subject = $this->resource;
|
2010-03-04 04:20:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|