aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-11-21 13:52:15 +0100
committerFabio Comuni <fabrix.xm@gmail.com>2011-11-21 13:52:15 +0100
commitcb05e677a96e1312263c0a1c63ee10cea62268b1 (patch)
tree9234db8ab0c946ed65123181acba0df71524a8eb /include
parenta86fd26bd86945fe75b7220e149b8986f88feb01 (diff)
parentaaedac8f574278fba89cd11d3d8f1adaeb6b030e (diff)
downloadvolse-hubzilla-cb05e677a96e1312263c0a1c63ee10cea62268b1.tar.gz
volse-hubzilla-cb05e677a96e1312263c0a1c63ee10cea62268b1.tar.bz2
volse-hubzilla-cb05e677a96e1312263c0a1c63ee10cea62268b1.zip
Merge remote-tracking branch 'friendica/master'
Diffstat (limited to 'include')
-rw-r--r--include/items.php103
-rw-r--r--include/network.php4
-rw-r--r--include/notifier.php12
3 files changed, 111 insertions, 8 deletions
diff --git a/include/items.php b/include/items.php
index a008e4ac8..fd36dcadb 100644
--- a/include/items.php
+++ b/include/items.php
@@ -893,6 +893,8 @@ function item_store($arr,$force_parent = false) {
);
}
+ tgroup_deliver($arr['uid'],$current_post);
+
return $current_post;
}
@@ -909,6 +911,69 @@ function get_item_contact($item,$contacts) {
}
+function tgroup_deliver($uid,$item_id) {
+
+
+ // setup a second delivery chain for forum/community posts if appropriate
+
+ $a = get_app();
+
+ $deliver_to_tgroup = false;
+
+ $u = q("select * from user where uid = %d and `page-flags` = %d limit 1",
+ intval($uid),
+ intval(PAGE_COMMUNITY)
+ );
+ if(! count($u))
+ return;
+
+ $i = q("select * from item where id = %d and uid = %d limit 1",
+ intval($item_id),
+ intval($uid)
+ );
+ if(! count($i))
+ return;
+
+ $item = $i[0];
+
+ // prevent delivery looping - only proceed
+ // if the message originated elsewhere and is a top-level post
+
+ if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
+ return;
+
+
+ $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
+
+ $cnt = preg_match_all('/\@\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ if(link_compare($link,$mtch[1])) {
+ $deliver_to_tgroup = true;
+ logger('tgroup_deliver: local group mention found: ' . $mtch[2]);
+ }
+ }
+ }
+
+ if(! $deliver_to_tgroup)
+ return;
+
+ // now change this copy of the post to a forum head message and deliver to all the tgroup members
+
+
+ q("update item set wall = 1, origin = 1, forum_mode = 1 where id = %d limit 1",
+ intval($item_id)
+ );
+
+ proc_run('php','include/notifier.php','tgroup',$item_id);
+
+}
+
+
+
+
+
+
function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$a = get_app();
@@ -1963,18 +2028,31 @@ function local_delivery($importer,$data) {
if($is_reply) {
+ $community = false;
+
+ if($importer['page-flags'] == PAGE_COMMUNITY) {
+ $sql_extra = '';
+ $community = true;
+ logger('local_delivery: community reply');
+ }
+ else
+ $sql_extra = " and contact.self = 1 and item.wall = 1 ";
+
// was the top-level post for this reply written by somebody on this site?
// Specifically, the recipient?
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`,
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
- WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s'
- AND `item`.`uid` = %d LIMIT 1",
+ WHERE `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s'
+ AND `item`.`uid` = %d
+ $sql_extra
+ LIMIT 1",
dbesc($parent_uri),
dbesc($parent_uri),
intval($importer['importer_uid'])
);
+
if($r && count($r)) {
logger('local_delivery: received remote comment');
@@ -1982,11 +2060,14 @@ function local_delivery($importer,$data) {
// remote reply to our post. Import and then notify everybody else.
$datarray = get_atom_elements($feed,$item);
- if(! link_compare($datarray['author-link'],$importer['url'])) {
- logger('local_delivery: received relay claiming to be from ' . $importer['url'] . ' however comment author url is ' . $datarray['author-link'] );
+
+ // TODO: make this next part work against both delivery threads of a community post
+
+// if((! link_compare($datarray['author-link'],$importer['url'])) && (! $community)) {
+// logger('local_delivery: received relay claiming to be from ' . $importer['url'] . ' however comment author url is ' . $datarray['author-link'] );
// they won't know what to do so don't report an error. Just quietly die.
- return 0;
- }
+// return 0;
+// }
$datarray['type'] = 'remote-comment';
$datarray['wall'] = 1;
@@ -2031,6 +2112,16 @@ function local_delivery($importer,$data) {
}
}
+// if($community) {
+// $newtag = '@[url=' . $a->get_baseurl() . '/profile/' . $importer['nickname'] . ']' . $importer['username'] . '[/url]';
+// if(! stristr($datarray['tag'],$newtag)) {
+// if(strlen($datarray['tag']))
+// $datarray['tag'] .= ',';
+// $datarray['tag'] .= $newtag;
+// }
+// }
+
+
$posted_id = item_store($datarray);
$parent = 0;
diff --git a/include/network.php b/include/network.php
index e89eb94da..78ed24074 100644
--- a/include/network.php
+++ b/include/network.php
@@ -22,7 +22,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
}
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
- @curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
+ @curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
if(intval($timeout)) {
@@ -105,7 +105,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
- curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
+ curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
if(intval($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
diff --git a/include/notifier.php b/include/notifier.php
index a4fe9b71e..c81ca2d15 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -218,6 +218,11 @@ function notifier_run($argv, $argc){
$relay_to_owner = true;
}
+
+ if(($cmd === 'uplink') && (intval($parent['forum_mode'])) && (! $top_level)) {
+ $relay_to_owner = true;
+ }
+
// until the 'origin' flag has been in use for several months
// we will just use it as a fallback test
// later we will be able to use it as the primary test of whether or not to relay.
@@ -259,6 +264,13 @@ function notifier_run($argv, $argc){
$deny_people = expand_acl($parent['deny_cid']);
$deny_groups = expand_groups(expand_acl($parent['deny_gid']));
+ // if our parent is a forum, uplink to the origonal author causing
+ // a delivery fork
+
+ if(intval($parent['forum_mode']) && (! $top_level) && ($cmd !== 'uplink')) {
+ proc_run('php','include/notifier','uplink',$item_id);
+ }
+
$conversants = array();
foreach($items as $item) {