]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Add probe_detect hook
[friendica.git] / src / Model / Contact.php
index f611cc452f0861d1bcd96fc51fe3800f797025b8..e881398df8b9ce893de96f520646934b6117a73c 100644 (file)
@@ -1530,10 +1530,6 @@ class Contact
 
                if (empty($data)) {
                        $data = Probe::uri($url, "", $uid);
-                       // Ensure that there is a gserver entry
-                       if (!empty($data['baseurl']) && ($data['network'] != Protocol::PHANTOM)) {
-                               $data['gsid'] = GServer::getID($data['baseurl']);
-                       }
                }
 
                // Take the default values when probing failed
@@ -1546,6 +1542,14 @@ class Contact
                        return 0;
                }
 
+               if (!empty($data['baseurl'])) {
+                       $data['baseurl'] = GServer::cleanURL($data['baseurl']);
+               }
+
+               if (!empty($data['baseurl']) && empty($data['gsid'])) {
+                       $data['gsid'] = GServer::getID($data['baseurl']);
+               }
+
                if (!$contact_id && !empty($data['alias']) && ($data['alias'] != $url) && !$in_loop) {
                        $contact_id = self::getIdForURL($data["alias"], $uid, true, $default, true);
                }
@@ -1628,7 +1632,7 @@ class Contact
                                }
                        }
                } else {
-                       $fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'baseurl'];
+                       $fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'baseurl', 'gsid'];
                        $contact = DBA::selectFirst('contact', $fields, ['id' => $contact_id]);
 
                        // This condition should always be true
@@ -1642,7 +1646,7 @@ class Contact
                                'updated' => DateTimeFormat::utcNow()
                        ];
 
-                       $fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl'];
+                       $fields = ['addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'baseurl', 'gsid'];
 
                        foreach ($fields as $field) {
                                $updated[$field] = ($data[$field] ?? '') ?: $contact[$field];
@@ -2081,7 +2085,7 @@ class Contact
                // These fields aren't updated by this routine:
                // 'xmpp', 'sensitive'
 
-               $fields = ['uid', 'avatar', 'name', 'nick', 'location', 'keywords', 'about',
+               $fields = ['uid', 'avatar', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
                        'unsearchable', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
                        'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey'];
                $contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
@@ -2136,10 +2140,6 @@ class Contact
                        }
                }
 
-               if (!empty($ret['baseurl']) && empty($contact['gsid'])) {
-                       $ret['gsid'] = GServer::getID($ret['baseurl']);
-               }
-
                $new_pubkey = $ret['pubkey'];
 
                $update = false;
@@ -2308,10 +2308,6 @@ class Contact
                        $ret = Probe::uri($url, $network, $uid, false);
                }
 
-               if (!empty($ret['baseurl'])) {
-                       $ret['gsid'] = GServer::getID($ret['baseurl']);
-               }
-
                if (($network != '') && ($ret['network'] != $network)) {
                        Logger::log('Expected network ' . $network . ' does not match actual network ' . $ret['network']);
                        return $result;