]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/PortableContact.php
rewrote based on CR by @Annando, thank you. It is now clear to me.
[friendica.git] / src / Protocol / PortableContact.php
index d5e9d8f8c6a09e1ed3ce231cd63bbf19d8afdbbc..672956ffb952fe492b23262b9031fe55e3f8e6ee 100644 (file)
@@ -18,6 +18,7 @@ use Friendica\Model\Profile;
 use Friendica\Network\Probe;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
+use Friendica\Protocol\Diaspora;
 use dba;
 use DOMDocument;
 use DOMXPath;
@@ -1418,10 +1419,31 @@ class PortableContact
 
                dba::delete('gserver-tag', ['gserver-id' => $gserver['id']]);
                if ($data->scope == 'tags') {
+                       // Avoid duplicates
+                       $tags = [];
                        foreach ($data->tags as $tag) {
+                               $tag = mb_strtolower($tag);
+                               $tags[$tag] = $tag;
+                       }
+
+                       foreach ($tags as $tag) {
                                dba::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag]);
                        }
                }
+
+               // Create or update the relay contact
+               $fields = [];
+               if (isset($data->protocols)) {
+                       if (isset($data->protocols->diaspora)) {
+                               $fields['network'] = NETWORK_DIASPORA;
+                               $fields['batch'] = $data->protocols->diaspora;
+                       }
+                       if (isset($data->protocols->dfrn)) {
+                               $fields['network'] = NETWORK_DFRN;
+                               $fields['batch'] = $data->protocols->dfrn;
+                       }
+               }
+               Diaspora::setRelayContact($server_url, $fields);
        }
 
        /**