mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:15:13 +00:00
wip: replies continued
This commit is contained in:
parent
5872366f79
commit
888010df5c
1 changed files with 22 additions and 22 deletions
|
@ -17,9 +17,9 @@ class Replies extends Controller
|
|||
public function init()
|
||||
{
|
||||
if (ActivityStreams::is_as_request() || Libzot::is_nomad_request()) {
|
||||
$item_id = argv(1);
|
||||
$item_mid = argv(1);
|
||||
|
||||
if (!$item_id) {
|
||||
if (!$item_mid) {
|
||||
http_status_exit(404, 'Not found');
|
||||
}
|
||||
|
||||
|
@ -33,13 +33,13 @@ class Replies extends Controller
|
|||
|
||||
$test = q(
|
||||
"select * from item where mid = '%s' $item_normal limit 1",
|
||||
dbesc(z_root() . '/activity/' . $item_id)
|
||||
dbesc(z_root() . '/activity/' . $item_mid)
|
||||
);
|
||||
|
||||
if (!$test) {
|
||||
$test = q(
|
||||
"select * from item where mid = '%s' $item_normal limit 1",
|
||||
dbesc(z_root() . '/item/' . $item_id)
|
||||
dbesc(z_root() . '/item/' . $item_mid)
|
||||
);
|
||||
if (!$test) {
|
||||
http_status_exit(404, 'Not found');
|
||||
|
@ -71,7 +71,7 @@ class Replies extends Controller
|
|||
if ($xchans) {
|
||||
$hashes = ids_to_querystr($xchans, 'xchan_hash', true);
|
||||
$i = q(
|
||||
"select id as item_id, item_private, uid from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1",
|
||||
"select item.* id as item_id from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1",
|
||||
dbesc($test[0]['mid'])
|
||||
);
|
||||
}
|
||||
|
@ -94,8 +94,8 @@ class Replies extends Controller
|
|||
|
||||
if (!$i) {
|
||||
$i = q(
|
||||
"select id as item_id, item_private, uid from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
|
||||
dbesc($test[0]['parent_mid'])
|
||||
"select item.*, id as item_id from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
|
||||
dbesc($test[0]['mid'])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -103,13 +103,13 @@ class Replies extends Controller
|
|||
http_status_exit(403, 'Forbidden');
|
||||
}
|
||||
|
||||
$parents_str = ids_to_querystr($i, 'item_id');
|
||||
xchan_query($i);
|
||||
|
||||
$sql_noAdd = ($zot6Hubloc) ? " and verb not in ('Add', 'Remove') " : '';
|
||||
|
||||
$items = q(
|
||||
"SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal $sql_noAdd and item_private = %d and item_deleted = 0 and uid = %d",
|
||||
dbesc($parents_str),
|
||||
"SELECT item.*, item.id AS item_id FROM item WHERE item.thr_parent = '%s' $item_normal $sql_noAdd and item_private = %d and item_deleted = 0 and uid = %d",
|
||||
dbesc($i[0]['mid']),
|
||||
intval($i[0]['item_private']),
|
||||
intval($i[0]['uid'])
|
||||
);
|
||||
|
@ -122,31 +122,31 @@ class Replies extends Controller
|
|||
$items = fetch_post_tags($items);
|
||||
|
||||
$observer = App::get_observer();
|
||||
$parent = $items[0];
|
||||
$parent = $i[0];
|
||||
$recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'], 'activitypub', 'recips', []) : []);
|
||||
$to = (($recips && array_key_exists('to', $recips) && is_array($recips['to'])) ? $recips['to'] : null);
|
||||
$nitems = [];
|
||||
foreach ($items as $i) {
|
||||
foreach ($items as $item) {
|
||||
$mids = [];
|
||||
|
||||
if (intval($i['item_private'])) {
|
||||
if (intval($item['item_private'])) {
|
||||
if (!$observer) {
|
||||
continue;
|
||||
}
|
||||
// ignore private reshare, possibly from hubzilla
|
||||
if ($i['verb'] === 'Announce') {
|
||||
if (!in_array($i['thr_parent'], $mids)) {
|
||||
$mids[] = $i['thr_parent'];
|
||||
if (!in_array($item['thr_parent'], $mids)) {
|
||||
$mids[] = $item['thr_parent'];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// also ignore any children of the private reshares
|
||||
if (in_array($i['thr_parent'], $mids)) {
|
||||
if (in_array($item['thr_parent'], $mids)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ($observer['xchan_hash'] !== $i['owner_xchan']) {
|
||||
if ($observer['xchan_hash'] !== $item['owner_xchan']) {
|
||||
if (empty($to)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -155,14 +155,14 @@ class Replies extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
$nitems[] = $i;
|
||||
$nitems[] = $item;
|
||||
}
|
||||
|
||||
if (!$nitems) {
|
||||
http_status_exit(404, 'Not found');
|
||||
}
|
||||
|
||||
$chan = Channel::from_id($nitems[0]['uid']);
|
||||
$chan = Channel::from_id($i[0]['uid']);
|
||||
|
||||
if (!$chan) {
|
||||
http_status_exit(404, 'Not found');
|
||||
|
@ -172,16 +172,16 @@ class Replies extends Controller
|
|||
http_status_exit(403, 'Forbidden');
|
||||
}
|
||||
|
||||
$i = ZlibActivity::encode_item_collection($nitems, 'conversation/' . $item_id, 'OrderedCollection', true, z_root() . '/channel/' . $chan['channel_address'], count($nitems));
|
||||
$i = ZlibActivity::encode_item_collection($nitems, 'replies/' . $item_mid, 'OrderedCollection', true, z_root() . '/channel/' . $chan['channel_address'], count($nitems));
|
||||
if ($portable_id && (!intval($items[0]['item_private']))) {
|
||||
ThreadListener::store(z_root() . '/activity/' . $item_id, $portable_id);
|
||||
ThreadListener::store(z_root() . '/activity/' . $item_mid, $portable_id);
|
||||
}
|
||||
|
||||
if (!$i) {
|
||||
http_status_exit(404, 'Not found');
|
||||
}
|
||||
|
||||
$channel = Channel::from_id($items[0]['uid']);
|
||||
$channel = Channel::from_id($i[0]['uid']);
|
||||
as_return_and_die($i, $channel);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue