- // Check if the address is resolvable or the profile url is identical with the base url of the system
- if (self::addrToUrl($apcontact['addr'], $apcontact['url']) || Strings::compareLink($apcontact['url'], $baseurl)) {
- $apcontact['baseurl'] = $baseurl;
- } else {
- $apcontact['addr'] = null;
+ if (strlen($apcontact['photo']) > 255) {
+ unset($parts['query']);
+ $apcontact['photo'] = Network::unparseURL($parts);
+ }
+
+ if (strlen($apcontact['photo']) > 255) {
+ $apcontact['photo'] = substr($apcontact['photo'], 0, 255);
+ }
+ }
+
+ if (!$webfinger && !empty($apcontact['addr'])) {
+ $data = self::fetchWebfingerData($apcontact['addr']);
+ if (!empty($data)) {
+ $apcontact['baseurl'] = $data['baseurl'];
+
+ if (empty($apcontact['alias']) && !empty($data['alias'])) {
+ $apcontact['alias'] = $data['alias'];
+ }
+ if (!empty($data['subscribe'])) {
+ $apcontact['subscribe'] = $data['subscribe'];
+ }
+ } else {
+ $apcontact['addr'] = null;
+ }