Merge pull request #4011 from annando/archive-cleanup
Some cleanup for archiving/unarchiving contacts
This commit is contained in:
commit
a4451c7c3d
3 changed files with 19 additions and 15 deletions
|
@ -1339,10 +1339,6 @@ class Diaspora
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$cid = $r[0]["id"];
|
$cid = $r[0]["id"];
|
||||||
$network = $r[0]["network"];
|
$network = $r[0]["network"];
|
||||||
|
|
||||||
// We are receiving content from a user that possibly is about to be terminated
|
|
||||||
// This means the user is vital, so we remove a possible termination date.
|
|
||||||
Contact::unmarkForArchival($r[0]);
|
|
||||||
} else {
|
} else {
|
||||||
$cid = $contact["id"];
|
$cid = $contact["id"];
|
||||||
$network = NETWORK_DIASPORA;
|
$network = NETWORK_DIASPORA;
|
||||||
|
|
|
@ -151,11 +151,8 @@ class OStatus
|
||||||
|
|
||||||
// Only update the contacts if it is an OStatus contact
|
// Only update the contacts if it is an OStatus contact
|
||||||
if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
|
if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
|
||||||
// This contact is vital, so we awake it from the dead
|
|
||||||
Contact::unmarkForArchival($contact);
|
|
||||||
|
|
||||||
// Update contact data
|
// Update contact data
|
||||||
|
|
||||||
$current = $contact;
|
$current = $contact;
|
||||||
unset($current['name-date']);
|
unset($current['name-date']);
|
||||||
|
|
||||||
|
|
|
@ -77,10 +77,10 @@ Class OnePoll
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
|
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
|
||||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
self::updateContact($contact, $fields);
|
||||||
Contact::unmarkForArchival($contact);
|
Contact::unmarkForArchival($contact);
|
||||||
} else {
|
} else {
|
||||||
dba::update('contact', array('last-update' => $updated, 'failure_update' => $updated), array('id' => $contact['id']));
|
self::updateContact($contact, array('last-update' => $updated, 'failure_update' => $updated));
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ Class OnePoll
|
||||||
|
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
self::updateContact($contact, $fields);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ Class OnePoll
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
|
|
||||||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
self::updateContact($contact, $fields);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ Class OnePoll
|
||||||
// we may not be friends anymore. Will keep trying for one month.
|
// we may not be friends anymore. Will keep trying for one month.
|
||||||
// set the last-update so we don't keep polling
|
// set the last-update so we don't keep polling
|
||||||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
self::updateContact($contact, $fields);
|
||||||
|
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
} elseif ($contact['term-date'] > NULL_DATE) {
|
} elseif ($contact['term-date'] > NULL_DATE) {
|
||||||
|
@ -577,7 +577,7 @@ Class OnePoll
|
||||||
logger('post_handshake: response from ' . $url . ' did not contain XML.');
|
logger('post_handshake: response from ' . $url . ' did not contain XML.');
|
||||||
|
|
||||||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
self::updateContact($contact, $fields);
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -622,13 +622,13 @@ Class OnePoll
|
||||||
|
|
||||||
$updated = datetime_convert();
|
$updated = datetime_convert();
|
||||||
|
|
||||||
dba::update('contact', array('last-update' => $updated, 'success_update' => $updated), array('id' => $contact['id']));
|
self::updateContact($contact, array('last-update' => $updated, 'success_update' => $updated));
|
||||||
dba::update('gcontact', array('last_contact' => $updated), array('nurl' => $contact['nurl']));
|
dba::update('gcontact', array('last_contact' => $updated), array('nurl' => $contact['nurl']));
|
||||||
Contact::unmarkForArchival($contact);
|
Contact::unmarkForArchival($contact);
|
||||||
} elseif (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED))) {
|
} elseif (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED))) {
|
||||||
$updated = datetime_convert();
|
$updated = datetime_convert();
|
||||||
|
|
||||||
dba::update('contact', array('last-update' => $updated, 'failure_update' => $updated), array('id' => $contact['id']));
|
self::updateContact($contact, array('last-update' => $updated, 'failure_update' => $updated));
|
||||||
dba::update('gcontact', array('last_failure' => $updated), array('nurl' => $contact['nurl']));
|
dba::update('gcontact', array('last_failure' => $updated), array('nurl' => $contact['nurl']));
|
||||||
Contact::markForArchival($contact);
|
Contact::markForArchival($contact);
|
||||||
} else {
|
} else {
|
||||||
|
@ -645,4 +645,15 @@ Class OnePoll
|
||||||
|
|
||||||
return $subject;
|
return $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Updates a personal contact entry and the public contact entry
|
||||||
|
*
|
||||||
|
* @param array $contact The personal contact entry
|
||||||
|
* @param array $fields The fields that are updated
|
||||||
|
*/
|
||||||
|
private static function updateContact($contact, $fields) {
|
||||||
|
dba::update('contact', $fields, array('id' => $contact['id']));
|
||||||
|
dba::update('contact', $fields, array('uid' => 0, 'nurl' => $contact['nurl']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue