revert extra Diaspora disabling changes to try to eliminate Mustard double-posting

This commit is contained in:
Zach Prezkuta 2012-06-12 18:38:24 -06:00
parent 8bb7ab88fb
commit c0c50ece0f
3 changed files with 23 additions and 43 deletions

View file

@ -113,7 +113,7 @@ function delivery_run($argv, $argc){
$uid = $r[0]['uid']; $uid = $r[0]['uid'];
$updated = $r[0]['edited']; $updated = $r[0]['edited'];
// The following seems superfluous. We've already checked for "if (! intval($r[0]['parent']))" a few lines up // POSSIBLE CLEANUP --> The following seems superfluous. We've already checked for "if (! intval($r[0]['parent']))" a few lines up
if(! $parent_id) if(! $parent_id)
continue; continue;
@ -492,9 +492,6 @@ function delivery_run($argv, $argc){
break; break;
case NETWORK_DIASPORA : case NETWORK_DIASPORA :
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
break;
if($public_message) if($public_message)
$loc = 'public batch ' . $contact['batch']; $loc = 'public batch ' . $contact['batch'];
else else
@ -502,6 +499,9 @@ function delivery_run($argv, $argc){
logger('delivery: diaspora batch deliver: ' . $loc); logger('delivery: diaspora batch deliver: ' . $loc);
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
break;
if((! $contact['pubkey']) && (! $public_message)) if((! $contact['pubkey']) && (! $public_message))
break; break;

View file

@ -383,11 +383,8 @@ function get_atom_elements($feed,$item) {
$res['app'] = 'OStatus'; $res['app'] = 'OStatus';
} }
// base64 encoded json structure representing Diaspora signature // base64 encoded json structure representing Diaspora signature
$dspr_enabled = intval(get_config('system','diaspora_enabled'));
if( $dspr_enabled) {
$dsig = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_signature'); $dsig = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_signature');
if($dsig) { if($dsig) {
$res['dsprsig'] = unxmlify($dsig[0]['data']); $res['dsprsig'] = unxmlify($dsig[0]['data']);
@ -396,8 +393,6 @@ function get_atom_elements($feed,$item) {
$dguid = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_guid'); $dguid = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_guid');
if($dguid) if($dguid)
$res['guid'] = unxmlify($dguid[0]['data']); $res['guid'] = unxmlify($dguid[0]['data']);
}
$bm = $item->get_item_tags(NAMESPACE_DFRN,'bookmark'); $bm = $item->get_item_tags(NAMESPACE_DFRN,'bookmark');
if($bm) if($bm)
@ -704,17 +699,13 @@ function item_store($arr,$force_parent = false) {
// If a Diaspora signature structure was passed in, pull it out of the // If a Diaspora signature structure was passed in, pull it out of the
// item array and set it aside for later storage. // item array and set it aside for later storage.
$dspr_enabled = intval(get_config('system','diaspora_enabled'));
$dsprsig = null; $dsprsig = null;
if(x($arr,'dsprsig')) { if(x($arr,'dsprsig')) {
if($dspr_enabled)
$dsprsig = json_decode(base64_decode($arr['dsprsig'])); $dsprsig = json_decode(base64_decode($arr['dsprsig']));
unset($arr['dsprsig']); unset($arr['dsprsig']);
} }
if(x($arr, 'gravity')) if(x($arr, 'gravity'))
$arr['gravity'] = intval($arr['gravity']); $arr['gravity'] = intval($arr['gravity']);
elseif($arr['parent-uri'] === $arr['uri']) elseif($arr['parent-uri'] === $arr['uri'])
@ -943,9 +934,7 @@ function item_store($arr,$force_parent = false) {
intval($parent_id) intval($parent_id)
); );
if($dsprsig) {
// Store the Diaspora signature if there is one
if($dspr_enabled && $dsprsig) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($current_post), intval($current_post),
dbesc($dsprsig->signed_text), dbesc($dsprsig->signed_text),
@ -1019,7 +1008,6 @@ function tag_deliver($uid,$item_id) {
$dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']); $dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER); $cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
if($cnt) { if($cnt) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
@ -2280,6 +2268,7 @@ function local_delivery($importer,$data) {
$is_a_remote_comment = false; $is_a_remote_comment = false;
// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`, $r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@ -2985,8 +2974,6 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
if($item['app']) if($item['app'])
$o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n"; $o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n";
$dspr_enabled = intval(get_config('system','diaspora_enabled'));
if( $dspr_enabled) {
if($item['guid']) if($item['guid'])
$o .= '<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>' . "\r\n"; $o .= '<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>' . "\r\n";
@ -2994,7 +2981,6 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer']))); $sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
$o .= '<dfrn:diaspora_signature>' . xmlify($sign) . '</dfrn:diaspora_signature>' . "\r\n"; $o .= '<dfrn:diaspora_signature>' . xmlify($sign) . '</dfrn:diaspora_signature>' . "\r\n";
} }
}
$verb = construct_verb($item); $verb = construct_verb($item);
$o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n"; $o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n";
@ -3332,9 +3318,7 @@ function drop_item($id,$interactive = true) {
// ignore the result // ignore the result
} }
// clean up item_id and sign (Diaspora signature) meta-data tables // clean up item_id and sign meta-data tables
// Clean up the sign table even if Diaspora support is disabled. We may still need to
// clean it up if Diaspora support had been enabled in the past
$r = q("DELETE FROM item_id where iid in (select id from item where parent = %d and uid = %d)", $r = q("DELETE FROM item_id where iid in (select id from item where parent = %d and uid = %d)",
intval($item['id']), intval($item['id']),

View file

@ -125,7 +125,7 @@ function notifier_run($argv, $argc){
$uid = $r[0]['uid']; $uid = $r[0]['uid'];
$updated = $r[0]['edited']; $updated = $r[0]['edited'];
// The following seems superfluous. We've already checked for "if (! intval($r[0]['parent']))" a few lines up // POSSIBLE CLEANUP --> The following seems superfluous. We've already checked for "if (! intval($r[0]['parent']))" a few lines up
if(! $parent_id) if(! $parent_id)
return; return;
@ -709,11 +709,11 @@ function notifier_run($argv, $argc){
} }
break; break;
case NETWORK_DIASPORA: case NETWORK_DIASPORA:
require_once('include/diaspora.php');
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled'))) if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')))
break; break;
require_once('include/diaspora.php');
if($mail) { if($mail) {
diaspora_send_mail($item,$owner,$contact); diaspora_send_mail($item,$owner,$contact);
break; break;
@ -860,17 +860,13 @@ function notifier_run($argv, $argc){
} }
// If the item was deleted, clean up the `sign` table
// If the item was deleted, clean up the `sign` table (for Diaspora signatures)
// Do this even if Diaspora support is disabled, as it may have been enabled in
// the past
if($target_item['deleted']) { if($target_item['deleted']) {
$r = q("DELETE FROM sign where `retract_iid` = %d", $r = q("DELETE FROM sign where `retract_iid` = %d",
intval($target_item['id']) intval($target_item['id'])
); );
} }
logger('notifier: calling hooks', LOGGER_DEBUG); logger('notifier: calling hooks', LOGGER_DEBUG);
if($normal_mode) if($normal_mode)