- /**
- * Checks if a profile url should be OStatus but only provides partial information
- *
- * @param array $webfinger Webfinger data
- * @param string $lrdd Path template for webfinger request
- * @param string $type type
- *
- * @return array fixed webfinger data
- * @throws HTTPException\InternalServerErrorException
- */
- private static function fixOStatus($webfinger, $lrdd, $type)
- {
- if (empty($webfinger['links']) || empty($webfinger['subject'])) {
- return $webfinger;
- }
-
- $is_ostatus = false;
- $has_key = false;
-
- foreach ($webfinger['links'] as $link) {
- if ($link['rel'] == ActivityNamespace::OSTATUSSUB) {
- $is_ostatus = true;
- }
- if ($link['rel'] == 'magic-public-key') {
- $has_key = true;
- }
- }
-
- if (!$is_ostatus || $has_key) {
- return $webfinger;
- }
-
- $url = Network::switchScheme($webfinger['subject']);
- $path = str_replace('{uri}', urlencode($url), $lrdd);
- $webfinger2 = self::webfinger($path, $type);
-
- // Is the new webfinger detectable as OStatus?
- if (self::ostatus($webfinger2, true)) {
- $webfinger = $webfinger2;
- }
-
- return $webfinger;
- }
-