diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 544dd6f20..768da47d8 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1473,19 +1473,6 @@ class Activity { $s['mid'] = $act->obj['id']; $s['parent_mid'] = $act->parent_id; - if(in_array($act->type, [ 'Like','Dislike' ])) { - $s['mid'] = $act->id; - $s['parent_mid'] = $act->obj['id']; - - // This needs better formatting with proper names - if($act->type === 'Like') { - $content['content'] = sprintf('%1$s Likes %2$s\'s %3$s',$act->actor['id'],$act->obj['actor']['id'],$act->obj['type']) . "\n\n" . $content['content']; - } - if($act->type === 'Dislike') { - $content['content'] = sprintf('%1$s Doesn\'t like %2$s\'s %3$s',$act->actor['id'],$act->obj['actor']['id'],$act->obj['type']) . "\n\n" . $content['content']; - } - } - if($act->data['published']) { $s['created'] = datetime_convert('UTC','UTC',$act->data['published']); } @@ -1499,15 +1486,39 @@ class Activity { $s['edited'] = datetime_convert('UTC','UTC',$act->obj['updated']); } - if(! $s['created']) - $s['created'] = datetime_convert(); - if(! $s['edited']) - $s['edited'] = $s['created']; + if(in_array($act->type, [ 'Like','Dislike' ])) { + $s['mid'] = $act->id; + $s['parent_mid'] = $act->obj['id']; + + // over-ride the object timestamp with the activity + + if($act->data['published']) { + $s['created'] = datetime_convert('UTC','UTC',$act->data['published']); + } + + // This needs better formatting with proper names + if($act->type === 'Like') { + $content['content'] = sprintf('%1$s Likes %2$s\'s %3$s',$act->actor['id'],$act->obj['actor']['id'],$act->obj['type']) . "\n\n" . $content['content']; + } + if($act->type === 'Dislike') { + $content['content'] = sprintf('%1$s Doesn\'t like %2$s\'s %3$s',$act->actor['id'],$act->obj['actor']['id'],$act->obj['type']) . "\n\n" . $content['content']; + } + } if(in_array($act->type,['Announce'])) { $s['mid'] = $act->id; $s['parent_mid'] = $act->id; + + // over-ride the object timestamp with the activity + + if($act->data['published']) { + $s['created'] = datetime_convert('UTC','UTC',$act->data['published']); + } + if($act->data['updated']) { + $s['edited'] = datetime_convert('UTC','UTC',$act->data['updated']); + } + $announced_actor = ((isset($act->obj['actor'])) ? $act->obj['actor'] : $act->get_actor('attributedTo', $act->obj)); if(! $announced_actor) { return []; @@ -1516,6 +1527,12 @@ class Activity { $s['author_xchan'] = $announced_actor['id']; } + if(! $s['created']) + $s['created'] = datetime_convert(); + + if(! $s['edited']) + $s['edited'] = $s['created']; + $s['title'] = self::bb_content($content,'name'); $s['summary'] = self::bb_content($content,'summary'); $s['body'] = (self::bb_content($content,'bbcode') ? : self::bb_content($content,'content')); @@ -1573,24 +1590,37 @@ class Activity { ]; $mps = []; - if(array_key_exists('url',$act->obj) && is_array($act->obj['url'])) { - foreach($act->obj['url'] as $vurl) { - if(in_array($vurl['mimeType'], $vtypes)) { - if(! array_key_exists('width',$vurl)) { - $vurl['width'] = 0; + $ptr = null; + + if(array_key_exists('url',$act->obj)) { + if(is_array($act->obj['url'])) { + if(array_key_exists(0,$act->obj['url'])) { + $ptr = $act->obj['url']; + } + else { + $ptr = [ $act->obj['url'] ]; + } + foreach($ptr as $vurl) { + if(in_array($vurl['mediaType'], $vtypes)) { + if(! array_key_exists('width',$vurl)) { + $vurl['width'] = 0; + } + $mps[] = $vurl; } - $mps[] = $vurl; } } - } - if($mps) { - usort($mps,[ __CLASS__, 'vid_sort' ]); - foreach($mps as $m) { - if(intval($m['width']) < 500) { - $s['body'] .= "\n\n" . '[video]' . $m['href'] . '[/video]'; - break; + if($mps) { + usort($mps,[ __CLASS__, 'vid_sort' ]); + foreach($mps as $m) { + if(intval($m['width']) < 500) { + $s['body'] .= "\n\n" . '[video]' . $m['href'] . '[/video]'; + break; + } } } + elseif(is_string($act->obj['url'])) { + $s['body'] .= "\n\n" . '[video]' . $act->obj['url'] . '[/video]'; + } } } @@ -1602,28 +1632,84 @@ class Activity { 'audio/wav' ]; - if(array_key_exists('url',$act->obj) && is_array($act->obj['url'])) { - foreach($act->obj['url'] as $vurl) { - if(in_array($vurl['mimeType'], $atypes)) { - $s['body'] .= "\n\n" . '[audio]' . $vurl['href'] . '[/audio]'; - break; + $ptr = null; + + if(array_key_exists('url',$act->obj)) { + if(is_array($act->obj['url'])) { + if(array_key_exists(0,$act->obj['url'])) { + $ptr = $act->obj['url']; + } + else { + $ptr = [ $act->obj['url'] ]; + } + foreach($ptr as $vurl) { + if(in_array($vurl['mediaType'], $atypes)) { + $s['body'] .= "\n\n" . '[audio]' . $vurl['href'] . '[/audio]'; + break; + } } } + elseif(is_string($act->obj['url'])) { + $s['body'] .= "\n\n" . '[audio]' . $act->obj['url'] . '[/audio]'; + } } + } if($act->obj['type'] === 'Image') { - if(array_key_exists('url',$act->obj) && is_array($act->obj['url'])) { - foreach($act->obj['url'] as $vurl) { - if(strpos($s['body'],$vurl['href']) === false) { - $s['body'] .= "\n\n" . '[zmg]' . $vurl['href'] . '[/zmg]'; - break; + + $ptr = null; + + if(array_key_exists('url',$act->obj)) { + if(is_array($act->obj['url'])) { + if(array_key_exists(0,$act->obj['url'])) { + $ptr = $act->obj['url']; + } + else { + $ptr = [ $act->obj['url'] ]; + } + foreach($ptr as $vurl) { + if(strpos($s['body'],$vurl['href']) === false) { + $s['body'] .= "\n\n" . '[zmg]' . $vurl['href'] . '[/zmg]'; + break; + } + } + } + elseif(is_string($act->obj['url'])) { + if(strpos($s['body'],$act->obj['url']) === false) { + $s['body'] .= "\n\n" . '[zmg]' . $act->obj['url'] . '[/zmg]'; } } } } + if(in_array($act->obj['type'],[ 'Note','Article' ])) { + $ptr = null; + if(array_key_exists('url',$act->obj)) { + if(is_array($act->obj['url'])) { + if(array_key_exists(0,$act->obj['url'])) { + $ptr = $act->obj['url']; + } + else { + $ptr = [ $act->obj['url'] ]; + } + foreach($ptr as $vurl) { + if(array_key_exists('mediaType',$vurl) && $vurl['mediaType'] === 'text/plain') { + $s['plink'] = $vurl['href']; + break; + } + } + } + elseif(is_string($act->obj['url'])) { + $s['plink'] = $act->obj['url']; + } + } + } + + if(! $s['plink']) { + $s['plink'] = $s['mid']; + } if($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips))) $s['item_private'] = 1; diff --git a/library/jsonld/jsonld.php b/library/jsonld/jsonld.php index 28b3e7ce3..8cd3e7ceb 100644 --- a/library/jsonld/jsonld.php +++ b/library/jsonld/jsonld.php @@ -4301,7 +4301,7 @@ class JsonLdProcessor { sort($nquads); // cache and return hashed quads - $hash = $bnodes->{$id}->hash = sha1(implode($nquads)); + $hash = $bnodes->{$id}->hash = hash('sha256',implode($nquads)); return $hash; } @@ -4320,8 +4320,8 @@ class JsonLdProcessor { * @return stdClass the hash and path namer used. */ protected function _hashPaths($id, $bnodes, $namer, $path_namer) { - // create SHA-1 digest - $md = hash_init('sha1'); + // create digest + $md = hash_init('sha256'); // group adjacent bnodes by hash, keep properties and references separate $groups = new stdClass(); @@ -4350,7 +4350,7 @@ class JsonLdProcessor { } // hash direction, property, and bnode name/hash - $group_md = hash_init('sha1'); + $group_md = hash_init('sha256'); hash_update($group_md, $direction); hash_update($group_md, $quad->predicate->value); hash_update($group_md, $name); @@ -4433,7 +4433,7 @@ class JsonLdProcessor { $path_namer = $chosen_namer; } - // return SHA-1 hash and path namer + // return hash and path namer return (object)array( 'hash' => hash_final($md), 'pathNamer' => $path_namer); } diff --git a/view/js/main.js b/view/js/main.js index f0bdc5f5a..296037bd5 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -267,7 +267,7 @@ function commentAuthors(id) { $("#comment-edit-text-" + id).addClass("expanded"); openMenu("comment-tools-" + id); } - $("#comment-edit-text-" + id).val(tmpStr + auths); + $("#comment-edit-text-" + id).val(auths + ' ' + tmpStr); } }