1
1
Fork 0

Always update on missing uri-id, check for uri-id in contact before removal

This commit is contained in:
Michael 2021-07-09 04:38:36 +00:00
parent 377bb78cc2
commit 88f147c6a7
2 changed files with 16 additions and 3 deletions

View file

@ -2027,8 +2027,8 @@ class Contact
// These fields aren't updated by this routine:
// 'xmpp', 'sensitive'
$fields = ['uid', 'avatar', 'header', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
'manually-approve', 'unsearchable', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
$fields = ['uid', 'uri-id', 'avatar', 'header', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
'manually-approve', 'unsearchable', 'url', 'guid', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
if (!DBA::isResult($contact)) {
@ -2056,6 +2056,9 @@ class Contact
$uid = $contact['uid'];
unset($contact['uid']);
$uriid = $contact['uri-id'];
unset($contact['uri-id']);
$pubkey = $contact['pubkey'];
unset($contact['pubkey']);
@ -2128,6 +2131,10 @@ class Contact
unset($ret['last-item']);
}
if (empty($uriid)) {
$update = true;
}
if (!empty($ret['photo']) && ($ret['network'] != Protocol::FEED)) {
self::updateAvatar($id, $ret['photo'], $update);
}
@ -2150,8 +2157,13 @@ class Contact
return true;
}
if (empty($ret['guid'])) {
$ret['uri-id'] = ItemURI::getIdByURI($ret['url']);
} else {
$ret['uri-id'] = ItemURI::insert(['uri' => $ret['uri'], 'guid' => $ret['guid']]);
}
$ret['nurl'] = Strings::normaliseLink($ret['url']);
$ret['uri-id'] = ItemURI::getIdByURI($ret['url']);
$ret['updated'] = $updated;
$ret['failed'] = false;

View file

@ -184,6 +184,7 @@ class ExpirePosts
AND NOT EXISTS(SELECT `external-id` FROM `post-user` WHERE `external-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `uri-id` FROM `mail` WHERE `uri-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `uri-id` FROM `event` WHERE `uri-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `uri-id` FROM `contact` WHERE `uri-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `parent-uri-id` FROM `mail` WHERE `parent-uri-id` = `item-uri`.`id`)
AND NOT EXISTS(SELECT `thr-parent-id` FROM `mail` WHERE `thr-parent-id` = `item-uri`.`id`)", $item['uri-id']]);