Check not only for the last contact but also for the last update for the sanity check.
This commit is contained in:
parent
cbd2fc1572
commit
880f486044
3 changed files with 8 additions and 6 deletions
|
@ -93,11 +93,12 @@ function discover_directory($search) {
|
|||
if(count($j->results))
|
||||
foreach($j->results as $jj) {
|
||||
// Check if the contact already exists
|
||||
$exists = q("SELECT `id`, `last_contact`, `last_failure` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
|
||||
$exists = q("SELECT `id`, `last_contact`, `last_failure`, `updated` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($jj->url));
|
||||
if ($exists) {
|
||||
logger("Profile ".$jj->url." already exists (".$search.")", LOGGER_DEBUG);
|
||||
|
||||
if ($exists[0]["last_contact"] < $exists[0]["last_failure"])
|
||||
if (($exists[0]["last_contact"] < $exists[0]["last_failure"]) AND
|
||||
($exists[0]["updated"] < $exists[0]["last_failure"]))
|
||||
continue;
|
||||
|
||||
// Update the contact
|
||||
|
|
|
@ -46,7 +46,8 @@ function dirfind_content(&$a) {
|
|||
$results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`keywords`
|
||||
FROM `gcontact`
|
||||
LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d
|
||||
WHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND `gcontact`.`last_contact` >= `gcontact`.`last_failure` AND
|
||||
WHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND
|
||||
((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND
|
||||
(`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR
|
||||
`gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s')
|
||||
GROUP BY `gcontact`.`nurl`
|
||||
|
|
|
@ -61,7 +61,7 @@ function poco_init(&$a) {
|
|||
$update_limit = date("Y-m-d H:i:s",strtotime($_GET['updatedSince']));
|
||||
|
||||
if ($global) {
|
||||
$r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND ((`last_contact` >= `last_failure`) OR (`updated` > `last_failure`)) AND `network` IN ('%s')",
|
||||
$r = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND `network` IN ('%s')",
|
||||
dbesc($update_limit),
|
||||
dbesc(NETWORK_DFRN)
|
||||
);
|
||||
|
@ -96,7 +96,7 @@ function poco_init(&$a) {
|
|||
|
||||
|
||||
if ($global) {
|
||||
$r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND `network` IN ('%s') AND `last_contact` >= `last_failure` LIMIT %d, %d",
|
||||
$r = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND `network` IN ('%s') AND ((`last_contact` >= `last_failure`) OR (`updated` > `last_failure`)) LIMIT %d, %d",
|
||||
dbesc($update_limit),
|
||||
dbesc(NETWORK_DFRN),
|
||||
intval($startIndex),
|
||||
|
@ -107,7 +107,7 @@ function poco_init(&$a) {
|
|||
`profile`.`address` AS `paddress`, `profile`.`region` AS `pregion`, `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`
|
||||
FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
|
||||
WHERE `self` = 1 AND `network` IN ('%s', '%s', '%s', '%s', '') AND `profile`.`is-default`
|
||||
AND `contact`.`success_update` >= `contact`.`failure_update`
|
||||
AND ((`contact`.`success_update` >= `contact`.`failure_update`) OR (`contact`.`last-item` >= `contact`.`failure_update`))
|
||||
AND `contact`.`uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d",
|
||||
dbesc(NETWORK_DFRN),
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
|
|
Loading…
Reference in a new issue