]> git.mxchange.org Git - friendica.git/blobdiff - include/notifier.php
cleaned up the conditions on when to and when not to relay.
[friendica.git] / include / notifier.php
index 93df670f107d2a06df8ea131e85f845967e84b34..7b645844f6985ca4722d834d1e7a8343a57d1424 100644 (file)
@@ -150,7 +150,37 @@ function notifier_run($argv, $argc){
 
                $parent = $items[0];
 
-               if($parent['wall'] == 0 && (! $expire)) {
+               // This is IMPORTANT!!!!
+
+               // We will only send a "notify owner to relay" or followup message if the referenced post
+               // originated on our system by virtue of having our hostname somewhere
+               // in the URI, AND it was a comment (not top_level) AND the parent originated elsewhere.
+               // if $parent['wall'] == 1 we will already have the parent message in our array
+               // and we will relay the whole lot.
+               // expire sends an entire group of expire messages and cannot be forwarded.
+               // However the conversation owner will be a part of the conversation and will 
+               // be notified during this run.
+               // Other DFRN conversation members will be alerted during polled updates.
+
+               // Diaspora members currently are not notified of expirations, and other networks have
+               // either limited or no ability to process deletions. We should at least fix Diaspora 
+               // by stringing togther an array of retractions and sending them onward.
+                
+       
+               $localhost = $a->get_hostname();
+               if(strpos($localhost,':'))
+                       $localhost = substr($localhost,0,strpos($localhost,':'));
+
+               /**
+                *
+                * Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes 
+                * have been known to cause runaway conditions which affected several servers, along with 
+                * permissions issues. 
+                *
+                */
+               if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) {
                        // local followup to remote post
                        $followup = true;
                        $public_message = false; // not public
@@ -513,7 +543,7 @@ function notifier_run($argv, $argc){
                                                // unsupported
                                                break;
                                        }
-                                       elseif($target_item['deleted'] && (! $parent_item['verb'] === ACTIVITY_LIKE)) {
+                                       elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
                                                // diaspora delete, 
                                                diaspora_send_retraction($target_item,$owner,$contact);
                                                break;
@@ -619,16 +649,17 @@ function notifier_run($argv, $argc){
                                );
 
                                if(count($n)) {
-                                       switch($n[0]['network']) {
+                                       $contact = $n[0];
+                                       switch($contact['network']) {
                                                case NETWORK_DFRN :
-                                                       logger('notifier: dfrnpubdelivery: ' . $n[0]['name']);
-                                                       $deliver_status = dfrn_deliver($owner,$n[0],$atom);
+                                                       logger('notifier: dfrnpubdelivery: ' . $contact['name']);
+                                                       $deliver_status = dfrn_deliver($owner,$contact,$atom);
                                                        break;
                                                case NETWORK_DIASPORA :
                                                        require_once('include/diaspora.php');
                                                        if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
                                                                break;
-
+                                                       
                                                        if(! $contact['pubkey'])
                                                                break;
                                        
@@ -636,23 +667,23 @@ function notifier_run($argv, $argc){
                                                                // unsupported
                                                                break;
                                                        }
-                                                       elseif($target_item['deleted'] && (! $parent_item['verb'] === ACTIVITY_LIKE)) {
+                                                       elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
                                                                // diaspora delete, 
-                                                               diaspora_send_retraction($target_item,$owner,$n[0]);
+                                                               diaspora_send_retraction($target_item,$owner,$contact);
                                                                break;
                                                        }
                                                        elseif($followup) {
                                                                // send comments, likes and retractions of likes to owner to relay
-                                                               diaspora_send_followup($target_item,$owner,$n[0]);
+                                                               diaspora_send_followup($target_item,$owner,$contact);
                                                                break;
                                                        }
                                                        elseif($target_item['parent'] != $target_item['id']) {
                                                                // we are the relay - send comments, likes and unlikes to our conversants
-                                                               diaspora_send_relay($target_item,$owner,$n[0]);
+                                                               diaspora_send_relay($target_item,$owner,$contact);
                                                                break;
                                                        }               
                                                        elseif($top_level) {
-                                                               diaspora_send_status($target_item,$owner,$n[0]);
+                                                               diaspora_send_status($target_item,$owner,$contact);
                                                                break;
                                                        }
                                                default: