diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index e09a8fc0b..af3fa3340 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1416,7 +1416,7 @@ class Activity { if(is_array($act->obj)) { $content = self::get_content($act->obj); } - + $s['owner_xchan'] = $act->actor['id']; $s['author_xchan'] = $act->actor['id']; @@ -1577,6 +1577,11 @@ class Activity { $item['aid'] = $channel['channel_account_id']; $item['uid'] = $channel['channel_id']; + if(! ( $item['author_xchan'] && $item['owner_xchan'])) { + logger('owner or author missing.'); + return; + } + if($channel['channel_system']) { if(! \Zotlabs\Lib\MessageFilter::evaluate($item,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) { logger('post is filtered'); @@ -1610,8 +1615,16 @@ class Activity { ); if(! $p) { $a = (($fetch_parents) ? self::fetch_and_store_parents($channel,$observer_hash,$act,$item) : false); - // if no parent was fetched, turn into a top-level post - if(! $a) { + if($a) { + $p = q("select parent_mid from item where mid = '%s' and uid = %d limit 1", + dbesc($item['parent_mid']), + intval($item['uid']) + ); + } + else { + + // if no parent was fetched, turn into a top-level post + // @TODO we maybe could accept these is we formatted the body correctly with share_bb() // or at least provided a link to the object if(in_array($act->type,[ 'Like','Dislike' ])) { diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 1025a2bf0..e7a5ad1f7 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -82,23 +82,28 @@ class ActivityStreams { if($this->ldsig) { $this->signer = $this->get_compound_property('creator',$this->ldsig); if($this->signer && $this->signer['publicKey'] && $this->signer['publicKey']['publicKeyPem']) { - $this->sigok = \Zotlabs\Lib\LDSignatures::verify($this->data,$this->signer['publicKey']['publicKeyPem']); + $this->sigok = LDSignatures::verify($this->data,$this->signer['publicKey']['publicKeyPem']); } } + if(! $this->obj) { + $this->obj = $this->data; + $this->type = 'Create'; + if(! $this->actor) { + $this->actor = $this->get_actor('attributedTo',$this->obj); + } + } + if($this->obj && $this->obj['actor']) $this->obj['actor'] = $this->get_actor('actor',$this->obj); if($this->tgt && $this->tgt['actor']) $this->tgt['actor'] = $this->get_actor('actor',$this->tgt); - - if(! $this->obj) { - $this->obj = $this->data; - $this->type = 'Create'; - } - $this->parent_id = $this->get_property_obj('inReplyTo'); if(! $this->parent_id) { + $this->parent_id = $this->get_property_obj('inReplyTo',$this->obj); + } + if(! $this->parent_id) { $this->parent_id = $this->obj['id']; } } @@ -252,9 +257,11 @@ class ActivityStreams { $x = z_fetch_url($url, true, $redirects, [ 'headers' => [ 'Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ]]); - if($x['success']) + if($x['success']) { + $y = json_decode($x['body'],true); + logger('returned: ' . json_encode($y,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); return json_decode($x['body'], true); - + } return null; } diff --git a/Zotlabs/Module/Inbox.php b/Zotlabs/Module/Inbox.php index be97becef..7ced0e4aa 100644 --- a/Zotlabs/Module/Inbox.php +++ b/Zotlabs/Module/Inbox.php @@ -67,6 +67,20 @@ class Inbox extends Controller { $channels = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network = 'activitypub' and xchan_hash = '%s' ) and channel_removed = 0 ", dbesc($observer_hash) ); + if(! $channels) { + $channels = []; + } + + $parent = $AS->parent_id; + if($parent) { + //this is a comment - deliver to everybody who owns the parent + $owners = q("SELECT * from channel where channel_id in ( SELECT uid from item where mid = '%s' ) ", + dbesc($parent) + ); + if($owners) { + $channels = array_merge($channels,$owners); + } + } } if($channels === false)