move 'replyto' from initial concept to experimental stage

This commit is contained in:
nobody 2021-04-17 16:34:36 -07:00
parent 87de776a43
commit 1f2981418e
4 changed files with 65 additions and 14 deletions

View file

@ -400,7 +400,31 @@ class Notifier {
if (($relay_to_owner || $uplink) && ($cmd !== 'relay')) {
logger('followup relay (upstream delivery)', LOGGER_DEBUG);
$sendto = ($uplink) ? $parent_item['source_xchan'] : $parent_item['owner_xchan'];
if (defined('X-REPLY-TO')) {
// experimental until debugging is completed
if ($parent_item['replyto']) {
$ptr = unserialise($parent_item['replyto']);
if (is_string($ptr)) {
$sendto = $ptr;
self::$recipients = [ $sendto ];
}
elseif (is_array($tr)) {
$sendto = [];
foreach ($ptr as $rto) {
if (is_string($rto)) {
$sendto[] = $rto;
}
elseif (is_array($rto) && isset($rto['id'])) {
$sendto[] = $rto['id'];
}
}
self::$recipients = $sendto;
}
}
else // X-REPLY-TO
self::$recipients = [ $sendto ];
}
// END X-REPLY-TO
self::$private = true;
$upstream = true;
self::$packet_type = 'response';

View file

@ -782,10 +782,11 @@ class Activity {
else
return [];
$replyto = self::encode_person($i['owner'],false);
// if ($replyto) {
// $ret['replyTo'] = $replyto;
// }
$replyto = unserialise($i['replyto']);
if ($replyto) {
$ret['replyTo'] = $replyto;
}
if (! isset($ret['url'])) {
$urls = [];
@ -1166,10 +1167,10 @@ class Activity {
}
}
$replyto = self::encode_person($i['owner'],false);
// if ($replyto) {
// $ret['replyTo'] = $replyto;
// }
$replyto = unserialise($i['replyto']);
if ($replyto) {
$ret['replyTo'] = $replyto;
}
if (! isset($ret['url'])) {
$urls = [];
@ -2515,6 +2516,15 @@ class Activity {
$s['mid'] = $s['parent_mid'] = $act->id;
}
if (isset($act->replyto) && ! empty($act->replyto)) {
if (is_array($act->replyto) && isset($act->replyto['id'])) {
$s['replyto'] = $act->replyto['id'];
}
else {
$s['replyto'] = $act->replyto;
}
}
if (ActivityStreams::is_response_activity($act->type)) {
$response_activity = true;
@ -2522,9 +2532,6 @@ class Activity {
$s['mid'] = $act->id;
$s['parent_mid'] = $act->obj['id'];
// if (isset($act->replyto) && ! empty($act->replyto)) {
// $s['replyto'] = $act->replyto;
// }
// over-ride the object timestamp with the activity

View file

@ -533,6 +533,10 @@ class Item extends Controller {
}
if ($parent_item && isset($parent_item['replyto']) && $parent_item['replyto']) {
$replyto = unserialise($parent_item['replyto']);
}
$moderated = false;
if (! $observer) {
@ -696,7 +700,17 @@ class Item extends Controller {
}
}
}
if (! isset($replyto)) {
if (strpos($owner_xchan['xchan_hash'],'http') === 0) {
$replyto = $owner_xchan['xchan_hash'];
}
else {
$replyto = $owner_xchan['xchan_url'];
}
}
$acl = new AccessControl($channel);
$view_policy = PermissionLimits::Get($channel['channel_id'],'view_stream');
@ -1340,7 +1354,7 @@ class Item extends Controller {
$datarray['term'] = $post_tags;
$datarray['plink'] = $plink;
$datarray['route'] = $route;
$datarray['replyto'] = $replyto;
// A specific ACL over-rides public_policy completely

View file

@ -724,6 +724,7 @@ function get_item_elements($x,$allow_code = false) {
}
$arr['attach'] = activity_sanitise($x['attach']);
$arr['replyto'] = activity_sanitise($c['replyto']);
$arr['term'] = decode_tags($x['tags']);
$arr['iconfig'] = decode_item_meta($x['meta']);
@ -1115,6 +1116,7 @@ function encode_item($item,$mirror = false) {
$x['longlat'] = $item['coord'];
$x['signature'] = $item['sig'];
$x['route'] = $item['route'];
$x['replyto'] = $item['replyto'];
$x['owner'] = encode_item_xchan($item['owner']);
$x['author'] = encode_item_xchan($item['author']);
@ -3058,6 +3060,9 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false
$arr['deny_gid'] = $channel['channel_deny_gid'];
$arr['comment_policy'] = map_scope(PermissionLimits::Get($channel['channel_id'],'post_comments'));
$arr['replyto'] = z_root() . '/channel/' . $channel['channel_address'];
if ($arr['id']) {
$post = item_store_update($arr);
}
@ -3117,12 +3122,13 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false
$title = $item['title'];
$body = $item['body'];
$r = q("update item set item_uplink = %d, item_nocomment = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
$r = q("update item set item_uplink = %d, item_nocomment = %d, item_flags = %d, owner_xchan = '%s', replyto = '%s', allow_cid = '%s', allow_gid = '%s',
deny_cid = '%s', deny_gid = '%s', item_private = %d, comment_policy = '%s', title = '%s', body = '%s', item_wall = %d, item_origin = %d where id = %d",
intval($item_uplink),
intval($item_nocomment),
intval($flag_bits),
dbesc($channel['channel_hash']),
dbesc(channel_url($channel)),
dbesc($channel['channel_allow_cid']),
dbesc($channel['channel_allow_gid']),
dbesc($channel['channel_deny_cid']),