+ return ['webfinger' => $webfinger, 'detected' => $detected];
+ }
+
+ /**
+ * Fetch information (protocol endpoints and user information) about a given uri
+ *
+ * This function is only called by the "uri" function that adds caching and rearranging of data.
+ *
+ * @param string $uri Address that should be probed
+ * @param string $network Test for this specific network
+ * @param integer $uid User ID for the probe (only used for mails)
+ * @param array $ap_profile Previously probed AP profile
+ *
+ * @return array uri data
+ * @throws HTTPException\InternalServerErrorException
+ */
+ private static function detect(string $uri, string $network, int $uid, array $ap_profile)
+ {
+ $hookData = [
+ 'uri' => $uri,
+ 'network' => $network,
+ 'uid' => $uid,
+ 'result' => [],
+ ];
+
+ Hook::callAll('probe_detect', $hookData);
+
+ if ($hookData['result']) {
+ if (!is_array($hookData['result'])) {
+ return [];
+ } else {
+ return $hookData['result'];
+ }
+ }
+
+ $parts = parse_url($uri);
+
+ if (!empty($parts['scheme']) && !empty($parts['host'])) {
+ if (in_array($parts['host'], ['twitter.com', 'mobile.twitter.com'])) {
+ return self::twitter($uri);
+ }
+ } elseif (strstr($uri, '@')) {
+ // If the URI starts with "mailto:" then jump directly to the mail detection
+ if (strpos($uri, 'mailto:') !== false) {
+ $uri = str_replace('mailto:', '', $uri);
+ return self::mail($uri, $uid);