if ($contact['network'] === NETWORK_OSTATUS) {
if ($pass < 2) {
logger("Consume OStatus messages ", LOGGER_DEBUG);
- ostatus_import($xml,$importer,$contact);
+ ostatus_import($xml,$importer,$contact, $hub);
}
return;
}
$tags = item_getfeedtags($item);
if(count($tags)) {
- foreach($tags as $t) {
- $o .= '<category scheme="X-DFRN:' . xmlify($t[0]) . ':' . xmlify($t[1]) . '" term="' . xmlify($t[2]) . '" />' . "\r\n";
- }
+ foreach($tags as $t)
+ if (($type != 'html') OR ($t[0] != "@"))
+ $o .= '<category scheme="X-DFRN:' . xmlify($t[0]) . ':' . xmlify($t[1]) . '" term="' . xmlify($t[2]) . '" />' . "\r\n";
}
//$o .= '<link rel="ostatus:conversation" href="'.xmlify($a->get_baseurl().'/display/'.$owner['nickname'].'/'.$item['parent']).'"/>'."\r\n";
require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
+require_once("include/Scrape.php");
/*
* This file was at one time responsible for doing all deliveries, but this caused
$conversant_str = dbesc($parent['contact-id']);
$recipients = array($parent['contact-id']);
- if (!$item['private'] AND $item['wall'] AND
- (strlen($item['allow_cid'].$item['allow_gid'].
- $item['deny_cid'].$item['deny_gid']) == 0))
+ if (!$target_item['private'] AND $target_item['wall'] AND
+ (strlen($target_item['allow_cid'].$target_item['allow_gid'].
+ $target_item['deny_cid'].$target_item['deny_gid']) == 0))
$push_notify = true;
if ($parent['network'] == NETWORK_OSTATUS) {
$push_notify = true;
+ // Send a salmon notification to every person we mentioned in the post
+ $arr = explode(',',$target_item['tag']);
+ foreach($arr as $x) {
+ logger('Checking tag '.$x, LOGGER_DEBUG);
+ $matches = null;
+ if(preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) {
+ $probed_contact = probe_url($matches[1]);
+ if ($probed_contact["notify"] != "") {
+ logger('scrape data for slapper: '.print_r($probed_contact, true));
+ $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
+ }
+ }
+ }
+
+/*
// Check if the recipient isn't in your contact list, try to slap it
// Not sure if it is working or not.
$r = q("SELECT `url` FROM `contact` WHERE `id` = %d", $parent['contact-id']);
if (count($r)) {
- $url_recipients = array();
$thrparent = q("SELECT `author-link` FROM `item` WHERE `uri` = '%s'", dbesc($target_item["thr-parent"]));
if (count($thrparent) AND (normalise_link($r[0]["url"]) != normalise_link($thrparent[0]["author-link"]))) {
- require_once("include/Scrape.php");
$probed_contact = probe_url($thrparent[0]["author-link"]);
if ($probed_contact["notify"] != "") {
logger('scrape data for slapper: '.print_r($probed_contact, true));
}
}
}
- logger("url_recipients".print_r($url_recipients,true));
+*/
+ if (count($url_recipients))
+ logger("url_recipients ".print_r($url_recipients,true));
}
} else {
$followup = false;
}
}
- logger('notifier: url_recipients' . print_r($url_recipients,true));
+ if (count($url_recipients))
+ logger('notifier: url_recipients ' . print_r($url_recipients,true));
$conversants = array_unique($conversants);
// send additional slaps to mentioned remote tags (@foo@example.com)
- if($slap && count($url_recipients) && ($followup || $top_level) && $public_message && (! $expire)) {
+ if($slap && count($url_recipients) && ($followup || $top_level) && ($public_message || $push_notify) && (! $expire)) {
if(! get_config('system','dfrn_only')) {
foreach($url_recipients as $url) {
if($url) {
return($author);
}
-function ostatus_import($xml,$importer,&$contact) {
+function ostatus_import($xml,$importer,&$contact, &$hub) {
+
+ // To-Do:
+ // Hub
$a = get_app();
return;
$doc = new DOMDocument();
- $doc->loadXML($xml);
+ @$doc->loadXML($xml);
$xpath = new DomXPath($doc);
$xpath->registerNamespace('atom', "http://www.w3.org/2005/Atom");
$item_id = 0;
// Reverse the order of the entries
+ $entrylist = array();
+
foreach ($entries AS $entry)
$entrylist[] = $entry;
$reply_xml = fetch_url($reply_path);
$reply_contact = $contact;
- ostatus_import($reply_xml,$importer,$reply_contact);
+ ostatus_import($reply_xml,$importer,$reply_contact, $reply_hub);
// After the import try to fetch the parent item again
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
function get_salmon_key($uri,$keyhash) {
$ret = array();
- logger('Fetching salmon key');
+ logger('Fetching salmon key for '.$uri);
$arr = lrdd($uri);
if(count($ret) == 1) {
// We only found one one key so we don't care if the hash matches.
- // If it's the wrong key we'll find out soon enough because
- // message verification will fail. This also covers some older
+ // If it's the wrong key we'll find out soon enough because
+ // message verification will fail. This also covers some older
// software which don't supply a keyhash. As long as they only
- // have one key we'll be right.
+ // have one key we'll be right.
return $ret[0];
}
return '';
}
-
-
+
+
function slapper($owner,$url,$slap) {
- logger('slapper called. Data: ' . $slap);
+ logger('slapper called for '.$url.'. Data: ' . $slap);
- // does contact have a salmon endpoint?
+ // does contact have a salmon endpoint?
if(! strlen($url))
return;
if(! $owner['sprvkey']) {
- logger(sprintf("slapper: user '%s' (%d) does not have a salmon private key. Send failed.",
+ logger(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.",
$owner['username'],$owner['uid']));
return;
}
EOT;
$slap = str_replace('<entry>',$namespaces,$slap);
-
+
// create a magic envelope
$data = base64url_encode($slap);
'$signature' => $signature
));
- // slap them
+ // slap them
post_url($url,$salmon, array(
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
if($return_code > 299) {
- logger('slapper: compliant salmon failed. Falling back to status.net hack2');
+ logger('compliant salmon failed. Falling back to status.net hack2');
// Entirely likely that their salmon implementation is
// non-compliant. Let's try once more, this time only signing
'$signature' => $signature2
));
- // slap them
+ // slap them
post_url($url,$salmon, array(
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
if($return_code > 299) {
- logger('slapper: compliant salmon failed. Falling back to status.net hack3');
+ logger('compliant salmon failed. Falling back to status.net hack3');
// Entirely likely that their salmon implementation is
// non-compliant. Let's try once more, this time only signing
- // the data, without the precomputed blob
+ // the data, without the precomputed blob
$salmon = replace_macros($salmon_tpl,array(
'$data' => $data,
'$signature' => $signature3
));
- // slap them
+ // slap them
post_url($url,$salmon, array(
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
$return_code = $a->get_curl_code();
}
}
- logger('slapper returned ' . $return_code);
+ logger('slapper for '.$url.' returned ' . $return_code);
if(! $return_code)
return(-1);
if(($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))
require_once('include/threads.php');
require_once('include/text.php');
require_once('include/items.php');
+require_once('include/Scrape.php');
function item_post(&$a) {