improved wall-to-wall detection for comments so we can handle Diaspora signing and wall-to-wall attribution correctly.
Do it at the point of submission. This also fixes a potential bug in yesterday's wall-to-wall permission setting, if it was a local comment to a remote post.
This commit is contained in:
parent
902b5c52e5
commit
58c692e389
@ -2517,7 +2517,7 @@ function item_store_update($arr,$allow_exec = false) {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id) {
|
function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id, $walltowall = false) {
|
||||||
|
|
||||||
// We won't be able to sign Diaspora comments for authenticated visitors
|
// We won't be able to sign Diaspora comments for authenticated visitors
|
||||||
// - we don't have their private key
|
// - we don't have their private key
|
||||||
@ -2527,7 +2527,16 @@ function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id)
|
|||||||
require_once('include/bb2diaspora.php');
|
require_once('include/bb2diaspora.php');
|
||||||
$signed_body = bb2diaspora_itembody($datarray);
|
$signed_body = bb2diaspora_itembody($datarray);
|
||||||
|
|
||||||
logger('mod_item: storing diaspora comment signature',LOGGER_DEBUG);
|
if($walltowall) {
|
||||||
|
logger('wall to wall comment',LOGGER_DEBUG);
|
||||||
|
// post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author.
|
||||||
|
$signed_body = "\n\n"
|
||||||
|
. '[img]' . $datarray['author']['xchan_photo_m'] . '[/img]'
|
||||||
|
. '[url=' . $datarray['author']['xchan_url'] . ']' . $datarray['author']['xchan_name'] . '[/url]' . "\n\n"
|
||||||
|
. $signed_body;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger('storing diaspora comment signature',LOGGER_DEBUG);
|
||||||
|
|
||||||
$diaspora_handle = $channel['channel_address'] . '@' . get_app()->get_hostname();
|
$diaspora_handle = $channel['channel_address'] . '@' . get_app()->get_hostname();
|
||||||
|
|
||||||
|
22
mod/item.php
22
mod/item.php
@ -258,15 +258,26 @@ function item_post(&$a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$walltowall = false;
|
$walltowall = false;
|
||||||
|
$walltowall_comment = false;
|
||||||
|
|
||||||
if($observer) {
|
if($observer) {
|
||||||
logger('mod_item: post accepted from ' . $observer['xchan_name'] . ' for ' . $owner_xchan['xchan_name'], LOGGER_DEBUG);
|
logger('mod_item: post accepted from ' . $observer['xchan_name'] . ' for ' . $owner_xchan['xchan_name'], LOGGER_DEBUG);
|
||||||
if($observer['xchan_name'] != $owner_xchan['xchan_name'])
|
|
||||||
$walltowall = true;
|
// wall-to-wall detection.
|
||||||
|
// For top-level posts, if the author and owner are different it's a wall-to-wall
|
||||||
|
// For comments, We need to additionally look at the parent and see if it's a wall post that originated locally.
|
||||||
|
|
||||||
|
if($observer['xchan_name'] != $owner_xchan['xchan_name']) {
|
||||||
|
if($parent_item && ($parent_item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) {
|
||||||
|
$walltowall_comment = true;
|
||||||
|
$walltowall = true;
|
||||||
|
}
|
||||||
|
if(! $parent) {
|
||||||
|
$walltowall = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true));
|
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true));
|
||||||
if($webpage)
|
if($webpage)
|
||||||
$public_policy = '';
|
$public_policy = '';
|
||||||
@ -874,10 +885,9 @@ function item_post(&$a) {
|
|||||||
|
|
||||||
if($parent) {
|
if($parent) {
|
||||||
// Store the comment signature information in case we need to relay to Diaspora
|
// Store the comment signature information in case we need to relay to Diaspora
|
||||||
//FIXME
|
|
||||||
$ditem = $datarray;
|
$ditem = $datarray;
|
||||||
$ditem['author'] = $observer;
|
$ditem['author'] = $observer;
|
||||||
store_diaspora_comment_sig($ditem,$channel,$parent_item, $post_id);
|
store_diaspora_comment_sig($ditem,$channel,$parent_item, $post_id, (($walltowall_comment) ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
|
update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
|
||||||
|
Reference in New Issue
Block a user