diff --git a/include/items.php b/include/items.php
index 97eb15efc..0a52d49d8 100644
--- a/include/items.php
+++ b/include/items.php
@@ -2228,7 +2228,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
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;
}
@@ -4406,9 +4406,9 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$tags = item_getfeedtags($item);
if(count($tags)) {
- foreach($tags as $t) {
- $o .= '' . "\r\n";
- }
+ foreach($tags as $t)
+ if (($type != 'html') OR ($t[0] != "@"))
+ $o .= '' . "\r\n";
}
//$o .= ''."\r\n";
diff --git a/include/notifier.php b/include/notifier.php
index dc4e1a239..18d0aead8 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -2,6 +2,7 @@
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
@@ -295,9 +296,9 @@ function notifier_run(&$argv, &$argc){
$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) {
@@ -305,15 +306,28 @@ function notifier_run(&$argv, &$argc){
$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));
@@ -321,7 +335,9 @@ function notifier_run(&$argv, &$argc){
}
}
}
- logger("url_recipients".print_r($url_recipients,true));
+*/
+ if (count($url_recipients))
+ logger("url_recipients ".print_r($url_recipients,true));
}
} else {
$followup = false;
@@ -372,7 +388,8 @@ function notifier_run(&$argv, &$argc){
}
}
- 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);
@@ -911,7 +928,7 @@ function notifier_run(&$argv, &$argc){
// 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) {
diff --git a/include/ostatus.php b/include/ostatus.php
index a1a3f1f70..41499a2c3 100644
--- a/include/ostatus.php
+++ b/include/ostatus.php
@@ -59,7 +59,10 @@ function ostatus_fetchauthor($xpath, $context, $importer, &$contact) {
return($author);
}
-function ostatus_import($xml,$importer,&$contact) {
+function ostatus_import($xml,$importer,&$contact, &$hub) {
+
+ // To-Do:
+ // Hub
$a = get_app();
@@ -69,7 +72,7 @@ function ostatus_import($xml,$importer,&$contact) {
return;
$doc = new DOMDocument();
- $doc->loadXML($xml);
+ @$doc->loadXML($xml);
$xpath = new DomXPath($doc);
$xpath->registerNamespace('atom', "http://www.w3.org/2005/Atom");
@@ -103,6 +106,8 @@ function ostatus_import($xml,$importer,&$contact) {
$item_id = 0;
// Reverse the order of the entries
+ $entrylist = array();
+
foreach ($entries AS $entry)
$entrylist[] = $entry;
@@ -296,7 +301,7 @@ function ostatus_import($xml,$importer,&$contact) {
$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'",
diff --git a/include/salmon.php b/include/salmon.php
index 3d525f51a..757437490 100644
--- a/include/salmon.php
+++ b/include/salmon.php
@@ -7,7 +7,7 @@ require_once('include/crypto.php');
function get_salmon_key($uri,$keyhash) {
$ret = array();
- logger('Fetching salmon key');
+ logger('Fetching salmon key for '.$uri);
$arr = lrdd($uri);
@@ -44,10 +44,10 @@ function get_salmon_key($uri,$keyhash) {
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];
}
@@ -62,20 +62,20 @@ function get_salmon_key($uri,$keyhash) {
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;
}
@@ -96,7 +96,7 @@ $namespaces = <<< EOT
EOT;
$slap = str_replace('',$namespaces,$slap);
-
+
// create a magic envelope
$data = base64url_encode($slap);
@@ -125,7 +125,7 @@ EOT;
'$signature' => $signature
));
- // slap them
+ // slap them
post_url($url,$salmon, array(
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
@@ -138,7 +138,7 @@ EOT;
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
@@ -152,7 +152,7 @@ EOT;
'$signature' => $signature2
));
- // slap them
+ // slap them
post_url($url,$salmon, array(
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
@@ -162,11 +162,11 @@ EOT;
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,
@@ -176,7 +176,7 @@ EOT;
'$signature' => $signature3
));
- // slap them
+ // slap them
post_url($url,$salmon, array(
'Content-type: application/magic-envelope+xml',
'Content-length: ' . strlen($salmon)
@@ -184,7 +184,7 @@ EOT;
$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')))
diff --git a/mod/item.php b/mod/item.php
index c3d85568e..a5f483b35 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -24,6 +24,7 @@ require_once('include/files.php');
require_once('include/threads.php');
require_once('include/text.php');
require_once('include/items.php');
+require_once('include/Scrape.php');
function item_post(&$a) {