scrape_url - use feed url if no name can be found

This commit is contained in:
Friendika 2011-09-04 05:07:25 -07:00
parent 1d01b3a088
commit 260d652168
3 changed files with 30 additions and 6 deletions

View File

@ -332,10 +332,12 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if(! $url) if(! $url)
return $result; return $result;
$network = null;
$diaspora = false; $diaspora = false;
$diaspora_base = ''; $diaspora_base = '';
$diaspora_guid = ''; $diaspora_guid = '';
$diaspora_key = ''; $diaspora_key = '';
$has_lrdd = false;
$email_conversant = false; $email_conversant = false;
$twitter = ((strpos($url,'twitter.com') !== false) ? true : false); $twitter = ((strpos($url,'twitter.com') !== false) ? true : false);
@ -352,6 +354,8 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$links = lrdd($url); $links = lrdd($url);
if(count($links)) { if(count($links)) {
$has_lrdd = true;
logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA); logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA);
foreach($links as $link) { foreach($links as $link) {
if($link['@attributes']['rel'] === NAMESPACE_ZOT) if($link['@attributes']['rel'] === NAMESPACE_ZOT)
@ -493,7 +497,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) { if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
if($diaspora) if($diaspora)
$network = NETWORK_DIASPORA; $network = NETWORK_DIASPORA;
else elseif($has_lrdd)
$network = NETWORK_OSTATUS; $network = NETWORK_OSTATUS;
$priority = 0; $priority = 0;
@ -637,7 +641,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' '))); $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));
} }
if(! $network) if(! $network)
$network = 'feed'; $network = NETWORK_FEED;
if(! $priority) if(! $priority)
$priority = 2; $priority = 2;
} }
@ -651,10 +655,14 @@ function probe_url($url, $mode = PROBE_NORMAL) {
if(! $profile) if(! $profile)
$profile = $url; $profile = $url;
// No human could be associated with this link, use the URL as the contact name
if(($network === NETWORK_FEED) && ($poll) && (! x($vcard,'fn')))
$vcard['fn'] = $url;
$vcard['fn'] = notags($vcard['fn']); $vcard['fn'] = notags($vcard['fn']);
$vcard['nick'] = str_replace(' ','',notags($vcard['nick'])); $vcard['nick'] = str_replace(' ','',notags($vcard['nick']));
$result['name'] = $vcard['fn']; $result['name'] = $vcard['fn'];
$result['nick'] = $vcard['nick']; $result['nick'] = $vcard['nick'];
$result['url'] = $profile; $result['url'] = $profile;

View File

@ -419,7 +419,8 @@ function delivery_run($argv, $argc){
diaspora_send_relay($target_item,$owner,$contact); diaspora_send_relay($target_item,$owner,$contact);
break; break;
} }
elseif($top_level) { elseif(($top_level) && (! $walltowall)) {
// currently no workable solution for sending walltowall
logger('delivery: diaspora status: ' . $contact['name']); logger('delivery: diaspora status: ' . $contact['name']);
diaspora_send_status($target_item,$owner,$contact); diaspora_send_status($target_item,$owner,$contact);
break; break;

View File

@ -2,6 +2,20 @@
require_once("boot.php"); require_once("boot.php");
/*
* This file was at one time responsible for doing all deliveries, but this caused
* big problems on shared hosting systems, where the process might get killed by the
* hosting provider and nothing would get delivered.
* It now only delivers one message under certain cases, and invokes a queued
* delivery mechanism (include/deliver.php) to deliver individual contacts at
* controlled intervals.
* This has a much better chance of surviving random processes getting killed
* by the hosting provider.
* A lot of this code is duplicated in include/deliver.php until we have time to go back
* and re-structure the delivery procedure based on the obstacles that have been thrown at
* us by hosting providers.
*/
function notifier_run($argv, $argc){ function notifier_run($argv, $argc){
global $a, $db; global $a, $db;
@ -594,7 +608,8 @@ function notifier_run($argv, $argc){
diaspora_send_relay($target_item,$owner,$contact); diaspora_send_relay($target_item,$owner,$contact);
break; break;
} }
elseif($top_level) { elseif(($top_level) && (! $walltowall)) {
// currently no workable solution for sending walltowall
diaspora_send_status($target_item,$owner,$contact); diaspora_send_status($target_item,$owner,$contact);
break; break;
} }