source routing stuff

This commit is contained in:
friendica 2014-03-29 21:53:50 -07:00
parent a31d5c7cdd
commit 1108eaaed0
2 changed files with 37 additions and 0 deletions

View File

@ -81,6 +81,18 @@ function collect_recipients($item,&$private) {
$recipients = check_list_permissions($item['uid'],$recipients,'view_stream');
$routes = q("select * from route where iid = %d",
intval($item['id'])
);
if($routes) {
$route = explode(',',$routes[0]['route']);
if(count($route)) {
$route = array_unique($route);
$recipients = array_diff($recipients,$route);
}
}
// add ourself just in case we have nomadic clones that need to get a copy.
$recipients[] = $item['author_xchan'];
@ -141,6 +153,28 @@ function can_comment_on_post($observer_xchan,$item) {
}
function add_source_route($iid,$hash) {
if((! $iid) || (! $route))
return;
$r = q("select * from route where iid = %d limit 1",
intval($iid)
);
if($r && $r[0]['route']) {
q("update route set route = '%s' where iid = %d limit 1",
dbesc(',' . $hash),
intval($iid)
);
}
else {
q("insert into route ( iid, route ) values ( %d, '%s') ",
intval($iid),
dbesc($route)
);
}
}
/**
* @function red_zrl_callback
* preg_match function when fixing 'naked' links in mod item.php

View File

@ -1452,6 +1452,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false) {
}
$xyz = event_store($ev);
add_source_route($xyz,$sender['hash']);
$result = array($d['hash'],'event processed',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
continue;
@ -1476,6 +1477,8 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false) {
$arr['uid'] = $channel['channel_id'];
$item_result = item_store($arr);
$item_id = $item_result['item_id'];
add_source_route($item_id,$sender['hash']);
$result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
}