]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Merge pull request #4893 from MrPetovan/bug/4879-remove-backslash-in-birthday-events
[friendica.git] / src / Protocol / DFRN.php
index f99399ee3ad883b899b98ceeaeb909c4f7f70086..eb2822894242a4f3cb369ebc22f79962b7547b32 100644 (file)
@@ -2923,6 +2923,9 @@ class DFRN
 
                logger("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);
 
+               // is it a public forum? Private forums aren't exposed with this method
+               $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()")->item(0)->nodeValue);
+
                // The account type is new since 3.5.1
                if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
                        $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()")->item(0)->nodeValue);
@@ -2930,17 +2933,17 @@ class DFRN
                        if ($accounttype != $importer["contact-type"]) {
                                dba::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
                        }
-               }
-
-               // is it a public forum? Private forums aren't supported with this method
-               // This is deprecated since 3.5.1
-               $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()")->item(0)->nodeValue);
-
-               if ($forum != $importer["forum"]) {
+                       // A forum contact can either have set "forum" or "prv" - but not both
+                       if (($accounttype == ACCOUNT_TYPE_COMMUNITY) && (($forum != $importer["forum"]) || ($forum == $importer["prv"]))) {
+                               $condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer["id"]];
+                               dba::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
+                       }
+               } elseif ($forum != $importer["forum"]) { // Deprecated since 3.5.1
                        $condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
                        dba::update('contact', ['forum' => $forum], $condition);
                }
 
+
                // We are processing relocations even if we are ignoring a contact
                $relocations = $xpath->query("/atom:feed/dfrn:relocate");
                foreach ($relocations as $relocation) {