Check all contacts that we haven't contacted in a month
This commit is contained in:
parent
e095553590
commit
4b2c2c4802
2 changed files with 7 additions and 6 deletions
|
@ -83,9 +83,10 @@ function discover_poco_run(&$argv, &$argc){
|
||||||
|
|
||||||
function discover_users() {
|
function discover_users() {
|
||||||
logger("Discover users", LOGGER_DEBUG);
|
logger("Discover users", LOGGER_DEBUG);
|
||||||
// To-Do: Maybe we should check old contact as well.
|
|
||||||
$users = q("SELECT `url`, `created`, `updated`, `last_failure`, `last_contact`, `server_url` FROM `gcontact`
|
$users = q("SELECT `url`, `created`, `updated`, `last_failure`, `last_contact`, `server_url` FROM `gcontact`
|
||||||
WHERE `last_contact` = '0000-00-00 00:00:00' AND `last_failure` = '0000-00-00 00:00:00' AND
|
WHERE `last_contact` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
|
||||||
|
`last_failure` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
|
||||||
`network` IN ('%s', '%s', '%s') ORDER BY rand()",
|
`network` IN ('%s', '%s', '%s') ORDER BY rand()",
|
||||||
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
|
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ function discover_users() {
|
||||||
|
|
||||||
if (poco_check_server($server_url, $gcontacts[0]["network"])) {
|
if (poco_check_server($server_url, $gcontacts[0]["network"])) {
|
||||||
logger('Check user '.$user["url"]);
|
logger('Check user '.$user["url"]);
|
||||||
poco_last_updated($user["url"]);
|
poco_last_updated($user["url"], true);
|
||||||
|
|
||||||
if (++$checked > 100)
|
if (++$checked > 100)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -425,7 +425,7 @@ function poco_detect_server($profile) {
|
||||||
return $server_url;
|
return $server_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function poco_last_updated($profile) {
|
function poco_last_updated($profile, $force = false) {
|
||||||
|
|
||||||
$gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
$gcontacts = q("SELECT * FROM `gcontact` WHERE `nurl` = '%s'",
|
||||||
dbesc(normalise_link($profile)));
|
dbesc(normalise_link($profile)));
|
||||||
|
@ -451,7 +451,7 @@ function poco_last_updated($profile) {
|
||||||
|
|
||||||
if ($server) {
|
if ($server) {
|
||||||
$noscraperet = z_fetch_url($server[0]["noscrape"]."/".$gcontacts[0]["nick"]);
|
$noscraperet = z_fetch_url($server[0]["noscrape"]."/".$gcontacts[0]["nick"]);
|
||||||
if ($noscraperet["success"]) {
|
if ($noscraperet["success"] AND ($noscraperet["body"] = "")) {
|
||||||
$noscrape = json_decode($noscraperet["body"], true);
|
$noscrape = json_decode($noscraperet["body"], true);
|
||||||
|
|
||||||
if (($noscrape["name"] != "") AND ($noscrape["name"] != $gcontacts[0]["name"]))
|
if (($noscrape["name"] != "") AND ($noscrape["name"] != $gcontacts[0]["name"]))
|
||||||
|
@ -514,7 +514,7 @@ function poco_last_updated($profile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we only can poll the feed, then we only do this once a while
|
// If we only can poll the feed, then we only do this once a while
|
||||||
if (!poco_do_update($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"]))
|
if (!$force AND !poco_do_update($gcontacts[0]["created"], $gcontacts[0]["updated"], $gcontacts[0]["last_failure"], $gcontacts[0]["last_contact"]))
|
||||||
return $gcontacts[0]["updated"];
|
return $gcontacts[0]["updated"];
|
||||||
|
|
||||||
$data = probe_url($profile);
|
$data = probe_url($profile);
|
||||||
|
|
Loading…
Reference in a new issue