]> git.mxchange.org Git - friendica.git/commitdiff
Don't archive "self" contacts
authorMichael <heluecht@pirati.ca>
Tue, 5 Dec 2017 21:29:33 +0000 (21:29 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 Dec 2017 21:29:33 +0000 (21:29 +0000)
include/items.php
src/Object/Contact.php

index f334990d7766095fc6b9ffcd98249b2558b6fdcf..63c3218199a4c7e7b5aacd9e3c759c1825c63a6a 100644 (file)
@@ -1157,6 +1157,14 @@ function item_set_last_item($arr) {
                 Contact::unmarkForArchival($contact);
        }
 
+       // Unarchive the contact if it is a toplevel posting
+       if ($arr["parent-uri"] === $arr["uri"]) {
+               $contact = dba::select('contact', [], ['id' => $arr["contact-id"]], ['limit' => 1]);
+               if ($contact['term-date'] > NULL_DATE) {
+                        Contact::unmarkForArchival($contact);
+               }
+       }
+
        $update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"])));
 
        // Is it a forum? Then we don't care about the rules from above
index bd7cee7fbea640281cdac4caacbac141568b00c9..64e61b9ce2a06253f4ec78b5b3f9d6181378cb22 100644 (file)
@@ -141,8 +141,8 @@ class Contact extends BaseObject
         */
        public static function markForArchival(array $contact)
        {
-               // Contact already archived, nothing to do
-               if ($contact['archive']) {
+               // Contact already archived or "self" contact? => nothing to do
+               if ($contact['archive'] || $contact['self']) {
                        return;
                }
 
@@ -150,7 +150,7 @@ class Contact extends BaseObject
                        dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id']));
 
                        if ($contact['url'] != '') {
-                               dba::update('contact', array('term-date' => datetime_convert()), array('`nurl` = ? AND `term-date` <= ?', normalise_link($contact['url']), NULL_DATE));
+                               dba::update('contact', array('term-date' => datetime_convert()), array('`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE));
                        }
                } else {
                        /* @todo
@@ -169,7 +169,7 @@ class Contact extends BaseObject
                                dba::update('contact', array('archive' => 1), array('id' => $contact['id']));
 
                                if ($contact['url'] != '') {
-                                       dba::update('contact', array('archive' => 1), array('nurl' => normalise_link($contact['url'])));
+                                       dba::update('contact', array('archive' => 1), array('nurl' => normalise_link($contact['url']), 'self' => false));
                                }
                        }
                }