aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-27 20:00:43 -0800
committerfriendica <info@friendica.com>2015-01-27 20:00:43 -0800
commita2cdd1499c968c31ae1b95933231f80be5fc639b (patch)
tree231780d92f46a0f265e79fa478c3b7e7fc84d085 /include/zot.php
parent0bfbe6d61d3c6250a162a29d2cdb0ec78ad02f1d (diff)
parent145b30adfc21b7f29d1431ebd1e2e0f4ebd853bf (diff)
downloadvolse-hubzilla-a2cdd1499c968c31ae1b95933231f80be5fc639b.tar.gz
volse-hubzilla-a2cdd1499c968c31ae1b95933231f80be5fc639b.tar.bz2
volse-hubzilla-a2cdd1499c968c31ae1b95933231f80be5fc639b.zip
Merge branch 'master' into tres
Conflicts: include/socgraph.php
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php73
1 files changed, 68 insertions, 5 deletions
diff --git a/include/zot.php b/include/zot.php
index d8b9a1485..7bdde836f 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1078,6 +1078,12 @@ function zot_import($arr, $sender_url) {
$i['notify']['sender']['hash'] = make_xchan_hash($i['notify']['sender']['guid'],$i['notify']['sender']['guid_sig']);
$deliveries = null;
+ if(array_key_exists('message',$i) && array_key_exists('type',$i['message']) && $i['message']['type'] === 'rating') {
+ // rating messages are processed only by directory servers
+ logger('Rating received: ' . print_r($arr,true), LOGGER_DATA);
+ $result = process_rating_delivery($i['notify']['sender'],$arr);
+ }
+
if(array_key_exists('recipients',$i['notify']) && count($i['notify']['recipients'])) {
logger('specific recipients');
$recip_arr = array();
@@ -1097,7 +1103,8 @@ function zot_import($arr, $sender_url) {
// It's a specifically targetted post. If we were sent a public_scope hint (likely),
// get rid of it so that it doesn't get stored and cause trouble.
- if(($i) && is_array($i) && array_key_exists('message',$i) && is_array($i['message']) && array_key_exists('public_scope',$i['message']))
+ if(($i) && is_array($i) && array_key_exists('message',$i) && is_array($i['message'])
+ && $i['message']['type'] === 'activity' && array_key_exists('public_scope',$i['message']))
unset($i['message']['public_scope']);
$deliveries = $r;
@@ -1106,7 +1113,7 @@ function zot_import($arr, $sender_url) {
}
else {
- if(($i['message']) && (array_key_exists('flags',$i['message'])) && (in_array('private',$i['message']['flags']))) {
+ if(($i['message']) && (array_key_exists('flags',$i['message'])) && (in_array('private',$i['message']['flags'])) && $i['message']['type'] === 'activity') {
if(array_key_exists('public_scope',$i['message']) && $i['message']['public_scope'] === 'public') {
// This should not happen but until we can stop it...
logger('private message was delivered with no recipients.');
@@ -1197,6 +1204,7 @@ function zot_import($arr, $sender_url) {
$result = process_profile_delivery($i['notify']['sender'],$arr,$deliveries);
}
+
elseif($i['message']['type'] === 'channel_sync') {
// $arr = get_channelsync_elements($i['message']);
@@ -1456,7 +1464,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque
// As a side effect we will also do a preliminary check that we have the top-level-post, otherwise
// processing it is pointless.
- $r = q("select route from item where mid = '%s' and uid = %d limit 1",
+ $r = q("select route, id from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['parent_mid']),
intval($channel['channel_id'])
);
@@ -1493,14 +1501,34 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque
// going downstream check that we have the same upstream provider that
// sent it to us originally. Ignore it if it came from another source
- // (with potentially different permissions)
+ // (with potentially different permissions).
+ // only compare the last hop since it could have arrived at the last location any number of ways.
+ // Always accept empty routes.
+
+ $existing_route = explode(',', $r[0]['route']);
+ $routes = count($existing_route);
+ if($routes) {
+ $last_hop = array_pop($existing_route);
+ $last_prior_route = implode(',',$existing_route);
+ }
+ else {
+ $last_hop = '';
+ $last_prior_route = '';
+ }
$current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender['hash'];
- if($r[0]['route'] != $current_route) {
+ if($last_hop && $last_hop != $sender['hash'] && $sender['hash'] != 'undefined') {
+ logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG);
+ logger('comment route mismatch: parent msg = ' . $r[0]['id'],LOGGER_DEBUG);
$result[] = array($d['hash'],'comment route mismatch',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
continue;
}
+
+ // we'll add sender['hash'] onto this when we deliver it. $last_prior_route now has the previously stored route
+ // *except* for the sender['hash'] which would've been the last hop before it got to us.
+
+ $arr['route'] = $last_prior_route;
}
}
@@ -1750,6 +1778,41 @@ function process_mail_delivery($sender,$arr,$deliveries) {
return $result;
}
+function process_rating_delivery($sender,$arr) {
+
+ $dirmode = intval(get_config('system','directory_mode'));
+ if($dirmode == DIRECTORY_MODE_NORMAL)
+ return;
+
+ if(! $arr['target'])
+ return;
+
+ $r = q("select * from xlink where xlink_xchan = '%s' and xlink_target = '%s' limit 1",
+ dbesc($sender['hash']),
+ dbesc($arr['target'])
+ );
+ if($r) {
+ $x = q("update xlink set xlink_rating = %d, xlink_rating_text = '%s', xlink_updated = '%s' where xlink_id = %d",
+ intval($arr['rating']),
+ intval($arr['rating_text']),
+ dbesc(datetime_convert()),
+ intval($r[0]['xlink_id'])
+ );
+ }
+ else {
+ $x = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated, xlink_static )
+ values( '%s', '%s', %d, '%s', '%s', 1 ) ",
+ dbesc($sender['hash']),
+ dbesc($arr['target']),
+ intval($arr['rating']),
+ intval($arr['rating_text']),
+ dbesc(datetime_convert())
+ );
+ }
+ return;
+}
+
+
function process_profile_delivery($sender,$arr,$deliveries) {
logger('process_profile_delivery', LOGGER_DEBUG);