mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
more testing of collections
This commit is contained in:
parent
bb01687aa3
commit
cfa14a6fbf
4 changed files with 23 additions and 13 deletions
|
@ -363,6 +363,10 @@ class Activity
|
|||
$t = json_decode($m, true);
|
||||
} else {
|
||||
$t = self::encode_activity($i, $activitypub);
|
||||
if (!$t['proof']) {
|
||||
$channel = Channel::from_hash($i['author_xchan']);
|
||||
$t['proof'] = (new JcsEddsa2022())->sign($t, $channel);
|
||||
}
|
||||
}
|
||||
if ($t) {
|
||||
$x[] = $t;
|
||||
|
|
|
@ -1208,9 +1208,10 @@ class Libzot
|
|||
// This is a relayed/forwarded Activity (as opposed to a shared/boosted object)
|
||||
// Reparse the encapsulated Activity and use that instead
|
||||
logger('relayed activity', LOGGER_DEBUG);
|
||||
$AS = new ActivityStreams($AS->obj, portable_id: $env['sender']);
|
||||
$AS = new ActivityStreams($AS->raw['object'], portable_id: $env['sender']);
|
||||
}
|
||||
// process add/remove from collection separately, as it requires a target.
|
||||
// use the raw object, as it will not include actor expansion
|
||||
if (in_array($AS->type, ['Add', 'Remove'])
|
||||
&& is_array($AS->obj)
|
||||
&& array_key_exists('object', $AS->obj)
|
||||
|
@ -1218,7 +1219,7 @@ class Libzot
|
|||
&& !empty($AS->tgt)) {
|
||||
logger('relayed collection operation', LOGGER_DEBUG);
|
||||
$isCollectionOperation = true;
|
||||
$AS = new ActivityStreams($AS->obj, portable_id: $env['sender']);
|
||||
$AS = new ActivityStreams($AS->raw['object'], portable_id: $env['sender']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -31,17 +31,17 @@ class Conversation extends Controller
|
|||
|
||||
// do we have the item (at all)?
|
||||
|
||||
$r = q(
|
||||
$test = q(
|
||||
"select * from item where mid = '%s' $item_normal limit 1",
|
||||
dbesc(z_root() . '/activity/' . $item_id)
|
||||
);
|
||||
|
||||
if (!$r) {
|
||||
$r = q(
|
||||
if (!$test) {
|
||||
$test = q(
|
||||
"select * from item where mid = '%s' $item_normal limit 1",
|
||||
dbesc(z_root() . '/item/' . $item_id)
|
||||
);
|
||||
if (!$r) {
|
||||
if (!$test) {
|
||||
http_status_exit(404, 'Not found');
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ class Conversation extends Controller
|
|||
if ($xchans) {
|
||||
$hashes = ids_to_querystr($xchans, 'xchan_hash', true);
|
||||
$i = q(
|
||||
"select id as item_id from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1",
|
||||
dbesc($r[0]['parent_mid'])
|
||||
"select id as item_id, item_private from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1",
|
||||
dbesc($test[0]['parent_mid'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ class Conversation extends Controller
|
|||
|
||||
if (!$i) {
|
||||
$i = q(
|
||||
"select id as item_id from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
|
||||
dbesc($r[0]['parent_mid'])
|
||||
"select id as item_id from item, item_private where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
|
||||
dbesc($test[0]['parent_mid'])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,9 @@ class Conversation extends Controller
|
|||
$parents_str = ids_to_querystr($i, 'item_id');
|
||||
|
||||
$items = q(
|
||||
"SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal ",
|
||||
dbesc($parents_str)
|
||||
"SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal and verb = 'Add' and item_private = %d",
|
||||
dbesc($parents_str),
|
||||
intval($i[0]['item_private'])
|
||||
);
|
||||
|
||||
if (!$items) {
|
||||
|
|
|
@ -1823,7 +1823,11 @@ class Item extends Controller
|
|||
elseif ($channel['channel_hash'] === $datarray['owner_xchan'] && $datarray['verb'] !== 'Add') {
|
||||
$items = [$datarray];
|
||||
xchan_query($items);
|
||||
Activity::addToCollection($channel, Activity::encode_activity(array_shift($items), true), $datarray['parent_mid'], $datarray);
|
||||
for ($x = 0; $x < count($items); $x ++) {
|
||||
$items[$x] = array_merge(Activity::ap_context(), Activity::encode_activity($items[$x]));
|
||||
$items[$x]['proof'] = (new JcsEddsa2022())->sign($items[$x], $channel);
|
||||
}
|
||||
Activity::addToCollection($channel, array_shift($items), $datarray['parent_mid'], $datarray);
|
||||
|
||||
// @fixme: if this is a local top-level post, sign the original but don't deliver it.!!!
|
||||
|
||||
|
|
Loading…
Reference in a new issue