X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fnotifier.php;h=069f3bdf2e37abb655237ac8edbb6692d442b375;hb=eb5e6aae7273fef06a06f983fe78aaad737aa729;hp=0166d0b372a38b22a2d859ded7a86128ccd2b1f9;hpb=f5615068ca338153ab7dacf5c9ce46c6ed7b1ab4;p=friendica.git diff --git a/include/notifier.php b/include/notifier.php index 0166d0b372..069f3bdf2e 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -60,19 +60,19 @@ if(! count($r)) killme(); - $parent = $r[0]['parent']; + $parent_id = $r[0]['parent']; $uid = $r[0]['uid']; $updated = $r[0]['edited']; $items = q("SELECT * FROM `item` WHERE `parent` = %d ORDER BY `id` ASC", - intval($parent) + intval($parent_id) ); if(! count($items)) killme(); } - $r = q("SELECT `contact`.*, `user`.`nickname` + $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($uid) @@ -84,6 +84,11 @@ killme(); $hub = get_config('system','huburl'); + // If this is a public conversation, notify the feed hub + $notify_hub = true; + + // fill this in with a salmon slap if applicable + $slap = ''; if($cmd != 'mail') { @@ -94,11 +99,18 @@ if($parent['type'] === 'remote') { // local followup to remote post $followup = true; + $notify_hub = false; // not public $conversant_str = dbesc($parent['contact-id']); } else { $followup = false; + if((strlen($parent['allow_cid'])) + || (strlen($parent['allow_gid'])) + || (strlen($parent['deny_cid'])) + || (strlen($parent['deny_gid']))) + $notify_hub = false; // private recipients, not public + $allow_people = expand_acl($parent['allow_cid']); $allow_groups = expand_groups(expand_acl($parent['allow_gid'])); $deny_people = expand_acl($parent['deny_cid']); @@ -119,8 +131,6 @@ $recipients = array_diff($recipients,$deny); $conversant_str = dbesc(implode(', ',$conversants)); - - } $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0"); @@ -140,14 +150,25 @@ $atom = ''; - $hubxml = ((strlen($hub)) ? '' . "\n" : ''); - + $hubxml = ''; + if(strlen($hub)) { + $hubs = explode(',', $hub); + if(count($hubs)) { + foreach($hubs as $h) { + $h = trim($h); + if(! strlen($h)) + continue; + $hubxml .= '' . "\n" ; + } + } + } $atom .= replace_macros($feed_template, array( '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ), '$feed_title' => xmlify($owner['name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) , '$hub' => $hubxml, + '$salmon' => '', // private feed, we don't use salmon here '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$photo' => xmlify($owner['photo']), @@ -158,6 +179,7 @@ )); if($cmd === 'mail') { + $notify_hub = false; // mail is not public $atom .= replace_macros($mail_template, array( '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), @@ -178,7 +200,7 @@ $actobj = construct_activity($item); if($item['id'] == $item_id) { - $atom .= replace_macros($cmnt_template, array( + $slap = replace_macros($cmnt_template, array( '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$thumb' => xmlify($owner['thumb']), @@ -190,6 +212,7 @@ '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)), '$location' => xmlify($item['location']), + '$coord' => xmlify($item['coord']), '$type' => 'text', '$verb' => xmlify($verb), '$actobj' => $actobj, @@ -200,6 +223,7 @@ )); } } + $atom .= $slap; } else { foreach($items as $item) { @@ -230,6 +254,7 @@ '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)), '$location' => xmlify($item['location']), + '$coord' => xmlify($item['coord']), '$type' => 'text', '$verb' => xmlify($verb), '$actobj' => $actobj, @@ -250,6 +275,7 @@ '$content' => xmlify($item['body']), '$alt' => xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id']), '$location' => xmlify($item['location']), + '$coord' => xmlify($item['coord']), '$type' => 'text', '$verb' => xmlify($verb), '$actobj' => $actobj, @@ -281,6 +307,8 @@ // delivery loop + + foreach($r as $contact) { if($contact['self']) continue; @@ -289,9 +317,13 @@ switch($contact['network']) { case 'dfrn': - $deliver_status = dfrn_deliver($contact,$atom,$debugging); + $deliver_status = dfrn_deliver($owner,$contact,$atom,$debugging); break; default: + if($followup) { + require_once('include/salmon.php'); + slapper($owner,$contact,$slap); + } break; } @@ -302,9 +334,23 @@ } } - if((strlen($hub)) && ($cmd !== 'mail') && ($followup == false)) { - $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); - post_url($hub,$params); + if((strlen($hub)) && ($notify_hub)) { + $hubs = explode(',', $hub); + if(count($hubs)) { + foreach($hubs as $h) { + $h = trim($h); + if(! strlen($h)) + continue; + $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] ); + post_url($h,$params); + if($debugging) { + file_put_contents('pubsub.out', "\n\n" . "Pinged hub " . $h . ' at ' + . datetime_convert() . "\n" . "Hub returned " . $a->get_curl_code() . "\n\n" , FILE_APPEND); + } + if(count($hubs) > 1) + sleep(7); // try and avoid multiple hubs responding at precisely the same time + } + } } killme();