mirror of
https://github.com/friendica/friendica
synced 2025-01-15 05:15:31 +01:00
OStatus: Trying to deliver a comment to all contacts - not only the thread owner. (Not working by now)
This commit is contained in:
parent
dc182d508e
commit
b763c810fb
4 changed files with 54 additions and 35 deletions
|
@ -98,15 +98,13 @@ function delivery_run(&$argv, &$argc){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// find ancestors
|
// find ancestors
|
||||||
$r = q("SELECT * FROM `item` WHERE `id` = %d and visible = 1 and moderated = 0 LIMIT 1",
|
$r = q("SELECT * FROM `item` WHERE `id` = %d and visible = 1 and moderated = 0 LIMIT 1",
|
||||||
intval($item_id)
|
intval($item_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if((! count($r)) || (! intval($r[0]['parent']))) {
|
if((! count($r)) || (! intval($r[0]['parent'])))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
$target_item = $r[0];
|
$target_item = $r[0];
|
||||||
$parent_id = intval($r[0]['parent']);
|
$parent_id = intval($r[0]['parent']);
|
||||||
|
@ -123,9 +121,8 @@ function delivery_run(&$argv, &$argc){
|
||||||
intval($parent_id)
|
intval($parent_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! count($items)) {
|
if(! count($items))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
$icontacts = null;
|
$icontacts = null;
|
||||||
$contacts_arr = array();
|
$contacts_arr = array();
|
||||||
|
@ -201,6 +198,13 @@ function delivery_run(&$argv, &$argc){
|
||||||
if(strpos($localhost,':'))
|
if(strpos($localhost,':'))
|
||||||
$localhost = substr($localhost,0,strpos($localhost,':'));
|
$localhost = substr($localhost,0,strpos($localhost,':'));
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0",
|
||||||
|
intval($contact_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
if(count($r))
|
||||||
|
$contact = $r[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes
|
* Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes
|
||||||
|
@ -209,7 +213,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) {
|
if(!$top_level && ($parent["network"] != NETWORK_OSTATUS) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) {
|
||||||
logger('relay denied for delivery agent.');
|
logger('relay denied for delivery agent.');
|
||||||
|
|
||||||
/* no relay allowed for direct contact delivery */
|
/* no relay allowed for direct contact delivery */
|
||||||
|
@ -223,13 +227,6 @@ function delivery_run(&$argv, &$argc){
|
||||||
$public_message = false; // private recipients, not public
|
$public_message = false; // private recipients, not public
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0",
|
|
||||||
intval($contact_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
if(count($r))
|
|
||||||
$contact = $r[0];
|
|
||||||
|
|
||||||
$hubxml = feed_hublinks();
|
$hubxml = feed_hublinks();
|
||||||
|
|
||||||
logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA);
|
logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA);
|
||||||
|
@ -390,11 +387,15 @@ function delivery_run(&$argv, &$argc){
|
||||||
if(! $item_contact)
|
if(! $item_contact)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
|
// For OStatus don't notify all contacts in the thread
|
||||||
|
if (!$top_level AND ($parent["network"] == NETWORK_OSTATUS) AND ($item["id"] != $item["parent"]))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(($top_level OR ($parent["network"] == NETWORK_OSTATUS)) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
|
||||||
$slaps[] = atom_entry($item,'html',null,$owner,true);
|
$slaps[] = atom_entry($item,'html',null,$owner,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('notifier: slapdelivery: ' . $contact['name']);
|
logger('slapdelivery item '.$item_id.' to ' . $contact['name']);
|
||||||
foreach($slaps as $slappy) {
|
foreach($slaps as $slappy) {
|
||||||
if($contact['notify']) {
|
if($contact['notify']) {
|
||||||
if(! was_recently_delayed($contact['id']))
|
if(! was_recently_delayed($contact['id']))
|
||||||
|
|
|
@ -224,6 +224,9 @@ function notifier_run(&$argv, &$argc){
|
||||||
// fill this in with a single salmon slap if applicable
|
// fill this in with a single salmon slap if applicable
|
||||||
$slap = '';
|
$slap = '';
|
||||||
|
|
||||||
|
// List of OStatus receiptians of follow up messages
|
||||||
|
$ostatus_recip_str = "";
|
||||||
|
|
||||||
if(! ($mail || $fsuggest || $relocate)) {
|
if(! ($mail || $fsuggest || $relocate)) {
|
||||||
|
|
||||||
require_once('include/group.php');
|
require_once('include/group.php');
|
||||||
|
@ -284,8 +287,6 @@ function notifier_run(&$argv, &$argc){
|
||||||
if($parent['origin'])
|
if($parent['origin'])
|
||||||
$relay_to_owner = false;
|
$relay_to_owner = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($relay_to_owner) {
|
if($relay_to_owner) {
|
||||||
logger('notifier: followup', LOGGER_DEBUG);
|
logger('notifier: followup', LOGGER_DEBUG);
|
||||||
// local followup to remote post
|
// local followup to remote post
|
||||||
|
@ -295,6 +296,15 @@ function notifier_run(&$argv, &$argc){
|
||||||
$recipients = array($parent['contact-id']);
|
$recipients = array($parent['contact-id']);
|
||||||
|
|
||||||
if ($parent['network'] == NETWORK_OSTATUS) {
|
if ($parent['network'] == NETWORK_OSTATUS) {
|
||||||
|
$ostatus_recipients = array();
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `network` = '%s'", intval($uid), dbesc(NETWORK_OSTATUS));
|
||||||
|
if(count($r)) {
|
||||||
|
foreach($r as $rr)
|
||||||
|
$ostatus_recipients[] = $rr['id'];
|
||||||
|
|
||||||
|
$ostatus_recip_str = ", ".implode(', ', $ostatus_recipients);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the recipient isn't in your contact list
|
// Check if the recipient isn't in your contact list
|
||||||
$r = q("SELECT `url` FROM `contact` WHERE `id` = %d", $parent['contact-id']);
|
$r = q("SELECT `url` FROM `contact` WHERE `id` = %d", $parent['contact-id']);
|
||||||
|
@ -553,7 +563,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if($followup)
|
if($followup)
|
||||||
$recip_str = $parent['contact-id'];
|
$recip_str = $parent['contact-id'].$ostatus_recip_str;
|
||||||
else
|
else
|
||||||
$recip_str = implode(', ', $recipients);
|
$recip_str = implode(', ', $recipients);
|
||||||
|
|
||||||
|
@ -574,7 +584,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
|
|
||||||
foreach($r as $contact) {
|
foreach($r as $contact) {
|
||||||
if((! $mail) && (! $fsuggest) && (! $followup) && (!$relocate) && (! $contact['self'])) {
|
if((! $mail) && (! $fsuggest) && (!$followup OR ($parent['contact-id'] != $contact['id'])) && (!$relocate) && (! $contact['self'])) {
|
||||||
if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
|
if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
|
||||||
continue;
|
continue;
|
||||||
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
|
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
|
||||||
|
@ -608,10 +618,12 @@ function notifier_run(&$argv, &$argc){
|
||||||
if($contact['self'])
|
if($contact['self'])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
logger("Deliver to ".$contact['url'], LOGGER_DEBUG);
|
||||||
|
|
||||||
// potentially more than one recipient. Start a new process and space them out a bit.
|
// potentially more than one recipient. Start a new process and space them out a bit.
|
||||||
// we will deliver single recipient types of message and email recipients here.
|
// we will deliver single recipient types of message and email recipients here.
|
||||||
|
|
||||||
if((! $mail) && (! $fsuggest) && (!$relocate) && (! $followup)) {
|
if((! $mail) && (! $fsuggest) && (!$relocate) && (!$followup OR ($parent['contact-id'] != $contact['id']))) {
|
||||||
|
|
||||||
$this_batch[] = $contact['id'];
|
$this_batch[] = $contact['id'];
|
||||||
|
|
||||||
|
@ -713,7 +725,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if($followup && $contact['notify']) {
|
if($followup && $contact['notify']) {
|
||||||
logger('notifier: slapdelivery: ' . $contact['name']);
|
logger('slapdelivery followup item '.$item_id.' to ' . $contact['name']);
|
||||||
$deliver_status = slapper($owner,$contact['notify'],$slap);
|
$deliver_status = slapper($owner,$contact['notify'],$slap);
|
||||||
|
|
||||||
if($deliver_status == (-1)) {
|
if($deliver_status == (-1)) {
|
||||||
|
@ -726,7 +738,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
// a public hub, it's ok to send a salmon
|
// a public hub, it's ok to send a salmon
|
||||||
|
|
||||||
if((count($slaps)) && ($public_message) && (! $expire)) {
|
if((count($slaps)) && ($public_message) && (! $expire)) {
|
||||||
logger('notifier: slapdelivery: ' . $contact['name']);
|
logger('slapdelivery item '.$item_id.' to ' . $contact['name']);
|
||||||
foreach($slaps as $slappy) {
|
foreach($slaps as $slappy) {
|
||||||
if($contact['notify']) {
|
if($contact['notify']) {
|
||||||
$deliver_status = slapper($owner,$contact['notify'],$slappy);
|
$deliver_status = slapper($owner,$contact['notify'],$slappy);
|
||||||
|
@ -938,7 +950,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
// throw everything into the queue in case we get killed
|
// throw everything into the queue in case we get killed
|
||||||
|
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
if((! $mail) && (! $fsuggest) && (! $followup)) {
|
if((! $mail) && (! $fsuggest) && (!$followup OR ($parent['contact-id'] != $contact['id']))) {
|
||||||
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
|
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
|
||||||
dbesc($cmd),
|
dbesc($cmd),
|
||||||
intval($item_id),
|
intval($item_id),
|
||||||
|
|
|
@ -66,7 +66,7 @@ function get_salmon_key($uri,$keyhash) {
|
||||||
|
|
||||||
function slapper($owner,$url,$slap) {
|
function slapper($owner,$url,$slap) {
|
||||||
|
|
||||||
logger('slapper called. Data: ' . $slap);
|
logger('slapper called for '.$owner['url'].' to '.$url.' . Data: ' . $slap);
|
||||||
|
|
||||||
// does contact have a salmon endpoint?
|
// does contact have a salmon endpoint?
|
||||||
|
|
||||||
|
|
|
@ -835,10 +835,16 @@ function get_mentions($item) {
|
||||||
foreach($arr as $x) {
|
foreach($arr as $x) {
|
||||||
$matches = null;
|
$matches = null;
|
||||||
if(preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) {
|
if(preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) {
|
||||||
$o .= "\t\t" . '<link rel="mentioned" href="' . $matches[1] . '" />' . "\r\n";
|
|
||||||
$o .= "\t\t" . '<link rel="ostatus:attention" href="' . $matches[1] . '" />' . "\r\n";
|
$o .= "\t\t" . '<link rel="ostatus:attention" href="' . $matches[1] . '" />' . "\r\n";
|
||||||
|
$o .= "\t\t" . '<link rel="mentioned" href="' . $matches[1] . '" />' . "\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$item['private']) {
|
||||||
|
$o .= "\t\t".'<link rel="ostatus:attention" href="http://activityschema.org/collection/public"/>'."\r\n";
|
||||||
|
$o .= "\t\t".'<link rel="mentioned" href="http://activityschema.org/collection/public"/>'."\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue