]> git.mxchange.org Git - friendica.git/commitdiff
Remove contacts in the background
authorMichael <heluecht@pirati.ca>
Sun, 12 Aug 2018 17:15:47 +0000 (17:15 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 12 Aug 2018 17:15:47 +0000 (17:15 +0000)
src/Model/Contact.php
src/Worker/RemoveContact.php

index 39a0ba718a8cd0b2d78c78a38e5dbbae9515f0e1..b18159d40cf0cf823bba43b082e6d897af214b9c 100644 (file)
@@ -314,15 +314,10 @@ class Contact extends BaseObject
                        return;
                }
 
-               $archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts');
-               if ($archive) {
-                       DBA::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
-                       return;
-               }
-
-               DBA::delete('contact', ['id' => $id]);
+               // Archive the contact
+               DBA::update('contact', ['archive' => true, 'network' => Protocol::PHANTOM], ['id' => $id]);
 
-               // Delete the rest in the background
+               // Delete it in the background
                Worker::add(PRIORITY_LOW, 'RemoveContact', $id);
        }
 
index 40ac937f100ed4656a3ff251eecceea7aeb4bfbe..01388516bc5e199f041188c1869a23e87866cc7a 100644 (file)
@@ -12,13 +12,14 @@ require_once 'include/dba.php';
 class RemoveContact {
        public static function execute($id) {
 
-               // Only delete if the contact doesn't exist (anymore)
-               $r = DBA::exists('contact', ['id' => $id]);
-               if ($r) {
+               // Only delete if the contact is archived
+               $condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id];
+               $r = DBA::exists('contact', $condition);
+               if (!DBA::isResult($r)) {
                        return;
                }
 
-               // Now we delete all the depending table entries
+               // Now we delete the contact and all depending tables
                DBA::delete('contact', ['id' => $id]);
        }
 }