ownerxrd.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * @package WebFingerPlugin
  18. * @author James Walker <james@status.net>
  19. * @author Mikael Nordfeldth <mmn@hethane.se>
  20. * @copyright 2010 StatusNet, Inc.
  21. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  22. */
  23. defined('GNUSOCIAL') || die();
  24. class OwnerxrdAction extends WebfingerAction
  25. {
  26. protected $defaultformat = 'xml';
  27. protected function prepare(array $args=array())
  28. {
  29. $user = User::siteOwner();
  30. $nick = common_canonical_nickname($user->nickname);
  31. $args['resource'] = 'acct:' . $nick . '@' . common_config('site', 'server');
  32. // We have now set $args['resource'] to the configured value, since
  33. // only this local site configuration knows who the owner is!
  34. parent::prepare($args);
  35. return true;
  36. }
  37. protected function setXRD()
  38. {
  39. parent::setXRD();
  40. // Check to see if a $config['webfinger']['owner'] has been set
  41. // and then make sure 'subject' is set to that primary identity.
  42. if (!empty($owner = common_config('webfinger', 'owner'))) {
  43. $this->xrd->aliases[] = $this->xrd->subject;
  44. $this->xrd->subject = Discovery::normalize($owner);
  45. } else {
  46. $this->xrd->subject = $this->resource;
  47. }
  48. }
  49. }