mirror of
https://github.com/friendica/friendica
synced 2025-04-29 21:04:24 +02:00
Delete removed contacts
This commit is contained in:
parent
cb5362f499
commit
a331a8cf0a
7 changed files with 59 additions and 15 deletions
|
@ -724,7 +724,7 @@ class Contact
|
|||
{
|
||||
// We want just to make sure that we don't delete our "self" contact
|
||||
$contact = DBA::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
|
||||
if (!DBA::isResult($contact) || !intval($contact['uid'])) {
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1762,6 +1762,17 @@ class Contact
|
|||
DBA::update('contact', $fields, ['id' => $cids]);
|
||||
}
|
||||
|
||||
public static function deleteContactByUrl(string $url)
|
||||
{
|
||||
// Update contact data for all users
|
||||
$condition = ['self' => false, 'nurl' => Strings::normaliseLink($url)];
|
||||
$contacts = DBA::select('contact', ['id', 'uid'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
Logger::info('Deleting contact', ['id' => $contact['id'], 'uid' => $contact['uid'], 'url' => $url]);
|
||||
self::remove($contact['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for "updateFromProbe". Updates personal and public contact
|
||||
*
|
||||
|
@ -1914,6 +1925,15 @@ class Contact
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!empty($ret['account-type']) && $ret['account-type'] == User::ACCOUNT_TYPE_DELETED) {
|
||||
Logger::info('Deleted account', ['id' => $id, 'url' => $ret['url'], 'ret' => $ret]);
|
||||
self::remove($id);
|
||||
|
||||
// Delete all contacts with the same URL
|
||||
self::deleteContactByUrl($ret['url']);
|
||||
return true;
|
||||
}
|
||||
|
||||
$uid = $contact['uid'];
|
||||
unset($contact['uid']);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue