require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
require_once("boot.php");
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
- * big problems on shared hosting systems, where the process might get killed by the
- * hosting provider and nothing would get delivered.
+ * big problems on shared hosting systems, where the process might get killed by the
+ * hosting provider and nothing would get delivered.
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
- $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
- `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
+ $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
+ `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
// local followup to remote post
$followup = true;
$public_message = false; // not public
$conversant_str = dbesc($parent['contact-id']);
// local followup to remote post
$followup = true;
$public_message = false; // not public
$conversant_str = dbesc($parent['contact-id']);
+ $recipients = array($parent['contact-id']);
+
+ 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;
+
+ // We notify Friendica users in the thread when it is an OStatus thread.
+ // Hopefully this transfers the messages to the other Friendica servers. (Untested)
+ if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
+
+ $push_notify = true;
+
+ if ($parent["network"] == NETWORK_OSTATUS) {
+ $r = q("SELECT `author-link` FROM `item` WHERE `parent` = %d AND `author-link` != '%s'",
+ intval($target_item["parent"]), dbesc($owner['url']));
+ foreach($r as $parent_item) {
+ $probed_contact = probe_url($parent_item["author-link"]);
+ if (($probed_contact["notify"] != "") AND ($probed_contact["network"] == NETWORK_DFRN)) {
+ logger('Notify Friendica user '.$probed_contact["url"].': '.$probed_contact["notify"]);
+ $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
+ }
+ }
+ }
+
+ if (count($url_recipients))
+ logger("url_recipients ".print_r($url_recipients,true));
+ }
+ } else {
- if((strlen($parent['allow_cid']))
- || (strlen($parent['allow_gid']))
- || (strlen($parent['deny_cid']))
+ if((strlen($parent['allow_cid']))
+ || (strlen($parent['allow_gid']))
+ || (strlen($parent['deny_cid']))
- $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
+ // If the thread parent is OStatus then do some magic to distribute the messages.
+ // We have not only to look at the parent, since it could be a Friendica thread.
+ if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
+
+ logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
+
+ // 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('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]);
+ $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
+ }
+ }
+ }
+
+ // It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora
+ $sql_extra = " AND `network` IN ('".NETWORK_OSTATUS."', '".NETWORK_DFRN."')";
+ } else
+ $sql_extra = "";
+
+ $r = q("SELECT * FROM `contact` WHERE `id` IN ($conversant_str) AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0".$sql_extra);
- $atom .= replace_macros($sugg_template, array(
- '$name' => xmlify($owner['name']),
- '$photo' => xmlify($photos[4]),
- '$thumb' => xmlify($photos[5]),
- '$micro' => xmlify($photos[6]),
- '$url' => xmlify($owner['url']),
- '$request' => xmlify($owner['request']),
- '$confirm' => xmlify($owner['confirm']),
- '$notify' => xmlify($owner['notify']),
- '$poll' => xmlify($owner['poll']),
- '$sitepubkey' => xmlify(get_config('system','site_pubkey')),
- //'$pubkey' => xmlify($owner['pubkey']),
- //'$prvkey' => xmlify($owner['prvkey']),
- ));
- $recipients_relocate = q("SELECT * FROM contact WHERE uid = %d AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN);
+ $atom .= replace_macros($sugg_template, array(
+ '$name' => xmlify($owner['name']),
+ '$photo' => xmlify($photos[4]),
+ '$thumb' => xmlify($photos[5]),
+ '$micro' => xmlify($photos[6]),
+ '$url' => xmlify($owner['url']),
+ '$request' => xmlify($owner['request']),
+ '$confirm' => xmlify($owner['confirm']),
+ '$notify' => xmlify($owner['notify']),
+ '$poll' => xmlify($owner['poll']),
+ '$sitepubkey' => xmlify(get_config('system','site_pubkey')),
+ //'$pubkey' => xmlify($owner['pubkey']),
+ //'$prvkey' => xmlify($owner['prvkey']),
+ ));
+ $recipients_relocate = q("SELECT * FROM contact WHERE uid = %d AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN);
if($followup) {
foreach($items as $item) { // there is only one item
if(! $item['parent'])
continue;
if($item['id'] == $item_id) {
logger('notifier: followup: item: ' . print_r($item,true), LOGGER_DATA);
if($followup) {
foreach($items as $item) { // there is only one item
if(! $item['parent'])
continue;
if($item['id'] == $item_id) {
logger('notifier: followup: item: ' . print_r($item,true), LOGGER_DATA);
- $slap = atom_entry($item,'html',null,$owner,false);
+ //$slap = atom_entry($item,'html',null,$owner,false);
$atom .= atom_entry($item,'text',null,$owner,false);
}
}
$atom .= atom_entry($item,'text',null,$owner,false);
}
}
if($item_id == $item['id'] || $item['id'] == $item['parent'])
$atom .= atom_entry($item,'text',null,$owner,true);
if($item_id == $item['id'] || $item['id'] == $item['parent'])
$atom .= atom_entry($item,'text',null,$owner,true);
$atom .= atom_entry($item,'text',null,$owner,true);
$atom .= atom_entry($item,'text',null,$owner,true);
$slaps[] = atom_entry($item,'html',null,$owner,true);
}
}
$slaps[] = atom_entry($item,'html',null,$owner,true);
}
}
- if ($relocate)
- $r = $recipients_relocate;
- else
- $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ",
- dbesc($recip_str)
- );
+ if ($relocate)
+ $r = $recipients_relocate;
+ else
+ $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ",
+ dbesc($recip_str)
+ );
require_once('include/salmon.php');
$interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
require_once('include/salmon.php');
$interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
// together into a single process. This will reduce the overall number of processes
// spawned for each delivery, but they will run longer.
// together into a single process. This will reduce the overall number of processes
// spawned for each delivery, but they will run longer.
$ssl_policy = get_config('system','ssl_policy');
fix_contact_ssl_policy($x[0],$ssl_policy);
$ssl_policy = get_config('system','ssl_policy');
fix_contact_ssl_policy($x[0],$ssl_policy);
$deliver_status = slapper($owner,$contact['notify'],$slap);
if($deliver_status == (-1)) {
$deliver_status = slapper($owner,$contact['notify'],$slap);
if($deliver_status == (-1)) {
foreach($slaps as $slappy) {
if($contact['notify']) {
$deliver_status = slapper($owner,$contact['notify'],$slappy);
foreach($slaps as $slappy) {
if($contact['notify']) {
$deliver_status = slapper($owner,$contact['notify'],$slappy);
- if($target_item['verb'] === ACTIVITY_DISLIKE) {
- // unsupported
- break;
+ $unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+
+ //don't transmit activities which are not supported by diaspora
+ foreach($unsupported_activities as $act) {
+ if(activity_match($target_item['verb'],$act)) {
+ break 2;
+ }
// send both top-level retractions and relayable retractions for owner to relay
diaspora_send_retraction($target_item,$owner,$contact);
break;
// send both top-level retractions and relayable retractions for owner to relay
diaspora_send_retraction($target_item,$owner,$contact);
break;
$r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
AND `uid` = %d AND `rel` != %d group by `batch` ORDER BY rand() ",
dbesc(NETWORK_DIASPORA),
$r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
AND `uid` = %d AND `rel` != %d group by `batch` ORDER BY rand() ",
dbesc(NETWORK_DIASPORA),
proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']);
if($interval)
@time_sleep_until(microtime(true) + (float) $interval);
proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']);
if($interval)
@time_sleep_until(microtime(true) + (float) $interval);
- if ($h === '[internal]') {
- // Set push flag for PuSH subscribers to this topic,
- // they will be notified in queue.php
- q("UPDATE `push_subscriber` SET `push` = 1 " .
- "WHERE `nickname` = '%s'", dbesc($owner['nickname']));
- } else {
- $params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
- post_url($h,$params);
- logger('pubsub: publish: ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
- }
- if(count($hubs) > 1)
- sleep(7); // try and avoid multiple hubs responding at precisely the same time
+ if($push_notify AND strlen($hub)) {
+ $hubs = explode(',', $hub);
+ if(count($hubs)) {
+ foreach($hubs as $h) {
+ $h = trim($h);
+ if(! strlen($h))
+ continue;
+
+ if ($h === '[internal]') {
+ // Set push flag for PuSH subscribers to this topic,
+ // they will be notified in queue.php
+ q("UPDATE `push_subscriber` SET `push` = 1 " .
+ "WHERE `nickname` = '%s'", dbesc($owner['nickname']));
+
+ logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
+
+ } else {
+
+ $params = 'hub.mode=publish&hub.url=' . urlencode( $a->get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
+ post_url($h,$params);
+ logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());