1
0
Fork 0

Merge pull request #10905 from MrPetovan/task/10865-contact-purge

Move contact deleted check from RemoveContent to Remove task
This commit is contained in:
Michael Vogel 2021-11-03 21:15:48 +01:00 committed by GitHub
commit f12c56f817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 17 deletions

View file

@ -29,19 +29,21 @@ use Friendica\Database\DBA;
*/ */
class Remove extends RemoveContent class Remove extends RemoveContent
{ {
public static function execute(int $id): array public static function execute(int $id): bool
{ {
$contact = parent::execute($id); // Only delete if the contact is to be deleted
$contact = DBA::selectFirst('contact', ['id', 'uid', 'url', 'nick', 'name'], ['deleted' => true, 'id' => $id]);
if (!DBA::isResult($contact)) {
return false;
}
if (!empty($contact)) { if (!parent::execute($id)) {
return []; return false;
} }
$ret = DBA::delete('contact', ['id' => $id]); $ret = DBA::delete('contact', ['id' => $id]);
Logger::info('Deleted contact', ['id' => $id, 'result' => $ret]); Logger::info('Deleted contact', ['id' => $id, 'result' => $ret]);
$contact['id'] = null; return true;
return $contact;
} }
} }

View file

@ -33,19 +33,13 @@ use Friendica\Model\Post;
*/ */
class RemoveContent class RemoveContent
{ {
public static function execute(int $id): array public static function execute(int $id): bool
{ {
if (empty($id)) { if (empty($id)) {
return []; return false;
} }
// Only delete if the contact is to be deleted Logger::info('Start deleting contact content', ['cid' => $id]);
$contact = DBA::selectFirst('contact', ['id', 'uid', 'url', 'nick', 'name'], ['deleted' => true, 'id' => $id]);
if (!DBA::isResult($contact)) {
return [];
}
Logger::info('Start deleting contact content', ['contact' => $contact]);
// Now we delete the contact and all depending tables // Now we delete the contact and all depending tables
DBA::delete('post-tag', ['cid' => $id]); DBA::delete('post-tag', ['cid' => $id]);
@ -87,6 +81,6 @@ class RemoveContent
DBA::delete('group_member', ['contact-id' => $id]); DBA::delete('group_member', ['contact-id' => $id]);
DI::intro()->delete(DI::introFactory()->createDummy($id)); DI::intro()->delete(DI::introFactory()->createDummy($id));
return $contact; return true;
} }
} }