]> git.mxchange.org Git - friendica.git/commitdiff
Relay: Avoid empty tags / Always use the "relay account"
authorMichael <heluecht@pirati.ca>
Mon, 9 Apr 2018 05:53:23 +0000 (05:53 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 9 Apr 2018 05:53:23 +0000 (05:53 +0000)
mod/_well_known.php
src/Protocol/Diaspora.php

index 25289171f67f3f9f4965c7b80acda5b3dd38d66a..c5bee3fdad4b49280b6f9543353fbe5a5524df50 100644 (file)
@@ -46,8 +46,10 @@ function wk_social_relay()
                $server_tags = Config::get('system', 'relay_server_tags');
                $tagitems = explode(",", $server_tags);
 
+               /// @todo Check if it was better to use "strtolower" on the tags
                foreach ($tagitems AS $tag) {
-                       $tags[trim($tag, "# ")] = trim($tag, "# ");
+                       $tag = trim($tag, "# ");
+                       $tags[$tag] = $tag;
                }
 
                if (Config::get('system', 'relay_user_tags')) {
@@ -62,7 +64,9 @@ function wk_social_relay()
 
        $taglist = [];
        foreach ($tags AS $tag) {
-               $taglist[] = $tag;
+               if (!empty($tag)) {
+                       $taglist[] = $tag;
+               }
        }
 
        $relay = [
index 75e3820754dba65d93e721a5dea2bd2fcab8f9fe..79e7c096378a01a056b6297bfeb6bccd42efeaaa 100644 (file)
@@ -123,30 +123,30 @@ class Diaspora
        {
                $batch = $server_url . '/receive/public';
 
-               $fields = ['batch', 'id', 'name', 'network', 'nick',
-                       'url', 'archive', 'blocked', 'contact-type'];
-               // Fetch the first unarchived, unblocked account
+               $fields = ['batch', 'id', 'name', 'network', 'archive', 'blocked'];
+
+               // Fetch the relay contact
                $condition = ['uid' => 0, 'network' => NETWORK_DIASPORA, 'batch' => $batch,
-                       'archive' => false, 'blocked' => false];
+                       'contact-type' => ACCOUNT_TYPE_RELAY];
                $contact = dba::selectFirst('contact', $fields, $condition);
 
-               // If there is nothing found, we check if there is already a relay account
+               // If there is nothing found, we check if there is some unmarked relay
+               // This code segment can be removed before the release 2018-05
                if (!DBM::is_result($contact)) {
                        $condition = ['uid' => 0, 'network' => NETWORK_DIASPORA, 'batch' => $batch,
-                               'contact-type' => ACCOUNT_TYPE_RELAY];
+                               'name' => 'relay', 'nick' => 'relay', 'url' => $server_url];
                        $contact = dba::selectFirst('contact', $fields, $condition);
+
+                       if (DBM::is_result($contact)) {
+                               // Mark the relay account as a relay account
+                               $fields = ['contact-type' => ACCOUNT_TYPE_RELAY];
+                               dba::update('contact', $fields, ['id' => $contact['id']]);
+                       }
                }
                if (DBM::is_result($contact)) {
                        if ($contact['archive'] || $contact['blocked']) {
                                return false;
                        }
-
-                       // Mark relay accounts as a relay, if this hadn't been the case before
-                       if (($contact['url'] == $server_url) && ($contact['nick'] == 'relay') &&
-                               ($contact['name'] == 'relay') && ($contact['contact-type'] != ACCOUNT_TYPE_RELAY)) {
-                               $fields = ['contact-type' => ACCOUNT_TYPE_RELAY];
-                               dba::update('contact', $fields, ['id' => $contact['id']]);
-                       }
                        return $contact;
                } else {
                        $fields = ['uid' => 0, 'created' => DateTimeFormat::utcNow(),