mark for death implemented
This commit is contained in:
parent
fb9ccf5d1b
commit
e270bd3874
@ -33,7 +33,6 @@ function onepoll_run($argv, $argc){
|
||||
$d = datetime_convert();
|
||||
|
||||
|
||||
dbg(1);
|
||||
$contacts = q("SELECT abook.*, xchan.*, account.*
|
||||
FROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan
|
||||
where abook_id = %d
|
||||
@ -45,7 +44,6 @@ dbg(1);
|
||||
intval(ACCOUNT_OK),
|
||||
intval(ACCOUNT_UNVERIFIED)
|
||||
);
|
||||
dbg(0);
|
||||
|
||||
if(! $contacts) {
|
||||
logger('onepoll: abook_id not found: ' . $contact_id);
|
||||
@ -79,21 +77,21 @@ dbg(0);
|
||||
$x = zot_refresh($contact,$importer);
|
||||
|
||||
$responded = false;
|
||||
|
||||
$updated = datetime_convert();
|
||||
if(! $x) {
|
||||
// mark for death
|
||||
|
||||
// mark for death by not updating abook_connected, this is caught in include/poller.php
|
||||
q("update abook set abook_updated = '%s' where abook_id = %d limit 1",
|
||||
dbesc($updated),
|
||||
intval($contact['abook_id'])
|
||||
);
|
||||
}
|
||||
else {
|
||||
q("update abook set abook_updated = '%s', abook_connected = '%s' where abook_id = %d limit 1",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($updated),
|
||||
dbesc($updated),
|
||||
intval($contact['abook_id'])
|
||||
);
|
||||
$responded = true;
|
||||
|
||||
// if marked for death, reset
|
||||
|
||||
}
|
||||
|
||||
if(! $responded)
|
||||
|
@ -124,9 +124,50 @@ function poller_run($argv, $argc){
|
||||
$update = false;
|
||||
|
||||
$t = $contact['abook_updated'];
|
||||
$c = $contact['abook_connected'];
|
||||
|
||||
|
||||
if($c == $t) {
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
|
||||
$update = true;
|
||||
}
|
||||
else {
|
||||
// if we've never connected with them, start the mark for death countdown from now
|
||||
|
||||
if($c === '0000-00-00 00:00:00') {
|
||||
$r = q("update abook set abook_connected = '%s' where abook_id = %d limit 1",
|
||||
dbesc(datetime_convert()),
|
||||
intval($abook['abook_id'])
|
||||
);
|
||||
$c = datetime_convert();
|
||||
$update = true;
|
||||
}
|
||||
|
||||
// He's dead, Jim
|
||||
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $c . " + 30 day")) {
|
||||
$r = q("update abook set abook_flags = (abook_flags & %d) where abook_id = %d limit 1",
|
||||
intval(ABOOK_FLAG_ARCHIVED),
|
||||
intval($contact['abook_id'])
|
||||
);
|
||||
$update = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// might be dead, so maybe don't poll quite so often
|
||||
|
||||
// recently deceased, so keep up the regular schedule for 3 days
|
||||
|
||||
if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $c . " + 3 day"))
|
||||
&& (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")))
|
||||
$update = true;
|
||||
|
||||
// After that back off and put them on a morphine drip
|
||||
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 2 day")) {
|
||||
$update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if((! $update) && (! $force))
|
||||
continue;
|
||||
|
@ -18,7 +18,7 @@ function poco_init(&$a) {
|
||||
$c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = 1");
|
||||
if(! $c) {
|
||||
logger('mod_poco: system mode. No candidates.', LOGGER_DEBUG);
|
||||
http_status_exit(401);
|
||||
http_status_exit(404);
|
||||
}
|
||||
$system_mode = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user