mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
set frequency of poll per contact, other misc fixes (photo now has contact-id)
This commit is contained in:
parent
a4a46d82df
commit
3fd4b4264e
7 changed files with 113 additions and 34 deletions
|
@ -17,7 +17,7 @@ require_once('include/items.php');
|
|||
|
||||
if($argc < 2)
|
||||
exit;
|
||||
|
||||
dbg(3);
|
||||
$a->set_baseurl($argv[1]);
|
||||
|
||||
$contacts = q("SELECT * FROM `contact` WHERE `dfrn-id` != '' AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()");
|
||||
|
@ -27,6 +27,39 @@ if($argc < 2)
|
|||
|
||||
foreach($contacts as $contact) {
|
||||
|
||||
if($contact['priority']) {
|
||||
|
||||
$update = false;
|
||||
$t = $contact['last-update'];
|
||||
|
||||
switch ($contact['priority']) {
|
||||
case 5:
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 month"))
|
||||
$update = true;
|
||||
break;
|
||||
case 4:
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 week"))
|
||||
$update = true;
|
||||
break;
|
||||
case 3:
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 day"))
|
||||
$update = true;
|
||||
break;
|
||||
case 2:
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 12 hour"))
|
||||
$update = true;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', t . " + 1 hour"))
|
||||
$update = true;
|
||||
break;
|
||||
}
|
||||
if(! $update)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$importer_uid = $contact['uid'];
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
|
||||
|
@ -44,7 +77,8 @@ if($argc < 2)
|
|||
$url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update ;
|
||||
|
||||
$xml = fetch_url($url);
|
||||
|
||||
echo "URL: " . $url;
|
||||
echo "XML: " . $xml;
|
||||
if(! $xml)
|
||||
continue;
|
||||
|
||||
|
@ -61,12 +95,19 @@ if($argc < 2)
|
|||
openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']);
|
||||
|
||||
$xml = post_url($contact['poll'],$postvars);
|
||||
if(! strlen($xml))
|
||||
continue;
|
||||
|
||||
echo "XML response:" . $xml . "\r\n";
|
||||
echo "Length:" . strlen($xml) . "\r\n";
|
||||
|
||||
if(! strlen($xml)) {
|
||||
// an empty response may mean there's nothing new - record the fact that we checked
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact['id'])
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
$feed = new SimplePie();
|
||||
$feed->set_raw_data($xml);
|
||||
$feed->enable_order_by_date(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue