aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/delivery.php36
-rw-r--r--include/items.php14
-rw-r--r--include/notifier.php40
3 files changed, 83 insertions, 7 deletions
diff --git a/include/delivery.php b/include/delivery.php
index 1ba1d9c3a..8318be4dd 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -280,6 +280,42 @@ function delivery_run($argv, $argc){
$atom .= '</feed>' . "\r\n";
logger('notifier: ' . $atom, LOGGER_DATA);
+ $basepath = implode('/', array_slice(explode('/',$contact['url']),0,3));
+
+ // perform local delivery if we are on the same site
+
+ if(link_compare($basepath,$a->get_baseurl())) {
+
+ $nickname = basename($contact['url']);
+ if($contact['issued-id'])
+ $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
+ else
+ $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
+
+ $x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
+ `contact`.`pubkey` AS `cpubkey`,
+ `contact`.`prvkey` AS `cprvkey`,
+ `contact`.`thumb` AS `thumb`,
+ `contact`.`url` as `url`,
+ `contact`.`name` as `senderName`,
+ `user`.*
+ FROM `contact`
+ LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
+ WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
+ $sql_extra
+ AND `user`.`account_expired` = 0 LIMIT 1",
+ dbesc(NETWORK_DFRN),
+ dbesc($nickname)
+ );
+
+ if(count($x)) {
+ require_once('library/simplepie/simplepie.inc');
+ logger('mod-delivery: local delivery');
+ local_delivery($x[0],$atom);
+ break;
+ }
+ }
$deliver_status = dfrn_deliver($owner,$contact,$atom);
diff --git a/include/items.php b/include/items.php
index b32861c42..8360a42ec 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1555,14 +1555,14 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
}
}
-function local_delivery($importer,$xml) {
+function local_delivery($importer,$data) {
$a = get_app();
if($importer['readonly']) {
// We aren't receiving stuff from this person. But we will quietly ignore them
// rather than a blatant "go away" message.
- logger('dfrn_notify: ignoring');
+ logger('local_delivery: ignoring');
return 0;
//NOTREACHED
}
@@ -1680,7 +1680,7 @@ function local_delivery($importer,$xml) {
$rawmail = $feed->get_feed_tags( NAMESPACE_DFRN, 'mail' );
if(isset($rawmail[0]['child'][NAMESPACE_DFRN])) {
- logger('dfrn_notify: private message received');
+ logger('local_delivery: private message received');
$ismail = true;
$base = $rawmail[0]['child'][NAMESPACE_DFRN];
@@ -1785,7 +1785,7 @@ function local_delivery($importer,$xml) {
// NOTREACHED
}
- logger('dfrn_notify: feed item count = ' . $feed->get_item_quantity());
+ logger('local_delivery: feed item count = ' . $feed->get_item_quantity());
// process any deleted entries
@@ -1815,7 +1815,7 @@ function local_delivery($importer,$xml) {
$item = $r[0];
if(! $item['deleted'])
- logger('dfrn_notify: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
+ logger('local_delivery: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
if($item['uri'] == $item['parent-uri']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
@@ -1884,13 +1884,13 @@ function local_delivery($importer,$xml) {
if($r && count($r)) {
- logger('dfrn_notify: received remote comment');
+ logger('local_delivery: received remote comment');
$is_like = false;
// remote reply to our post. Import and then notify everybody else.
$datarray = get_atom_elements($feed,$item);
if(! link_compare($datarray['author-link'],$importer['url'])) {
- logger('dfrn_notify: received relay claiming to be from ' . $importer['url'] . ' however comment author url is ' . $datarray['author-link'] );
+ logger('local_delivery: received relay claiming to be from ' . $importer['url'] . ' however comment author url is ' . $datarray['author-link'] );
// they won't know what to do so don't report an error. Just quietly die.
return 0;
}
diff --git a/include/notifier.php b/include/notifier.php
index 18a0fe584..90111600a 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -453,6 +453,46 @@ function notifier_run($argv, $argc){
switch($contact['network']) {
case NETWORK_DFRN:
+
+ // perform local delivery if we are on the same site
+
+ $basepath = implode('/', array_slice(explode('/',$contact['url']),0,3));
+
+ if(link_compare($basepath,$a->get_baseurl())) {
+
+ $nickname = basename($contact['url']);
+ if($contact['issued-id'])
+ $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
+ else
+ $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
+
+ $x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
+ `contact`.`pubkey` AS `cpubkey`,
+ `contact`.`prvkey` AS `cprvkey`,
+ `contact`.`thumb` AS `thumb`,
+ `contact`.`url` as `url`,
+ `contact`.`name` as `senderName`,
+ `user`.*
+ FROM `contact`
+ LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
+ WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
+ $sql_extra
+ AND `user`.`account_expired` = 0 LIMIT 1",
+ dbesc(NETWORK_DFRN),
+ dbesc($nickname)
+ );
+
+ if(count($x)) {
+ require_once('library/simplepie/simplepie.inc');
+ logger('mod-delivery: local delivery');
+ local_delivery($x[0],$atom);
+ break;
+ }
+ }
+
+
+
logger('notifier: dfrndelivery: ' . $contact['name']);
$deliver_status = dfrn_deliver($owner,$contact,$atom);