directory sync issues

This commit is contained in:
friendica 2014-03-03 21:00:42 -08:00
parent cdd2e9cd95
commit 3d49bf0320
5 changed files with 28 additions and 14 deletions

View File

@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 ); define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1101 ); define ( 'DB_UPDATE_VERSION', 1102 );
define ( 'EOL', '<br />' . "\r\n" ); define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
@ -323,11 +323,10 @@ define ( 'POLL_OVERWRITE', 0x8000); // If you vote twice remove the prior
define ( 'UPDATE_FLAGS_UPDATED', 0x0001); define ( 'UPDATE_FLAGS_UPDATED', 0x0001);
define ( 'UPDATE_FLAGS_FORCED', 0x0002);
define ( 'UPDATE_FLAGS_DELETED', 0x1000); define ( 'UPDATE_FLAGS_DELETED', 0x1000);
/** /**
* Maximum number of "people who like (or don't like) this" that we will list by name * Maximum number of "people who like (or don't like) this" that we will list by name
*/ */

View File

@ -101,6 +101,9 @@ function sync_directories($dirmode) {
$ud_flags = 0; $ud_flags = 0;
if(is_array($t['flags']) && in_array('deleted',$t['flags'])) if(is_array($t['flags']) && in_array('deleted',$t['flags']))
$ud_flags |= UPDATE_FLAGS_DELETED; $ud_flags |= UPDATE_FLAGS_DELETED;
if(is_array($t['flags']) && in_array('forced',$t['flags']))
$ud_flags |= UPDATE_FLAGS_FORCED;
$z = q("insert into updates ( ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) $z = q("insert into updates ( ud_hash, ud_guid, ud_date, ud_flags, ud_addr )
values ( '%s', '%s', '%s', %d, '%s' ) ", values ( '%s', '%s', '%s', %d, '%s' ) ",
dbesc($t['hash']), dbesc($t['hash']),

View File

@ -305,7 +305,7 @@ function zot_refresh($them,$channel = null, $force = false) {
return false; return false;
} }
$x = import_xchan($j,(($force) ? (-1) : 1)); $x = import_xchan($j,(($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED));
if(! $x['success']) if(! $x['success'])
return false; return false;
@ -538,14 +538,14 @@ function zot_register_hub($arr) {
/** /**
* @function import_xchan($arr,$ud_flags = 1) * @function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED)
* Takes an associative array of a fetched discovery packet and updates * Takes an associative array of a fetched discovery packet and updates
* all internal data structures which need to be updated as a result. * all internal data structures which need to be updated as a result.
* *
* @param array $arr => json_decoded discovery packet * @param array $arr => json_decoded discovery packet
* @param int $ud_flags * @param int $ud_flags
* Determines whether to create a directory update record if any changes occur, default 1 or true * Determines whether to create a directory update record if any changes occur, default is UPDATE_FLAGS_UPDATED (true)
* $ud_flags = (-1) indicates a forced refresh where we unconditionally create a directory update record * $ud_flags = UPDATE_FLAGS_FORCED indicates a forced refresh where we unconditionally create a directory update record
* this typically occurs once a month for each channel as part of a scheduled ping to notify the directory * this typically occurs once a month for each channel as part of a scheduled ping to notify the directory
* that the channel still exists * that the channel still exists
* *
@ -553,7 +553,7 @@ function zot_register_hub($arr) {
* 'message' (optional error string only if success is false) * 'message' (optional error string only if success is false)
*/ */
function import_xchan($arr,$ud_flags = 1) { function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) {
call_hooks('import_xchan', $arr); call_hooks('import_xchan', $arr);
@ -912,7 +912,7 @@ function import_xchan($arr,$ud_flags = 1) {
} }
} }
if(($changed) || ($ud_flags == (-1))) { if(($changed) || ($ud_flags == UPDATE_FLAGS_FORCED)) {
$guid = random_string() . '@' . get_app()->get_hostname(); $guid = random_string() . '@' . get_app()->get_hostname();
update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags); update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags);
logger('import_xchan: changed: ' . $what,LOGGER_DEBUG); logger('import_xchan: changed: ' . $what,LOGGER_DEBUG);
@ -1644,7 +1644,7 @@ function process_profile_delivery($sender,$arr,$deliveries) {
dbesc($sender['hash']) dbesc($sender['hash'])
); );
if($r) if($r)
import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], 1, 0); import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], UPDATE_FLAGS_UPDATED, 0);
} }
@ -1655,7 +1655,7 @@ function process_profile_delivery($sender,$arr,$deliveries) {
* *
*/ */
function import_directory_profile($hash,$profile,$addr,$ud_flags = 1, $suppress_update = 0) { function import_directory_profile($hash,$profile,$addr,$ud_flags = UPDATE_FLAGS_UPDATED, $suppress_update = 0) {
logger('import_directory_profile', LOGGER_DEBUG); logger('import_directory_profile', LOGGER_DEBUG);
if(! $hash) if(! $hash)

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1101 ); define( 'UPDATE_VERSION' , 1102 );
/** /**
* *
@ -1143,4 +1143,11 @@ ADD INDEX ( `xchat_edited` ) ");
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
return UPDATE_FAILED; return UPDATE_FAILED;
} }
function update_r1101() {
$r = q("update updates set ud_flags = 2 where ud_flags = (-1)");
$r = q("update updates set ud_flags = 0 where ud_flags = 4096");
return UPDATE_SUCCESS;
}

View File

@ -159,7 +159,12 @@ function dirsearch_content(&$a) {
); );
if($r) { if($r) {
foreach($r as $rr) { foreach($r as $rr) {
$flags = (($rr['ud_flags'] & UPDATE_FLAGS_DELETED) ? array('deleted') : array()); $flags = array();
if($rr['ud_flags'] & UPDATE_FLAGS_DELETED)
$flags[] = 'deleted';
if($rr['ud_flags'] & UPDATE_FLAGS_FORCED)
$flags[] = 'forced';
$spkt['transactions'][] = array( $spkt['transactions'][] = array(
'hash' => $rr['ud_hash'], 'hash' => $rr['ud_hash'],
'address' => $rr['ud_addr'], 'address' => $rr['ud_addr'],