From 7ce4175876ce13727432dc839938bb8e486ef406 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 09:29:51 +0200 Subject: initial commit directory sync rewrite - should work but still requires lots of cleanup --- Zotlabs/Lib/Libzot.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index a8334595f..b41ba043a 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -920,11 +920,11 @@ class Libzot { $s = Libsync::sync_locations($arr, $arr); if ($s) { - if (isset($s['change_message'])) + if (!empty($s['change_message'])) $what .= $s['change_message']; - if (isset($s['changed'])) + if (!empty($s['changed'])) $changed = $s['changed']; - if (isset($s['message'])) + if (!empty($s['message'])) $ret['message'] .= $s['message']; } @@ -977,17 +977,15 @@ class Libzot { } } - if (($changed) || ($ud_flags == UPDATE_FLAGS_FORCED)) { + if ($changed/* || ($ud_flags == UPDATE_FLAGS_FORCED)*/) { $guid = random_string() . '@' . \App::get_hostname(); Libzotdir::update_modtime($xchan_hash, $guid, $address, $ud_flags); - logger('Changed: ' . $what, LOGGER_DEBUG); } elseif (!$ud_flags) { // nothing changed but we still need to update the updates record - q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and (ud_flags & %d) = 0 ", - intval(UPDATE_FLAGS_UPDATED), - dbesc($address), - intval(UPDATE_FLAGS_UPDATED) + q("update updates set ud_flags = 0, ud_date = '%s' where ud_hash = '%s'", + dbesc(datetime_convert()), + dbesc($xchan_hash) ); } -- cgit v1.2.3 From 261762448e99a722d2a5e262610a66c5c1c72293 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 11:36:34 +0200 Subject: use url instead of addr for updates and clean up local_dir_update() and update_modtime() --- Zotlabs/Lib/Libzot.php | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index b41ba043a..4323dae48 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -649,7 +649,7 @@ class Libzot { * * \e string \b message (optional) error string only if success is false */ - static function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { + static function import_xchan($arr, $ud_flags = 0, $ud_arr = null) { $ret = ['success' => false]; @@ -665,7 +665,7 @@ class Libzot { */ call_hooks('import_xchan', $arr); - $dirmode = intval(get_config('system', 'directory_mode')); + $dirmode = intval(get_config('system', 'directory_mode', DIRECTORY_MODE_NORMAL)); $changed = false; $what = ''; @@ -696,7 +696,7 @@ class Libzot { return $ret; } - logger('import_xchan: ' . $xchan_hash, LOGGER_DEBUG); + hz_syslog('import_xchan: ' . $xchan_hash, LOGGER_DEBUG); if (isset($arr['signing_algorithm']) && $arr['signing_algorithm']) { set_xconfig($xchan_hash, 'system', 'signing_algorithm', $arr['signing_algorithm']); @@ -787,8 +787,8 @@ class Libzot { dbesc($xchan_hash) ); - logger('Update: existing: ' . print_r($r[0], true), LOGGER_DATA, LOG_DEBUG); - logger('Update: new: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); + hz_syslog('Update: existing: ' . print_r($r[0], true), LOGGER_DATA, LOG_DEBUG); + hz_syslog('Update: new: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); $what .= 'xchan '; $changed = true; } @@ -928,20 +928,16 @@ class Libzot { $ret['message'] .= $s['message']; } - // Which entries in the update table are we interested in updating? - - $address = (($ud_arr && $ud_arr['ud_addr']) ? $ud_arr['ud_addr'] : $arr['primary_location']['address']); - - - // Are we a directory server of some kind? $other_realm = false; $realm = get_directory_realm(); - if (array_key_exists('site', $arr) - && array_key_exists('realm', $arr['site']) - && (strpos($arr['site']['realm'], $realm) === false)) + if (array_key_exists('site', $arr) && array_key_exists('realm', $arr['site']) && (strpos($arr['site']['realm'], $realm) === false)) { $other_realm = true; + } + $address = $arr['primary_location']['url']; + + // Are we a directory server of some kind? if ($dirmode != DIRECTORY_MODE_NORMAL) { @@ -977,16 +973,9 @@ class Libzot { } } - if ($changed/* || ($ud_flags == UPDATE_FLAGS_FORCED)*/) { - $guid = random_string() . '@' . \App::get_hostname(); - Libzotdir::update_modtime($xchan_hash, $guid, $address, $ud_flags); - } - elseif (!$ud_flags) { - // nothing changed but we still need to update the updates record - q("update updates set ud_flags = 0, ud_date = '%s' where ud_hash = '%s'", - dbesc(datetime_convert()), - dbesc($xchan_hash) - ); + if ($ud_arr) { + // Always update updates if we were provided an ud_arr + Libzotdir::update_modtime($xchan_hash, $address); } if (!x($ret, 'message')) { -- cgit v1.2.3 From 432024123a4066723f22abaf02b6a0cb520f0a32 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 13:17:23 +0200 Subject: update updates if we are provided an ud_arr or we imported a new xchan --- Zotlabs/Lib/Libzot.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 4323dae48..9a913a6a8 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -651,7 +651,10 @@ class Libzot { static function import_xchan($arr, $ud_flags = 0, $ud_arr = null) { - $ret = ['success' => false]; + $ret = [ + 'success' => false, + 'message' => '' + ]; if (!is_array($arr)) { logger('Not an array: ' . print_r($arr, true), LOGGER_DEBUG); @@ -696,7 +699,7 @@ class Libzot { return $ret; } - hz_syslog('import_xchan: ' . $xchan_hash, LOGGER_DEBUG); + logger('import_xchan: ' . $xchan_hash, LOGGER_DEBUG); if (isset($arr['signing_algorithm']) && $arr['signing_algorithm']) { set_xconfig($xchan_hash, 'system', 'signing_algorithm', $arr['signing_algorithm']); @@ -709,6 +712,8 @@ class Libzot { if (!array_key_exists('connect_url', $arr)) $arr['connect_url'] = ''; + $new_xchan = false; + if ($r) { if ($arr['photo'] && array_key_exists('updated', $arr['photo']) && $arr['photo']['updated'] > $r[0]['xchan_photo_date']) @@ -787,8 +792,8 @@ class Libzot { dbesc($xchan_hash) ); - hz_syslog('Update: existing: ' . print_r($r[0], true), LOGGER_DATA, LOG_DEBUG); - hz_syslog('Update: new: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); + logger('Update: existing: ' . print_r($r[0], true), LOGGER_DATA, LOG_DEBUG); + logger('Update: new: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); $what .= 'xchan '; $changed = true; } @@ -826,6 +831,7 @@ class Libzot { ); $what .= 'new_xchan'; + $new_xchan = true; $changed = true; } @@ -923,7 +929,7 @@ class Libzot { if (!empty($s['change_message'])) $what .= $s['change_message']; if (!empty($s['changed'])) - $changed = $s['changed']; + $changed .= $s['changed']; if (!empty($s['message'])) $ret['message'] .= $s['message']; } @@ -939,7 +945,7 @@ class Libzot { // Are we a directory server of some kind? - if ($dirmode != DIRECTORY_MODE_NORMAL) { + if ($dirmode !== DIRECTORY_MODE_NORMAL) { // We're some kind of directory server. However we can only add directory information // if the entry is in the same realm (or is a sub-realm). Sub-realms are denoted by @@ -973,8 +979,8 @@ class Libzot { } } - if ($ud_arr) { - // Always update updates if we were provided an ud_arr + if ($ud_arr || ($new_xchan && in_array($dirmode, [DIRECTORY_MODE_PRIMARY, DIRECTORY_MODE_SECONDARY]))) { + // update updates if we were provided an ud_arr or the xchan is new and we are some sort of directory Libzotdir::update_modtime($xchan_hash, $address); } -- cgit v1.2.3 From 9f7dbe16fd29fed557aecdf8150d0ba244f3f36a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 13:21:26 +0200 Subject: adjust check --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 9a913a6a8..814aebf47 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -984,7 +984,7 @@ class Libzot { Libzotdir::update_modtime($xchan_hash, $address); } - if (!x($ret, 'message')) { + if (empty($ret['message'])) { $ret['success'] = true; $ret['hash'] = $xchan_hash; } -- cgit v1.2.3 From 30724bd7c43f52361fbcc7d912545255bd351757 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 12 Apr 2023 15:35:21 +0000 Subject: update updates if anything changed --- Zotlabs/Lib/Libzot.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 814aebf47..9a6b64c75 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -712,8 +712,6 @@ class Libzot { if (!array_key_exists('connect_url', $arr)) $arr['connect_url'] = ''; - $new_xchan = false; - if ($r) { if ($arr['photo'] && array_key_exists('updated', $arr['photo']) && $arr['photo']['updated'] > $r[0]['xchan_photo_date']) @@ -831,7 +829,6 @@ class Libzot { ); $what .= 'new_xchan'; - $new_xchan = true; $changed = true; } @@ -979,8 +976,8 @@ class Libzot { } } - if ($ud_arr || ($new_xchan && in_array($dirmode, [DIRECTORY_MODE_PRIMARY, DIRECTORY_MODE_SECONDARY]))) { - // update updates if we were provided an ud_arr or the xchan is new and we are some sort of directory + if ($changed) { + // update updates if anything changed Libzotdir::update_modtime($xchan_hash, $address); } -- cgit v1.2.3 From 6f1c261f6bc740d3a8a0c3b8540b7a5712c20cfd Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 18:01:35 +0200 Subject: deprecate ud_flags and ud_arr in import_xchan() --- Zotlabs/Lib/Libzot.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 9a6b64c75..23f3ef08f 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -328,7 +328,7 @@ class Libzot { logger('zot-info: ' . print_r($record, true), LOGGER_DATA, LOG_DEBUG); - $x = self::import_xchan($record['data'], (($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED)); + $x = self::import_xchan($record['data']); if (!$x['success']) { return false; @@ -635,21 +635,13 @@ class Libzot { * all internal data structures which need to be updated as a result. * * @param array $arr => json_decoded discovery packet - * @param int $ud_flags - * Determines whether to create a directory update record if any changes occur, default is UPDATE_FLAGS_UPDATED - * $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 - * that the channel still exists - * @param array $ud_arr - * If set [typically by update_directory_entry()] indicates a specific update table row and more particularly - * contains a particular address (ud_addr) which needs to be updated in that table. - * + * @return array An associative array with: * * \e boolean \b success boolean true or false * * \e string \b message (optional) error string only if success is false */ - static function import_xchan($arr, $ud_flags = 0, $ud_arr = null) { + static function import_xchan($arr) { $ret = [ 'success' => false, -- cgit v1.2.3 From ae074153c8367c9fac143ac29349b9f9d802e90a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 18:40:51 +0200 Subject: remouve updates stuff from import_directory_profile() --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 23f3ef08f..1c7098f66 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -942,7 +942,7 @@ class Libzot { // be in directories for the local realm (foo) and also the RED_GLOBAL realm. if (array_key_exists('profile', $arr) && is_array($arr['profile']) && (!$other_realm)) { - $profile_changed = Libzotdir::import_directory_profile($xchan_hash, $arr['profile'], $address, $ud_flags, 1); + $profile_changed = Libzotdir::import_directory_profile($xchan_hash, $arr['profile']); if ($profile_changed) { $what .= 'profile '; $changed = true; -- cgit v1.2.3 From bf5722cd25d2b837253ce2c63ec9decb61124040 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 19:07:28 +0200 Subject: always call update_modtime() foer now; --- Zotlabs/Lib/Libzot.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 1c7098f66..743100506 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -968,10 +968,8 @@ class Libzot { } } - if ($changed) { - // update updates if anything changed - Libzotdir::update_modtime($xchan_hash, $address); - } + // update updates if anything changed + Libzotdir::update_modtime($xchan_hash, $address); if (empty($ret['message'])) { $ret['success'] = true; -- cgit v1.2.3 From 64f30831ac1176baedba9952ff56c51e000ae5f2 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 12 Apr 2023 23:07:19 +0200 Subject: rename update_modtime() to update() and only bump ud_date if something actually changed --- Zotlabs/Lib/Libzot.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 743100506..bf6d02a72 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -968,8 +968,10 @@ class Libzot { } } - // update updates if anything changed - Libzotdir::update_modtime($xchan_hash, $address); + + // update updates if anything changed bump the ud_date + Libzotdir::update($xchan_hash, $address, $changed); + if (empty($ret['message'])) { $ret['success'] = true; -- cgit v1.2.3 From 6ddf1a57867689caffb6513afe73aeea1f2ed906 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 13 Apr 2023 10:45:36 +0200 Subject: update zotinfo to use as much info as possible from channel since in some cases the xchan might be history already --- Zotlabs/Lib/Libzot.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index bf6d02a72..8cd2718f4 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -678,15 +678,11 @@ class Libzot { $sig_methods = ((array_key_exists('signing', $arr) && is_array($arr['signing'])) ? $arr['signing'] : ['sha256']); $verified = false; - if (!self::verify($arr['id'], $arr['id_sig'], $arr['public_key'])) { - logger('Unable to verify channel signature for ' . $arr['primary_location']['address']); - return $ret; - } - else { + if (self::verify($arr['id'], $arr['id_sig'], $arr['public_key'])) { $verified = true; } - - if (!$verified) { + else { + logger('Unable to verify channel signature for ' . $xchan_hash . ' (' . $arr['primary_location']['address']) . ')'; $ret['message'] = t('Unable to verify channel signature'); return $ret; } @@ -968,11 +964,9 @@ class Libzot { } } - // update updates if anything changed bump the ud_date Libzotdir::update($xchan_hash, $address, $changed); - if (empty($ret['message'])) { $ret['success'] = true; $ret['hash'] = $xchan_hash; @@ -2800,8 +2794,8 @@ class Libzot { // Communication details - $ret['id'] = $e['xchan_guid']; - $ret['id_sig'] = self::sign($e['xchan_guid'], $e['channel_prvkey']); + $ret['id'] = $e['channel_guid']; + $ret['id_sig'] = self::sign($e['channel_guid'], $e['channel_prvkey']); $ret['primary_location'] = [ 'address' => $e['xchan_addr'], @@ -2810,10 +2804,10 @@ class Libzot { 'follow_url' => $e['xchan_follow'], ]; - $ret['public_key'] = $e['xchan_pubkey']; + $ret['public_key'] = $e['channel_pubkey']; $ret['signing_algorithm'] = 'rsa-sha256'; $ret['username'] = $e['channel_address']; - $ret['name'] = $e['xchan_name']; + $ret['name'] = $e['channel_name']; $ret['name_updated'] = $e['xchan_name_date']; $ret['photo'] = [ 'url' => $e['xchan_photo_l'], -- cgit v1.2.3 From 0b7bece8e3b252cc3a234f86607f4f7f9b416ddd Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 13 Apr 2023 11:01:57 +0200 Subject: remove pre zot6 compatibility tweaks --- Zotlabs/Lib/Libzot.php | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 8cd2718f4..13634e8dd 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2353,19 +2353,6 @@ class Libzot { 'deleted' => (intval($hub['hubloc_deleted']) ? true : false) ]; - // version compatibility tweaks - - if (!strpos($z['url_sig'], '.')) { - $z['url_sig'] = 'sha256.' . $z['url_sig']; - } - - if (!$z['id_url']) { - $z['id_url'] = $z['url'] . '/channel/' . substr($z['address'], 0, strpos($z['address'], '@')); - } - if (!$z['site_id']) { - $z['site_id'] = Libzot::make_xchan_hash($z['url'], $z['sitekey']); - } - $ret[] = $z; } } -- cgit v1.2.3 From 824497b97a2bcd0afe7a74c94e3992723c22ccdf Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 13 Apr 2023 11:37:01 +0200 Subject: fix wrong array key, check for xchan_deleted with empty() which will also catch a possibly already removed xchan (which will be null) and bump version --- Zotlabs/Lib/Libzot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 13634e8dd..b75e4e135 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -721,7 +721,7 @@ class Libzot { $hidden_changed = 1; if (isset($arr['adult_content']) && intval($r[0]['xchan_selfcensored']) != intval($arr['adult_content'])) $adult_changed = 1; - if (isset($arr['xchan_deleted']) && intval($r[0]['xchan_deleted']) != intval($arr['deleted'])) + if (isset($arr['deleted']) && intval($r[0]['xchan_deleted']) != intval($arr['deleted'])) $deleted_changed = 1; // new style 6-MAR-2019 @@ -2724,12 +2724,12 @@ class Libzot { $e = $r[0]; $id = $e['channel_id']; - $sys_channel = (intval($e['channel_system']) ? true : false); + $sys_channel = ((empty($e['channel_system'])) ? false : true); $special_channel = (($e['channel_pageflags'] & PAGE_PREMIUM) ? true : false); $adult_channel = (($e['channel_pageflags'] & PAGE_ADULT) ? true : false); $censored = (($e['channel_pageflags'] & PAGE_CENSORED) ? true : false); $searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true); - $deleted = (intval($e['xchan_deleted']) ? true : false); + $deleted = ((empty($e['xchan_deleted'])) ? false : true); if ($deleted || $censored || $sys_channel) $searchable = false; -- cgit v1.2.3 From f1667dbbe62dd0dce95aa36071c00b83b9033f0c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 13 Apr 2023 21:25:03 +0200 Subject: zot_info(): improved check for deleted --- Zotlabs/Lib/Libzot.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index b75e4e135..30afab66c 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2724,12 +2724,13 @@ class Libzot { $e = $r[0]; $id = $e['channel_id']; - $sys_channel = ((empty($e['channel_system'])) ? false : true); + $sys_channel = ((intval($e['channel_system'])) ? true : false); $special_channel = (($e['channel_pageflags'] & PAGE_PREMIUM) ? true : false); $adult_channel = (($e['channel_pageflags'] & PAGE_ADULT) ? true : false); $censored = (($e['channel_pageflags'] & PAGE_CENSORED) ? true : false); $searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true); - $deleted = ((empty($e['xchan_deleted'])) ? false : true); + // if the xchan has been deleted (instead of marked deleted) xchan entries will return null + $deleted = ((intval($e['xchan_deleted']) || $e['xchan_hash'] === null) ? true : false); if ($deleted || $censored || $sys_channel) $searchable = false; -- cgit v1.2.3 From d08c8e6edc81448cb00564767fa1401b48059461 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 13 Apr 2023 21:50:13 +0200 Subject: Revert "zot_info(): improved check for deleted" This reverts commit f1667dbbe62dd0dce95aa36071c00b83b9033f0c. --- Zotlabs/Lib/Libzot.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 30afab66c..b75e4e135 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2724,13 +2724,12 @@ class Libzot { $e = $r[0]; $id = $e['channel_id']; - $sys_channel = ((intval($e['channel_system'])) ? true : false); + $sys_channel = ((empty($e['channel_system'])) ? false : true); $special_channel = (($e['channel_pageflags'] & PAGE_PREMIUM) ? true : false); $adult_channel = (($e['channel_pageflags'] & PAGE_ADULT) ? true : false); $censored = (($e['channel_pageflags'] & PAGE_CENSORED) ? true : false); $searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true); - // if the xchan has been deleted (instead of marked deleted) xchan entries will return null - $deleted = ((intval($e['xchan_deleted']) || $e['xchan_hash'] === null) ? true : false); + $deleted = ((empty($e['xchan_deleted'])) ? false : true); if ($deleted || $censored || $sys_channel) $searchable = false; -- cgit v1.2.3 From ad5bbc463b0d94a3b920b72bb224b9435a422a4c Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 16 Apr 2023 10:59:26 +0000 Subject: fix wrong variable --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index b75e4e135..59fa863da 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1374,7 +1374,7 @@ class Libzot { $uids = ids_to_querystr($uids, 'uid'); $z = q("SELECT channel_hash FROM channel WHERE channel_hash != '%s' AND channel_id IN ($uids)", - dbesc($msg['sender']) + dbesc($env['sender']) ); if ($z) { -- cgit v1.2.3 From 84e25e8fd2e321c6d40230d737bf5dd495f1da0c Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 21 Apr 2023 10:34:55 +0000 Subject: Fetch conversations in the background. Otherwise it might sgnificantly delay delivery --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 59fa863da..2feddd378 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1722,7 +1722,7 @@ class Libzot { // this is just an exercise in futility. if (perm_is_allowed($channel['channel_id'], $sender, 'send_stream')) { - self::fetch_conversation($channel, $arr['parent_mid']); + Master::Summon(['Zotconvo', $channel['channel_id'], $arr['parent_mid']]); } continue; -- cgit v1.2.3 From 81f33da4991ed2abaa2422dac2bcc5fe5a2eea74 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 23 Apr 2023 13:02:38 +0200 Subject: improved fetch_conversation() --- Zotlabs/Lib/Libzot.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 2feddd378..99b9e0f75 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2013,18 +2013,12 @@ class Libzot { continue; } - $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s' order by hubloc_id desc", - dbesc($AS->actor['id']) - ); - + $r = Activity::get_actor_hublocs($AS->actor['id']); $r = self::zot_record_preferred($r); - if (!$r) { $y = import_author_xchan(['url' => $AS->actor['id']]); if ($y) { - $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s'", - dbesc($AS->actor['id']) - ); + $r = Activity::get_actor_hublocs($AS->actor['id']); $r = self::zot_record_preferred($r); } if (!$r) { @@ -2034,22 +2028,29 @@ class Libzot { } if (isset($AS->obj['actor']['id']) && $AS->obj['actor']['id'] !== $AS->actor['id']) { - $y = import_author_xchan(['url' => $AS->obj['actor']['id']]); - if (!$y) { - logger('FOF Activity: no object actor'); - continue; + $ro = Activity::get_actor_hublocs($AS->obj['actor']['id']); + $ro = self::zot_record_preferred($ro); + if (!$ro) { + $y = import_author_xchan(['url' => $AS->obj['actor']['id']]); + if ($y) { + $ro = Activity::get_actor_hublocs($AS->obj['actor']['id']); + $ro = self::zot_record_preferred($ro); + } + if (!$ro) { + logger('FOF Activity: no obj actor'); + continue; + } } } $arr = Activity::decode_note($AS); if (!$arr) { + logger('FOF Activity: could not decode'); continue; } - if ($r) { - $arr['author_xchan'] = $r['hubloc_hash']; - } + $arr['author_xchan'] = $r['hubloc_hash']; if ($signer) { $arr['owner_xchan'] = $signer[0]['hubloc_hash']; -- cgit v1.2.3 From bdb25315b6f01f1963b21f6e0c0bd5ec2959c62e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 26 Apr 2023 23:01:56 +0200 Subject: initial commit for directory flags federation --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 99b9e0f75..72cf892d0 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -965,7 +965,7 @@ class Libzot { } // update updates if anything changed bump the ud_date - Libzotdir::update($xchan_hash, $address, $changed); + Libzotdir::update($xchan_hash, $address, $changed, $r[0]['xchan_censored']); if (empty($ret['message'])) { $ret['success'] = true; -- cgit v1.2.3 From 1ed8b9dd149b9d2cb2fe30dc56ddc24cc523255c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 27 Apr 2023 11:17:53 +0200 Subject: fix php error --- Zotlabs/Lib/Libzot.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 72cf892d0..1843a081d 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -674,6 +674,7 @@ class Libzot { $arr['hash'] = $xchan_hash; $import_photos = false; + $xchan_censored = 0; $sig_methods = ((array_key_exists('signing', $arr) && is_array($arr['signing'])) ? $arr['signing'] : ['sha256']); $verified = false; @@ -705,6 +706,9 @@ class Libzot { if ($arr['photo'] && array_key_exists('updated', $arr['photo']) && $arr['photo']['updated'] > $r[0]['xchan_photo_date']) $import_photos = true; + $xchan_censored = $r[0]['xchan_censored'] ?? 0; + + // if we import an entry from a site that's not ours and either or both of us is off the grid - hide the entry. /** @TODO: check if we're the same directory realm, which would mean we are allowed to see it */ @@ -965,7 +969,7 @@ class Libzot { } // update updates if anything changed bump the ud_date - Libzotdir::update($xchan_hash, $address, $changed, $r[0]['xchan_censored']); + Libzotdir::update($xchan_hash, $address, $changed, $xchan_censored); if (empty($ret['message'])) { $ret['success'] = true; -- cgit v1.2.3 From 5da58d42f6b86d6aa026444a9163909eb5e0d49d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 27 Apr 2023 22:26:53 +0200 Subject: adjust args in libzotdir update and some dir sync fixes --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 1843a081d..d34afb83d 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -969,7 +969,7 @@ class Libzot { } // update updates if anything changed bump the ud_date - Libzotdir::update($xchan_hash, $address, $changed, $xchan_censored); + Libzotdir::update($xchan_hash, $address, $xchan_censored, $changed); if (empty($ret['message'])) { $ret['success'] = true; -- cgit v1.2.3 From 3543e6dd32bd7e518a0deec2038eafe6a183dc6b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 28 Apr 2023 08:57:21 +0200 Subject: slightly refactor dir sync --- Zotlabs/Lib/Libzot.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index d34afb83d..093670338 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -674,7 +674,6 @@ class Libzot { $arr['hash'] = $xchan_hash; $import_photos = false; - $xchan_censored = 0; $sig_methods = ((array_key_exists('signing', $arr) && is_array($arr['signing'])) ? $arr['signing'] : ['sha256']); $verified = false; @@ -706,8 +705,6 @@ class Libzot { if ($arr['photo'] && array_key_exists('updated', $arr['photo']) && $arr['photo']['updated'] > $r[0]['xchan_photo_date']) $import_photos = true; - $xchan_censored = $r[0]['xchan_censored'] ?? 0; - // if we import an entry from a site that's not ours and either or both of us is off the grid - hide the entry. /** @TODO: check if we're the same directory realm, which would mean we are allowed to see it */ @@ -969,7 +966,7 @@ class Libzot { } // update updates if anything changed bump the ud_date - Libzotdir::update($xchan_hash, $address, $xchan_censored, $changed); + Libzotdir::update($xchan_hash, $address, $changed); if (empty($ret['message'])) { $ret['success'] = true; -- cgit v1.2.3