]> git.mxchange.org Git - friendica.git/commitdiff
Some test code added
authorMichael Vogel <icarus@dabo.de>
Wed, 24 Jun 2015 12:21:42 +0000 (14:21 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 24 Jun 2015 12:21:42 +0000 (14:21 +0200)
include/notifier.php
include/ostatus.php

index 19f0134729f70ec88c386a7250c73ba036cd3fd5..312d45d0625e519d60449d34435ccc72e14677e8 100644 (file)
@@ -304,10 +304,11 @@ function notifier_run(&$argv, &$argc){
                        $thr_parent = q("SELECT `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d",
                                dbesc($target_item["thr-parent"]), intval($target_item["uid"]));
 
+                       logger('Parent is '.$parent['network'].'. Thread parent is '.$thr_parent[0]['network'], LOGGER_DEBUG);
+
                        // 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('Parent is '.$parent['network'].'. Thread parent is '.$thr_parent[0]['network'], LOGGER_DEBUG);
 
                                $push_notify = true;
 
@@ -338,22 +339,7 @@ function notifier_run(&$argv, &$argc){
                                                }
                                        }
                                }
-/*
-                               // Check if the recipient isn't in your contact list, try to slap it
-                               // Not sure if it is working or not.
-                               $r = q("SELECT `url` FROM `contact` WHERE `id` = %d", $parent['contact-id']);
-                               if (count($r)) {
-
-                                       $thrparent = q("SELECT `author-link` FROM `item` WHERE `uri` = '%s'", dbesc($target_item["thr-parent"]));
-                                       if (count($thrparent) AND (normalise_link($r[0]["url"]) != normalise_link($thrparent[0]["author-link"]))) {
-                                               $probed_contact = probe_url($thrparent[0]["author-link"]);
-                                               if ($probed_contact["notify"] != "") {
-                                                       logger('scrape data for slapper: '.print_r($probed_contact, true));
-                                                       $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
-                                               }
-                                       }
-                               }
-*/
+
                                if (count($url_recipients))
                                        logger("url_recipients ".print_r($url_recipients,true));
                        }
@@ -419,6 +405,21 @@ function notifier_run(&$argv, &$argc){
                        $conversant_str = dbesc(implode(', ',$conversants));
                }
 
+               // Test!
+               // 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"];
+                               }
+                       }
+               }
+
                $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
 
                if(count($r))
index 463ebcd30a779d07235716bbf13d4d2338a1be78..fccd178fe83f2000bb74642553e7cfa5a07a3a5f 100644 (file)
@@ -516,6 +516,7 @@ function ostatus_completion($conversation_url, $uid, $item = array()) {
 
        // If the thread shouldn't be completed then store the item and go away
        if ((intval(get_config('system','ostatus_poll_interval')) == -2) AND (count($item) > 0)) {
+               $arr["app"] .= " (OStatus-NoCompletion)";
                $item_stored = item_store($item, true);
                return($item_stored);
        }
@@ -584,6 +585,7 @@ function ostatus_completion($conversation_url, $uid, $item = array()) {
 
        if (!sizeof($items)) {
                if (count($item) > 0) {
+                       $arr["app"] .= " (OStatus-NoConvFetched)";
                        $item_stored = item_store($item, true);
 
                        if ($item_stored) {
@@ -862,6 +864,7 @@ function ostatus_completion($conversation_url, $uid, $item = array()) {
        }
 
        if (($item_stored < 0) AND (count($item) > 0)) {
+               $arr["app"] .= " (OStatus-NoConvFound)";
                $item_stored = item_store($item, true);
                if ($item_stored) {
                        logger("Uri ".$item["uri"]." wasn't found in conversation ".$conversation_url, LOGGER_DEBUG);