heavy lifting on diaspora likes. Still needs much more work - especially as we're ignoring signatures at this time
This commit is contained in:
parent
e4e9098f39
commit
384eace32a
@ -1776,6 +1776,13 @@ function diaspora_like($importer,$xml,$msg) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$i = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||||
|
dbesc($parent_item['author_xchan'])
|
||||||
|
);
|
||||||
|
if($i)
|
||||||
|
$item_author = $i[0];
|
||||||
|
|
||||||
// Note: I don't think "Like" objects with positive = "false" are ever actually used
|
// Note: I don't think "Like" objects with positive = "false" are ever actually used
|
||||||
// It looks like "RelayableRetractions" are used for "unlike" instead
|
// It looks like "RelayableRetractions" are used for "unlike" instead
|
||||||
if($positive === 'false') {
|
if($positive === 'false') {
|
||||||
@ -1808,12 +1815,12 @@ function diaspora_like($importer,$xml,$msg) {
|
|||||||
$parent_author_signature = base64_decode($parent_author_signature);
|
$parent_author_signature = base64_decode($parent_author_signature);
|
||||||
|
|
||||||
if(! rsa_verify($signed_data,$parent_author_signature,$key,'sha256')) {
|
if(! rsa_verify($signed_data,$parent_author_signature,$key,'sha256')) {
|
||||||
if (intval(get_config('system','ignore_diaspora_like_signature')))
|
// if (intval(get_config('system','ignore_diaspora_like_signature')))
|
||||||
logger('diaspora_like: top-level owner verification failed. Proceeding anyway.');
|
logger('diaspora_like: top-level owner verification failed. Proceeding anyway.');
|
||||||
else {
|
// else {
|
||||||
logger('diaspora_like: top-level owner verification failed.');
|
// logger('diaspora_like: top-level owner verification failed.');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1825,12 +1832,12 @@ function diaspora_like($importer,$xml,$msg) {
|
|||||||
$author_signature = base64_decode($author_signature);
|
$author_signature = base64_decode($author_signature);
|
||||||
|
|
||||||
if(! rsa_verify($signed_data,$author_signature,$key,'sha256')) {
|
if(! rsa_verify($signed_data,$author_signature,$key,'sha256')) {
|
||||||
if (intval(get_config('system','ignore_diaspora_like_signature')))
|
// if (intval(get_config('system','ignore_diaspora_like_signature')))
|
||||||
logger('diaspora_like: like creator verification failed. Proceeding anyway');
|
logger('diaspora_like: like creator verification failed. Proceeding anyway');
|
||||||
else {
|
// else {
|
||||||
logger('diaspora_like: like creator verification failed.');
|
// logger('diaspora_like: like creator verification failed.');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1853,93 +1860,75 @@ function diaspora_like($importer,$xml,$msg) {
|
|||||||
$uri = $diaspora_handle . ':' . $guid;
|
$uri = $diaspora_handle . ':' . $guid;
|
||||||
|
|
||||||
$activity = ACTIVITY_LIKE;
|
$activity = ACTIVITY_LIKE;
|
||||||
$post_type = (($parent_item['resource-id']) ? t('photo') : t('status'));
|
|
||||||
$objtype = (($parent_item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
|
$post_type = (($parent_item['resource_type'] === 'photo') ? t('photo') : t('status'));
|
||||||
$link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . '" />' . "\n") ;
|
|
||||||
|
$links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $parent_item['plink']));
|
||||||
|
$objtype = (($parent_item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
|
||||||
|
|
||||||
$body = $parent_item['body'];
|
$body = $parent_item['body'];
|
||||||
|
|
||||||
$obj = <<< EOT
|
|
||||||
|
|
||||||
<object>
|
$object = json_encode(array(
|
||||||
<type>$objtype</type>
|
'type' => $post_type,
|
||||||
<local>1</local>
|
'id' => $parent_item['mid'],
|
||||||
<id>{$parent_item['uri']}</id>
|
'parent' => (($parent_item['thr_parent']) ? $parent_item['thr_parent'] : $parent_item['parent_mid']),
|
||||||
<link>$link</link>
|
'link' => $links,
|
||||||
<title></title>
|
'title' => $parent_item['title'],
|
||||||
<content>$body</content>
|
'content' => $parent_item['body'],
|
||||||
</object>
|
'created' => $parent_item['created'],
|
||||||
EOT;
|
'edited' => $parent_item['edited'],
|
||||||
|
'author' => array(
|
||||||
|
'name' => $item_author['xchan_name'],
|
||||||
|
'address' => $item_author['xchan_addr'],
|
||||||
|
'guid' => $item_author['xchan_guid'],
|
||||||
|
'guid_sig' => $item_author['xchan_guid_sig'],
|
||||||
|
'link' => array(
|
||||||
|
array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item_author['xchan_url']),
|
||||||
|
array('rel' => 'photo', 'type' => $item_author['xchan_photo_mimetype'], 'href' => $item_author['xchan_photo_m'])),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
$bodyverb = t('%1$s likes %2$s\'s %3$s');
|
$bodyverb = t('%1$s likes %2$s\'s %3$s');
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
|
|
||||||
$arr['uri'] = $uri;
|
$arr['uri'] = $uri;
|
||||||
$arr['uid'] = $importer['channel_id'];
|
$arr['uid'] = $importer['channel_id'];
|
||||||
$arr['guid'] = $guid;
|
$arr['aid'] = $importer['channel_account_id'];
|
||||||
$arr['network'] = NETWORK_DIASPORA;
|
$arr['mid'] = $guid;
|
||||||
$arr['contact-id'] = $contact['id'];
|
$arr['parent_mid'] = $parent_item['mid'];
|
||||||
$arr['type'] = 'activity';
|
$arr['owner_xchan'] = $parent_item['owner_xchan'];
|
||||||
$arr['wall'] = $parent_item['wall'];
|
$arr['author_xchan'] = $person['xchan_hash'];
|
||||||
$arr['gravity'] = GRAVITY_LIKE;
|
|
||||||
$arr['parent'] = $parent_item['id'];
|
|
||||||
$arr['parent-uri'] = $parent_item['uri'];
|
|
||||||
|
|
||||||
$arr['owner-name'] = $parent_item['name'];
|
|
||||||
$arr['owner-link'] = $parent_item['url'];
|
|
||||||
//$arr['owner-avatar'] = $parent_item['thumb'];
|
|
||||||
$arr['owner-avatar'] = ((x($parent_item,'thumb')) ? $parent_item['thumb'] : $parent_item['photo']);
|
|
||||||
|
|
||||||
$arr['author-name'] = $person['name'];
|
|
||||||
$arr['author-link'] = $person['url'];
|
|
||||||
$arr['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
|
|
||||||
|
|
||||||
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
|
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
|
||||||
$alink = '[url=' . $parent_item['author-link'] . ']' . $parent_item['author-name'] . '[/url]';
|
$alink = '[url=' . $parent_item['author-link'] . ']' . $parent_item['author-name'] . '[/url]';
|
||||||
//$plink = '[url=' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . ']' . $post_type . '[/url]';
|
$plink = '[url='. z_root() .'/display/'.$guid.']'.$post_type.'[/url]';
|
||||||
$plink = '[url='.$a->get_baseurl().'/display/'.$guid.']'.$post_type.'[/url]';
|
|
||||||
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
|
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
|
||||||
|
|
||||||
$arr['app'] = 'Diaspora';
|
$arr['app'] = 'Diaspora';
|
||||||
|
|
||||||
$arr['private'] = $parent_item['private'];
|
$arr['item_private'] = $parent_item['item_private'];
|
||||||
$arr['verb'] = $activity;
|
$arr['verb'] = $activity;
|
||||||
$arr['object-type'] = $objtype;
|
$arr['object-type'] = $objtype;
|
||||||
$arr['object'] = $obj;
|
$arr['object'] = $object;
|
||||||
$arr['visible'] = 1;
|
|
||||||
$arr['unseen'] = 1;
|
|
||||||
$arr['last-child'] = 0;
|
|
||||||
|
|
||||||
if(! $parent_author_signature) {
|
if(! $parent_author_signature) {
|
||||||
$datarray['diaspora_meta'] = array('signer' => $diaspora_handle, 'body' => $text,
|
$datarray['diaspora_meta'] = array('signer' => $diaspora_handle, 'body' => $text,
|
||||||
'signed_text' => $signed_data, 'signature' => base64_encode($author_signature));
|
'signed_text' => $signed_data, 'signature' => base64_encode($author_signature));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$x = item_store($arr);
|
||||||
|
|
||||||
$message_id = item_store($arr);
|
if($x)
|
||||||
|
$message_id = $x['item_id'];
|
||||||
|
|
||||||
//if($message_id) {
|
|
||||||
// q("update item set plink = '%s' where id = %d",
|
|
||||||
// //dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
|
|
||||||
// dbesc($a->get_baseurl().'/display/'.$guid),
|
|
||||||
// intval($message_id)
|
|
||||||
// );
|
|
||||||
//}
|
|
||||||
|
|
||||||
if(! $parent_author_signature) {
|
|
||||||
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
|
|
||||||
intval($message_id),
|
|
||||||
dbesc($signed_data),
|
|
||||||
dbesc(base64_encode($author_signature)),
|
|
||||||
dbesc($diaspora_handle)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the message isn't already being relayed, notify others
|
// if the message isn't already being relayed, notify others
|
||||||
// the existence of parent_author_signature means the parent_author or owner
|
// the existence of parent_author_signature means the parent_author or owner
|
||||||
// is already relaying. The parent_item['origin'] indicates the message was created on our system
|
// is already relaying. The parent_item['origin'] indicates the message was created on our system
|
||||||
|
|
||||||
if(($parent_item['origin']) && (! $parent_author_signature))
|
if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature))
|
||||||
proc_run('php','include/notifier.php','comment-import',$message_id);
|
proc_run('php','include/notifier.php','comment-import',$message_id);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user