FreeNetwork.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <?php
  2. declare(strict_types = 1);
  3. // {{{ License
  4. // This file is part of GNU social - https://www.gnu.org/software/social
  5. //
  6. // GNU social is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // GNU social is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  18. // }}}
  19. namespace Component\FreeNetwork;
  20. use App\Core\DB\DB;
  21. use App\Core\Event;
  22. use App\Core\GSFile;
  23. use App\Core\HTTPClient;
  24. use function App\Core\I18n\_m;
  25. use App\Core\Log;
  26. use App\Core\Modules\Component;
  27. use App\Core\Router\RouteLoader;
  28. use App\Core\Router\Router;
  29. use App\Entity\Activity;
  30. use App\Entity\Actor;
  31. use App\Entity\LocalUser;
  32. use App\Entity\Note;
  33. use App\Util\Common;
  34. use App\Util\Exception\ClientException;
  35. use App\Util\Exception\NicknameEmptyException;
  36. use App\Util\Exception\NicknameException;
  37. use App\Util\Exception\NicknameInvalidException;
  38. use App\Util\Exception\NicknameNotAllowedException;
  39. use App\Util\Exception\NicknameTakenException;
  40. use App\Util\Exception\NicknameTooLongException;
  41. use App\Util\Exception\NoSuchActorException;
  42. use App\Util\Exception\ServerException;
  43. use App\Util\Formatting;
  44. use App\Util\Nickname;
  45. use Component\FreeNetwork\Controller\Feeds;
  46. use Component\FreeNetwork\Controller\HostMeta;
  47. use Component\FreeNetwork\Controller\OwnerXrd;
  48. use Component\FreeNetwork\Controller\Webfinger;
  49. use Component\FreeNetwork\Util\Discovery;
  50. use Component\FreeNetwork\Util\WebfingerResource;
  51. use Component\FreeNetwork\Util\WebfingerResource\WebfingerResourceActor;
  52. use Component\FreeNetwork\Util\WebfingerResource\WebfingerResourceNote;
  53. use Doctrine\Common\Collections\ExpressionBuilder;
  54. use Exception;
  55. use const PREG_SET_ORDER;
  56. use Symfony\Component\HttpFoundation\JsonResponse;
  57. use Symfony\Component\HttpFoundation\Response;
  58. use XML_XRD;
  59. use XML_XRD_Element_Link;
  60. /**
  61. * Implements WebFinger (RFC7033) for GNU social, as well as Link-based Resource Descriptor Discovery based on RFC6415,
  62. * Web Host Metadata ('.well-known/host-meta') resource.
  63. *
  64. * @package GNUsocial
  65. *
  66. * @author Mikael Nordfeldth <mmn@hethane.se>
  67. * @author Diogo Peralta Cordeiro <mail@diogo.site>
  68. */
  69. class FreeNetwork extends Component
  70. {
  71. public const PLUGIN_VERSION = '0.1.0';
  72. public const OAUTH_ACCESS_TOKEN_REL = 'http://apinamespace.org/oauth/access_token';
  73. public const OAUTH_REQUEST_TOKEN_REL = 'http://apinamespace.org/oauth/request_token';
  74. public const OAUTH_AUTHORIZE_REL = 'http://apinamespace.org/oauth/authorize';
  75. private static array $protocols = [];
  76. public function onInitializeComponent(): bool
  77. {
  78. Event::handle('AddFreeNetworkProtocol', [&self::$protocols]);
  79. return Event::next;
  80. }
  81. public function onAddRoute(RouteLoader $m): bool
  82. {
  83. // Feeds
  84. $m->connect('feed_network', '/feed/network', [Feeds::class, 'network']);
  85. $m->connect('feed_clique', '/feed/clique', [Feeds::class, 'clique']);
  86. $m->connect('feed_federated', '/feed/federated', [Feeds::class, 'federated']);
  87. $m->connect('freenetwork_hostmeta', '.well-known/host-meta', [HostMeta::class, 'handle']);
  88. $m->connect(
  89. 'freenetwork_hostmeta_format',
  90. '.well-known/host-meta.:format',
  91. [HostMeta::class, 'handle'],
  92. ['format' => '(xml|json)'],
  93. );
  94. // the resource GET parameter can be anywhere, so don't mention it here
  95. $m->connect('freenetwork_webfinger', '.well-known/webfinger', [Webfinger::class, 'handle']);
  96. $m->connect(
  97. 'freenetwork_webfinger_format',
  98. '.well-known/webfinger.:format',
  99. [Webfinger::class, 'handle'],
  100. ['format' => '(xml|json)'],
  101. );
  102. $m->connect('freenetwork_ownerxrd', 'main/ownerxrd', [OwnerXrd::class, 'handle']);
  103. return Event::next;
  104. }
  105. public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering)
  106. {
  107. DB::persist(\App\Entity\Feed::create(['actor_id' => $actor_id, 'url' => Router::url($route = 'feed_network'), 'route' => $route, 'title' => _m('Meteorites'), 'ordering' => $ordering++]));
  108. DB::persist(\App\Entity\Feed::create(['actor_id' => $actor_id, 'url' => Router::url($route = 'feed_clique'), 'route' => $route, 'title' => _m('Planetary System'), 'ordering' => $ordering++]));
  109. DB::persist(\App\Entity\Feed::create(['actor_id' => $actor_id, 'url' => Router::url($route = 'feed_federated'), 'route' => $route, 'title' => _m('Galaxy'), 'ordering' => $ordering++]));
  110. return Event::next;
  111. }
  112. public function onStartGetProfileAcctUri(Actor $profile, &$acct): bool
  113. {
  114. $wfr = new WebFingerResourceActor($profile);
  115. try {
  116. $acct = $wfr->reconstructAcct();
  117. } catch (Exception) {
  118. return Event::next;
  119. }
  120. return Event::stop;
  121. }
  122. /**
  123. * Last attempts getting a WebFingerResource object
  124. *
  125. * @param string $resource String that contains the requested URI
  126. * @param null|WebfingerResource $target WebFingerResource extended object goes here
  127. * @param array $args Array which may contains arguments such as 'rel' filtering values
  128. *
  129. * @throws NicknameEmptyException
  130. * @throws NicknameException
  131. * @throws NicknameInvalidException
  132. * @throws NicknameNotAllowedException
  133. * @throws NicknameTakenException
  134. * @throws NicknameTooLongException
  135. * @throws NoSuchActorException
  136. * @throws ServerException
  137. */
  138. public function onEndGetWebFingerResource(string $resource, ?WebfingerResource &$target = null, array $args = []): bool
  139. {
  140. // * Either we didn't find the profile, then we want to make
  141. // the $profile variable null for clarity.
  142. // * Or we did find it but for a possibly malicious remote
  143. // user who might've set their profile URL to a Note URL
  144. // which would've caused a sort of DoS unless we continue
  145. // our search here by discarding the remote profile.
  146. $profile = null;
  147. if (Discovery::isAcct($resource)) {
  148. $parts = explode('@', mb_substr(urldecode($resource), 5)); // 5 is strlen of 'acct:'
  149. if (\count($parts) === 2) {
  150. [$nick, $domain] = $parts;
  151. if ($domain !== Common::config('site', 'server')) {
  152. throw new ServerException(_m('Remote profiles not supported via WebFinger yet.'));
  153. }
  154. $nick = Nickname::normalize(nickname: $nick, check_already_used: false, check_is_allowed: false);
  155. $freenetwork_actor = LocalUser::getByPK(['nickname' => $nick]);
  156. if (!($freenetwork_actor instanceof LocalUser)) {
  157. throw new NoSuchActorException($nick);
  158. }
  159. $profile = $freenetwork_actor->getActor();
  160. }
  161. } else {
  162. try {
  163. if (Common::isValidHttpUrl($resource)) {
  164. // This means $resource is a valid url
  165. $resource_parts = parse_url($resource);
  166. // TODO: Use URLMatcher
  167. if ($resource_parts['host'] === Common::config('site', 'server')) {
  168. $str = $resource_parts['path'];
  169. // actor_view_nickname
  170. $renick = '/\/@(' . Nickname::DISPLAY_FMT . ')\/?/m';
  171. // actor_view_id
  172. $reuri = '/\/actor\/(\d+)\/?/m';
  173. if (preg_match_all($renick, $str, $matches, PREG_SET_ORDER, 0) === 1) {
  174. $profile = LocalUser::getByPK(['nickname' => $matches[0][1]])->getActor();
  175. } elseif (preg_match_all($reuri, $str, $matches, PREG_SET_ORDER, 0) === 1) {
  176. $profile = Actor::getById((int) $matches[0][1]);
  177. }
  178. }
  179. }
  180. } catch (NoSuchActorException $e) {
  181. // not a User, maybe a Note? we'll try that further down...
  182. // try {
  183. // Log::debug(__METHOD__ . ': Finding User_group URI for WebFinger lookup on resource==' . $resource);
  184. // $group = new User_group();
  185. // $group->whereAddIn('uri', array_keys($alt_urls), $group->columnType('uri'));
  186. // $group->limit(1);
  187. // if ($group->find(true)) {
  188. // $profile = $group->getProfile();
  189. // }
  190. // unset($group);
  191. // } catch (Exception $e) {
  192. // Log::error(get_class($e) . ': ' . $e->getMessage());
  193. // throw $e;
  194. // }
  195. }
  196. }
  197. if ($profile instanceof Actor) {
  198. Log::debug(__METHOD__ . ': Found Profile with ID==' . $profile->getID() . ' for resource==' . $resource);
  199. $target = new WebfingerResourceActor($profile);
  200. return Event::stop; // We got our target, stop handler execution
  201. }
  202. if (!\is_null($note = DB::findOneBy(Note::class, ['url' => $resource], return_null: true))) {
  203. $target = new WebfingerResourceNote($note);
  204. return Event::stop; // We got our target, stop handler execution
  205. }
  206. return Event::next;
  207. }
  208. public function onStartHostMetaLinks(array &$links): bool
  209. {
  210. foreach (Discovery::supportedMimeTypes() as $type) {
  211. $links[] = new XML_XRD_Element_Link(
  212. Discovery::LRDD_REL,
  213. Router::url(id: 'freenetwork_webfinger', args: [], type: Router::ABSOLUTE_URL) . '?resource={uri}',
  214. $type,
  215. isTemplate: true,
  216. );
  217. }
  218. // TODO OAuth connections
  219. //$links[] = new XML_XRD_Element_link(self::OAUTH_ACCESS_TOKEN_REL, common_local_url('ApiOAuthAccessToken'));
  220. //$links[] = new XML_XRD_Element_link(self::OAUTH_REQUEST_TOKEN_REL, common_local_url('ApiOAuthRequestToken'));
  221. //$links[] = new XML_XRD_Element_link(self::OAUTH_AUTHORIZE_REL, common_local_url('ApiOAuthAuthorize'));
  222. return Event::next;
  223. }
  224. /**
  225. * Add a link header for LRDD Discovery
  226. */
  227. public function onStartShowHTML($action): bool
  228. {
  229. if ($action instanceof ShowstreamAction) {
  230. $resource = $action->getTarget()->getUri();
  231. $url = common_local_url('webfinger') . '?resource=' . urlencode($resource);
  232. foreach ([Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE] as $type) {
  233. header('Link: <' . $url . '>; rel="' . Discovery::LRDD_REL . '"; type="' . $type . '"', false);
  234. }
  235. }
  236. return Event::next;
  237. }
  238. public function onStartDiscoveryMethodRegistration(Discovery $disco): bool
  239. {
  240. $disco->registerMethod('\Component\FreeNetwork\Util\LrddMethod\LrddMethodWebfinger');
  241. return Event::next;
  242. }
  243. public function onEndDiscoveryMethodRegistration(Discovery $disco): bool
  244. {
  245. $disco->registerMethod('\Component\FreeNetwork\Util\LrddMethod\LrddMethodHostMeta');
  246. $disco->registerMethod('\Component\FreeNetwork\Util\LrddMethod\LrddMethodLinkHeader');
  247. $disco->registerMethod('\Component\FreeNetwork\Util\LrddMethod\LrddMethodLinkHtml');
  248. return Event::next;
  249. }
  250. /**
  251. * @throws ClientException
  252. * @throws ServerException
  253. */
  254. public function onControllerResponseInFormat(string $route, array $accept_header, array $vars, ?Response &$response = null): bool
  255. {
  256. if (!\in_array($route, ['freenetwork_hostmeta', 'freenetwork_hostmeta_format', 'freenetwork_webfinger', 'freenetwork_webfinger_format', 'freenetwork_ownerxrd'])) {
  257. return Event::next;
  258. }
  259. $mimeType = array_intersect(array_values(Discovery::supportedMimeTypes()), $accept_header);
  260. /*
  261. * "A WebFinger resource MUST return a JRD as the representation
  262. * for the resource if the client requests no other supported
  263. * format explicitly via the HTTP "Accept" header. [...]
  264. * The WebFinger resource MUST silently ignore any requested
  265. * representations that it does not understand and support."
  266. * -- RFC 7033 (WebFinger)
  267. * http://tools.ietf.org/html/rfc7033
  268. */
  269. $mimeType = \count($mimeType) !== 0 ? array_pop($mimeType) : $vars['default_mimetype'];
  270. $headers = [];
  271. if (Common::config('discovery', 'cors')) {
  272. $headers['Access-Control-Allow-Origin'] = '*';
  273. }
  274. $headers['Content-Type'] = $mimeType;
  275. $response = match ($mimeType) {
  276. Discovery::XRD_MIMETYPE => new Response(content: $vars['xrd']->to('xml'), headers: $headers),
  277. Discovery::JRD_MIMETYPE, Discovery::JRD_MIMETYPE_OLD => new JsonResponse(data: $vars['xrd']->to('json'), headers: $headers, json: true),
  278. };
  279. $response->headers->set('cache-control', 'no-store, no-cache, must-revalidate');
  280. return Event::stop;
  281. }
  282. /**
  283. * Webfinger matches: @user@example.com or even @user--one.george_orwell@1984.biz
  284. *
  285. * @param string $text The text from which to extract webfinger IDs
  286. * @param string $preMention Character(s) that signals a mention ('@', '!'...)
  287. *
  288. * @return array the matching IDs (without $preMention) and each respective position in the given string
  289. */
  290. public static function extractWebfingerIds(string $text, string $preMention = '@'): array
  291. {
  292. $wmatches = [];
  293. $result = preg_match_all(
  294. '/' . Nickname::BEFORE_MENTIONS . preg_quote($preMention, '/') . '(' . Nickname::WEBFINGER_FMT . ')/',
  295. $text,
  296. $wmatches,
  297. \PREG_OFFSET_CAPTURE,
  298. );
  299. if ($result === false) {
  300. Log::error(__METHOD__ . ': Error parsing webfinger IDs from text (preg_last_error==' . preg_last_error() . ').');
  301. return [];
  302. } elseif (($n_matches = \count($wmatches)) != 0) {
  303. Log::debug((sprintf('Found %d matches for WebFinger IDs: %s', $n_matches, print_r($wmatches, true))));
  304. }
  305. return $wmatches[1];
  306. }
  307. /**
  308. * Profile URL matches: @param string $text The text from which to extract URL mentions
  309. *
  310. * @param string $preMention Character(s) that signals a mention ('@', '!'...)
  311. *
  312. * @return array the matching URLs (without @ or acct:) and each respective position in the given string
  313. * @example.com/mublog/user
  314. */
  315. public static function extractUrlMentions(string $text, string $preMention = '@'): array
  316. {
  317. $wmatches = [];
  318. // In the regexp below we need to match / _before_ URL_REGEX_VALID_PATH_CHARS because it otherwise gets merged
  319. // with the TLD before (but / is in URL_REGEX_VALID_PATH_CHARS anyway, it's just its positioning that is important)
  320. $result = preg_match_all(
  321. '/' . Nickname::BEFORE_MENTIONS . preg_quote($preMention, '/') . '(' . URL_REGEX_DOMAIN_NAME . '(?:\/[' . URL_REGEX_VALID_PATH_CHARS . ']*)*)/',
  322. $text,
  323. $wmatches,
  324. \PREG_OFFSET_CAPTURE,
  325. );
  326. if ($result === false) {
  327. Log::error(__METHOD__ . ': Error parsing profile URL mentions from text (preg_last_error==' . preg_last_error() . ').');
  328. return [];
  329. } elseif (\count($wmatches)) {
  330. Log::debug((sprintf('Found %d matches for profile URL mentions: %s', \count($wmatches), print_r($wmatches, true))));
  331. }
  332. return $wmatches[1];
  333. }
  334. /**
  335. * Find any explicit remote mentions. Accepted forms:
  336. * Webfinger: @user@example.com
  337. * Profile link: @param Actor $sender
  338. *
  339. * @param string $text input markup text
  340. * @param $mentions
  341. *
  342. * @return bool hook return value
  343. * @example.com/mublog/user
  344. */
  345. public function onEndFindMentions(Actor $sender, string $text, array &$mentions): bool
  346. {
  347. $matches = [];
  348. foreach (self::extractWebfingerIds($text, $preMention = '@') as $wmatch) {
  349. [$target, $pos] = $wmatch;
  350. Log::info("Checking webfinger person '{$target}'");
  351. $actor = null;
  352. $resource_parts = explode($preMention, $target);
  353. if ($resource_parts[1] === Common::config('site', 'server')) {
  354. $actor = LocalUser::getByPK(['nickname' => $resource_parts[0]])->getActor();
  355. } else {
  356. Event::handle('FreeNetworkFindMentions', [$target, &$actor]);
  357. if (\is_null($actor)) {
  358. continue;
  359. }
  360. }
  361. \assert($actor instanceof Actor);
  362. $displayName = !empty($actor->getFullname()) ? $actor->getFullname() : $actor->getNickname() ?? $target; // TODO: we could do getBestName() or getFullname() here
  363. $matches[$pos] = [
  364. 'mentioned' => [$actor],
  365. 'type' => 'mention',
  366. 'text' => $displayName,
  367. 'position' => $pos,
  368. 'length' => mb_strlen($target),
  369. 'url' => $actor->getUri(),
  370. ];
  371. }
  372. foreach (self::extractUrlMentions($text) as $wmatch) {
  373. [$target, $pos] = $wmatch;
  374. $url = "https://{$target}";
  375. if (Common::isValidHttpUrl($url)) {
  376. // This means $resource is a valid url
  377. $resource_parts = parse_url($url);
  378. // TODO: Use URLMatcher
  379. if ($resource_parts['host'] === Common::config('site', 'server')) {
  380. $str = $resource_parts['path'];
  381. // actor_view_nickname
  382. $renick = '/\/@(' . Nickname::DISPLAY_FMT . ')\/?/m';
  383. // actor_view_id
  384. $reuri = '/\/actor\/(\d+)\/?/m';
  385. if (preg_match_all($renick, $str, $matches, PREG_SET_ORDER, 0) === 1) {
  386. $actor = LocalUser::getByPK(['nickname' => $matches[0][1]])->getActor();
  387. } elseif (preg_match_all($reuri, $str, $matches, PREG_SET_ORDER, 0) === 1) {
  388. $actor = Actor::getById((int) $matches[0][1]);
  389. } else {
  390. Log::error('Unexpected behaviour onEndFindMentions at FreeNetwork');
  391. throw new ServerException('Unexpected behaviour onEndFindMentions at FreeNetwork');
  392. }
  393. } else {
  394. Log::info("Checking actor address '{$url}'");
  395. $link = new XML_XRD_Element_Link(
  396. Discovery::LRDD_REL,
  397. 'https://' . parse_url($url, \PHP_URL_HOST) . '/.well-known/webfinger?resource={uri}',
  398. Discovery::JRD_MIMETYPE,
  399. true, // isTemplate
  400. );
  401. $xrd_uri = Discovery::applyTemplate($link->template, $url);
  402. $response = HTTPClient::get($xrd_uri, ['headers' => ['Accept' => $link->type]]);
  403. if ($response->getStatusCode() !== 200) {
  404. continue;
  405. }
  406. $xrd = new XML_XRD();
  407. switch (GSFile::mimetypeBare($response->getHeaders()['content-type'][0])) {
  408. case Discovery::JRD_MIMETYPE_OLD:
  409. case Discovery::JRD_MIMETYPE:
  410. $type = 'json';
  411. break;
  412. case Discovery::XRD_MIMETYPE:
  413. $type = 'xml';
  414. break;
  415. default:
  416. // fall back to letting XML_XRD auto-detect
  417. Log::debug('No recognized content-type header for resource descriptor body on ' . $xrd_uri);
  418. $type = null;
  419. }
  420. $xrd->loadString($response->getContent(), $type);
  421. $actor = null;
  422. Event::handle('FreeNetworkFoundXrd', [$xrd, &$actor]);
  423. if (\is_null($actor)) {
  424. continue;
  425. }
  426. }
  427. $displayName = $actor->getFullname() ?? $actor->getNickname() ?? $target; // TODO: we could do getBestName() or getFullname() here
  428. $matches[$pos] = [
  429. 'mentioned' => [$actor],
  430. 'type' => 'mention',
  431. 'text' => $displayName,
  432. 'position' => $pos,
  433. 'length' => mb_strlen($target),
  434. 'url' => $actor->getUri(),
  435. ];
  436. }
  437. }
  438. foreach ($mentions as $i => $other) {
  439. // If we share a common prefix with a local user, override it!
  440. $pos = $other['position'];
  441. if (isset($matches[$pos])) {
  442. $mentions[$i] = $matches[$pos];
  443. unset($matches[$pos]);
  444. }
  445. }
  446. foreach ($matches as $mention) {
  447. $mentions[] = $mention;
  448. }
  449. return Event::next;
  450. }
  451. public static function notify(Actor $sender, Activity $activity, array $targets, ?string $reason = null): bool
  452. {
  453. foreach (self::$protocols as $protocol) {
  454. $protocol::freeNetworkDistribute($sender, $activity, $targets, $reason);
  455. }
  456. return false;
  457. }
  458. public static function mentionTagToName(string $nickname, string $uri): string
  459. {
  460. return '@' . $nickname . '@' . parse_url($uri, \PHP_URL_HOST);
  461. }
  462. public static function groupTagToName(string $nickname, string $uri): string
  463. {
  464. return '!' . $nickname . '@' . parse_url($uri, \PHP_URL_HOST);
  465. }
  466. /**
  467. * Add fediverse: query expression
  468. * // TODO: adding WebFinger would probably be nice
  469. */
  470. public function onCollectionQueryCreateExpression(ExpressionBuilder $eb, string $term, ?string $locale, ?Actor $actor, &$note_expr, &$actor_expr): bool
  471. {
  472. if (Formatting::startsWith($term, ['fediverse:'])) {
  473. foreach (self::$protocols as $protocol) {
  474. // 10 is strlen of `fediverse:`
  475. if ($protocol::freeNetworkGrabRemote(mb_substr($term, 10))) {
  476. break;
  477. }
  478. }
  479. }
  480. return Event::next;
  481. }
  482. public function onPluginVersion(array &$versions): bool
  483. {
  484. $versions[] = [
  485. 'name' => 'WebFinger',
  486. 'version' => self::PLUGIN_VERSION,
  487. 'author' => 'Mikael Nordfeldth',
  488. 'homepage' => GNUSOCIAL_ENGINE_URL,
  489. // TRANS: Plugin description.
  490. 'rawdescription' => _m('WebFinger and LRDD support'),
  491. ];
  492. return true;
  493. }
  494. }