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)
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') {
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']);
$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");
$atom = '';
- $hubxml = ((strlen($hub)) ? '<link rel="hub" href="' . xmlify($hub) . '" />' . "\n" : '');
-
+ $hubxml = '';
+ if(strlen($hub)) {
+ $hubs = explode(',', $hub);
+ if(count($hubs)) {
+ foreach($hubs as $h) {
+ $h = trim($h);
+ if(! strlen($h))
+ continue;
+ $hubxml .= '<link rel="hub" href="' . xmlify($h) . '" />' . "\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']),
));
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']),
$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']),
'$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,
));
}
}
+ $atom .= $slap;
}
else {
foreach($items as $item) {
'$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,
'$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,
// delivery loop
+
+
foreach($r as $contact) {
if($contact['self'])
continue;
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;
}
}
}
- 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();