From 8c1c49a45ed28f5235d6a5f7668d2c31158fbea3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 11 Dec 2020 11:32:37 +0000 Subject: fix hubloc issue in mod getfile (cherry picked from commit b0b9b9f28974f9016e47491e81876224c57a7e3b) --- include/import.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 82c23e116..8f7c28f93 100644 --- a/include/import.php +++ b/include/import.php @@ -527,12 +527,12 @@ function sync_apps($channel, $apps) { /** * @brief Import system apps. - * System apps from the original server may not exist on this system + * System apps from the original server may not exist on this system * (e.g. apps associated with addons that are not installed here). * Check the system apps that were provided in the import file to see if they * exist here and if so, install them locally. Preserve categories that * might have been added by this channel on the other server. - * Do not use any paths from the original as they will point to a different server. + * Do not use any paths from the original as they will point to a different server. * @param array $channel * @param array $apps */ @@ -1373,7 +1373,7 @@ function sync_files($channel, $files) { logger('attachment store failed',LOGGER_NORMAL,LOG_ERR); } if($f['photo']) { - + foreach($f['photo'] as $p) { unset($p['id']); $p['aid'] = $channel['channel_account_id']; @@ -1446,7 +1446,7 @@ function sync_files($channel, $files) { $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); - + // Override remote hub thumbnails storage settings if(! boolval(get_config('system','filesystem_storage_thumbnails', 0))) { $p['os_storage'] = 0; @@ -1488,12 +1488,12 @@ function sync_files($channel, $files) { create_table_from_array('photo',$p, [ 'content' ] ); } } - + } - + // Set xchan photo date to prevent thumbnails fetch for clones on profile update packet recieve if(isset($update_xchan)) { - + $x = q("UPDATE xchan SET xchan_photo_date = '%s' WHERE xchan_hash = '%s'", dbescdate($update_xchan), dbesc($channel['channel_hash']) @@ -1522,13 +1522,13 @@ function sync_addressbook($channel, $data) { if(! \Zotlabs\Lib\Apps::system_app_installed($channel['channel_id'], 'CardDAV')) return; - + logger("debug: " . print_r($data,true), LOGGER_DEBUG); require_once('include/cdav.php'); $principalUri = 'principals/' . $channel['channel_address']; - + if($data['action'] !== 'create') { $id = get_cdav_id($principalUri, $data['uri'], 'addressbooks'); if(! $id) @@ -1630,7 +1630,7 @@ function sync_calendar($channel, $data) { break; case 'update_card': - $caldavBackend->updateCalendarObject($id, $data['carduri'], $data['card']); + $caldavBackend->updateCalendarObject($id, $data['carduri'], $data['card']); break; case 'switch': -- cgit v1.2.3 From e58e27ce2256ce4192c6ac7670ccb301fb40e60a Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 14 Dec 2020 21:38:49 +0000 Subject: sync categories --- include/import.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 8f7c28f93..eb3125a8e 100644 --- a/include/import.php +++ b/include/import.php @@ -1352,7 +1352,6 @@ function sync_files($channel, $files) { } $redirects = 0; - $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); @@ -1363,6 +1362,25 @@ function sync_files($channel, $files) { if($x['success']) { $attachment_stored = true; + + $a = q("SELECT id FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", + dbesc($att['hash']), + intval($channel['channel_id']) + ); + if($a) { + q("DELETE FROM term WHERE uid = %d AND oid = %d AND otype = %d", + intval($channel['channel_id']), + intval($a[0]['id']), + intval(TERM_OBJ_FILE) + ); + if($att['term']) { + foreach($att['term'] as $t) { + if(array_key_exists('type',$t)) + $t['ttype'] = $t['type']; + store_item_tag($channel['channel_id'], $a[0]['id'], TERM_OBJ_FILE, $t['ttype'], escape_tags($t['term']), escape_tags($t['url'])); + } + } + } } continue; } -- cgit v1.2.3 From 4a902dbbbe79a59d6e434ddb39ff24af93583da3 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 14 Dec 2020 22:06:47 +0000 Subject: fix file sync issues --- include/import.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index eb3125a8e..cfbb8775d 100644 --- a/include/import.php +++ b/include/import.php @@ -1208,6 +1208,9 @@ function sync_files($channel, $files) { continue; } + $term = $att['term']; + unset($att['term']); + $attach_exists = false; $x = attach_by_hash($att['hash'],$channel['channel_hash']); logger('sync_files duplicate check: attach_exists=' . $attach_exists, LOGGER_DEBUG); @@ -1373,8 +1376,8 @@ function sync_files($channel, $files) { intval($a[0]['id']), intval(TERM_OBJ_FILE) ); - if($att['term']) { - foreach($att['term'] as $t) { + if($term) { + foreach($term as $t) { if(array_key_exists('type',$t)) $t['ttype'] = $t['type']; store_item_tag($channel['channel_id'], $a[0]['id'], TERM_OBJ_FILE, $t['ttype'], escape_tags($t['term']), escape_tags($t['url'])); -- cgit v1.2.3 From 6579007ca080a7d126be0c3130043f754eb6ac2e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 19 Dec 2020 23:57:14 +0100 Subject: Fix CardDAV address book ID --- include/import.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index cfbb8775d..d02cc1e1f 100644 --- a/include/import.php +++ b/include/import.php @@ -1554,6 +1554,7 @@ function sync_addressbook($channel, $data) { $id = get_cdav_id($principalUri, $data['uri'], 'addressbooks'); if(! $id) return; + $id = $id['id']; } $pdo = \DBA::$dba->db; -- cgit v1.2.3 From 7cfb230a5e90986b62a5c1df86ce48c894c0578c Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Jan 2021 13:22:43 +0000 Subject: streamline keyid --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index d02cc1e1f..853690094 100644 --- a/include/import.php +++ b/include/import.php @@ -1358,7 +1358,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], 'acct:' . channel_reddress($channel),true,'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3 From 61e782389c20a0d22749985177370149af4ae119 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Jan 2021 13:24:32 +0000 Subject: more streamline keyid --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 853690094..b512e1f11 100644 --- a/include/import.php +++ b/include/import.php @@ -1463,7 +1463,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'],'acct:' . channel_reddress($channel),true,'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3 From efb8a29b5fcacd491c5e080572581437b6000f87 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 9 Jan 2021 20:20:48 +0000 Subject: keyid adapt for backward compatibility to current release part 2 --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index b512e1f11..82d6cfe07 100644 --- a/include/import.php +++ b/include/import.php @@ -1358,7 +1358,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_reddress($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3 From b7afc905ecc5b738c7696b662692f727099cb968 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Jan 2021 09:34:38 +0000 Subject: Revert "keyid adapt for backward compatibility to current release part 2" This reverts commit efb8a29b5fcacd491c5e080572581437b6000f87. --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 82d6cfe07..b512e1f11 100644 --- a/include/import.php +++ b/include/import.php @@ -1358,7 +1358,7 @@ function sync_files($channel, $files) { $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); - $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_reddress($channel), true, 'sha512'); + $headers = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel), true, 'sha512'); $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); -- cgit v1.2.3