Merge pull request #4459 from annando/unmark-contact
Bugfix and improvements for unmarking potentially archived contacts
This commit is contained in:
commit
41cd5af54f
3 changed files with 21 additions and 27 deletions
|
@ -1084,17 +1084,15 @@ class Item extends BaseObject
|
||||||
private static function updateContact($arr)
|
private static function updateContact($arr)
|
||||||
{
|
{
|
||||||
// Unarchive the author
|
// Unarchive the author
|
||||||
$contact = dba::selectFirst('contact', [], ['id' => $arr["author-link"]]);
|
$contact = dba::selectFirst('contact', [], ['id' => $arr["author-id"]]);
|
||||||
if ($contact['term-date'] > NULL_DATE) {
|
if (DBM::is_result($contact)) {
|
||||||
Contact::unmarkForArchival($contact);
|
Contact::unmarkForArchival($contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unarchive the contact if it is a toplevel posting
|
// Unarchive the contact if it's not our own contact
|
||||||
if ($arr["parent-uri"] === $arr["uri"]) {
|
$contact = dba::selectFirst('contact', [], ['id' => $arr["contact-id"], 'self' => false]);
|
||||||
$contact = dba::selectFirst('contact', [], ['id' => $arr["contact-id"]]);
|
if (DBM::is_result($contact)) {
|
||||||
if ($contact['term-date'] > NULL_DATE) {
|
Contact::unmarkForArchival($contact);
|
||||||
Contact::unmarkForArchival($contact);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"])));
|
$update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"])));
|
||||||
|
|
|
@ -1353,11 +1353,6 @@ class DFRN
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['term-date'] > NULL_DATE) {
|
|
||||||
logger("dfrn_deliver: $url back from the dead - removing mark for death");
|
|
||||||
Contact::unmarkForArchival($contact);
|
|
||||||
}
|
|
||||||
|
|
||||||
$res = XML::parseString($xml);
|
$res = XML::parseString($xml);
|
||||||
|
|
||||||
if (!isset($res->status)) {
|
if (!isset($res->status)) {
|
||||||
|
@ -1368,6 +1363,10 @@ class DFRN
|
||||||
logger('Delivery returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG);
|
logger('Delivery returned status '.$res->status.' - '.$res->message, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($res->status == 200) {
|
||||||
|
Contact::unmarkForArchival($contact);
|
||||||
|
}
|
||||||
|
|
||||||
return intval($res->status);
|
return intval($res->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1376,26 +1376,23 @@ class Diaspora
|
||||||
/**
|
/**
|
||||||
* @brief returns contact details
|
* @brief returns contact details
|
||||||
*
|
*
|
||||||
* @param array $contact The default contact if the person isn't found
|
* @param array $def_contact The default contact if the person isn't found
|
||||||
* @param array $person The record of the person
|
* @param array $person The record of the person
|
||||||
* @param int $uid The user id
|
* @param int $uid The user id
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* 'cid' => contact id
|
* 'cid' => contact id
|
||||||
* 'network' => network type
|
* 'network' => network type
|
||||||
*/
|
*/
|
||||||
private static function authorContactByUrl($contact, $person, $uid)
|
private static function authorContactByUrl($def_contact, $person, $uid)
|
||||||
{
|
{
|
||||||
$r = q(
|
$condition = ['nurl' => normalise_link($person["url"]), 'uid' => $uid];
|
||||||
"SELECT `id`, `network`, `url` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
$contact = dba::selectFirst('contact', ['id', 'network'], $condition);
|
||||||
dbesc(normalise_link($person["url"])),
|
if (DBM::is_result($contact)) {
|
||||||
intval($uid)
|
|
||||||
);
|
|
||||||
if ($r) {
|
|
||||||
$cid = $r[0]["id"];
|
|
||||||
$network = $r[0]["network"];
|
|
||||||
} else {
|
|
||||||
$cid = $contact["id"];
|
$cid = $contact["id"];
|
||||||
|
$network = $contact["network"];
|
||||||
|
} else {
|
||||||
|
$cid = $def_contact["id"];
|
||||||
$network = NETWORK_DIASPORA;
|
$network = NETWORK_DIASPORA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue