From 5d70d889e908a32c846b9da3eb26703064d20ec6 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 10 Apr 2019 13:25:03 +0200 Subject: Revert "Update htconfig.sample.php" This reverts commit f2126ef18c8b66020305d07dcefeacc4e55a3c12 --- include/import.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 7a1e9aa55..21cdfb68f 100644 --- a/include/import.php +++ b/include/import.php @@ -1385,13 +1385,14 @@ function sync_files($channel, $files) { else $p['content'] = (($p['content'])? base64_decode($p['content']) : ''); - if(intval($p['imgscale']) && (! $p['content'])) { + if(intval($p['imgscale']) && intval($p['os_storage']) && (! empty($p['content']))) { $time = datetime_convert(); - $parr = array('hash' => $channel['channel_hash'], + $parr = array( + 'hash' => $channel['channel_hash'], 'time' => $time, - 'resource' => $att['hash'], + 'resource' => $p['resource_id'], 'revision' => 0, 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])), 'resolution' => $p['imgscale'] @@ -1414,8 +1415,6 @@ function sync_files($channel, $files) { $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); - $p['content'] = file_get_contents($stored_image); - unlink($stored_image); } if(!isset($p['display_path'])) -- cgit v1.2.3 From 074ee656f039442244396efa1ccf641ad1d9822e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 12 Apr 2019 14:56:07 +0200 Subject: Fetch thumbnails and store it in filesystem or DB; update xchan profile edit time on fetch --- include/import.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 21cdfb68f..d1d786321 100644 --- a/include/import.php +++ b/include/import.php @@ -1345,6 +1345,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']; @@ -1366,6 +1367,7 @@ function sync_files($channel, $files) { dbesc($p['resource_id']), intval($channel['channel_id']) ); + $update_xchan = $p['edited']; } // same for cover photos @@ -1385,7 +1387,7 @@ function sync_files($channel, $files) { else $p['content'] = (($p['content'])? base64_decode($p['content']) : ''); - if(intval($p['imgscale']) && intval($p['os_storage']) && (! empty($p['content']))) { + if(intval($p['imgscale']) && (! empty($p['content']))) { $time = datetime_convert(); @@ -1395,10 +1397,10 @@ function sync_files($channel, $files) { 'resource' => $p['resource_id'], 'revision' => 0, 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])), - 'resolution' => $p['imgscale'] + 'resolution' => intval($p['imgscale']) ); - $stored_image = $newfname . '-' . intval($p['imgscale']); + $stored_image = $newfname . '-' . $p['imgscale']; $fp = fopen($stored_image,'w'); if(! $fp) { @@ -1407,7 +1409,6 @@ function sync_files($channel, $files) { } $redirects = 0; - $headers = []; $headers['Accept'] = 'application/x-zot+json' ; $headers['Sigtoken'] = random_string(); @@ -1415,6 +1416,15 @@ 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; + $p['content'] = file_get_contents($stored_image); + @unlink($stored_image); + } + else + $p['os_storage'] = 1; } if(!isset($p['display_path'])) @@ -1446,6 +1456,14 @@ 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']) + ); + } } \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $att['hash'] ]); -- cgit v1.2.3 From d3a619659f4815c648603698c13a752d4be3f673 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 12 Apr 2019 15:38:10 +0200 Subject: Fix 'os_syspath' if we store thumbnails in filesystem --- include/import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index d1d786321..0a70b114c 100644 --- a/include/import.php +++ b/include/import.php @@ -1423,8 +1423,10 @@ function sync_files($channel, $files) { $p['content'] = file_get_contents($stored_image); @unlink($stored_image); } - else + else { $p['os_storage'] = 1; + $p['os_syspath'] = $stored_image; + } } if(!isset($p['display_path'])) -- cgit v1.2.3 From 852343f25448a996298b3b5f892a61b0b7701c7f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 12 Apr 2019 16:27:58 +0200 Subject: Override received 'content' if we saving thumbnail in filesystem --- 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 0a70b114c..69be521de 100644 --- a/include/import.php +++ b/include/import.php @@ -1426,6 +1426,7 @@ function sync_files($channel, $files) { else { $p['os_storage'] = 1; $p['os_syspath'] = $stored_image; + $p['content'] = $stored_image; } } -- cgit v1.2.3 From 04b261057d1123a43e72216ecc3c8172bbda32bc Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 12 Apr 2019 22:34:32 +0200 Subject: Set 'os_syspath' with local path --- include/import.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 69be521de..585a0ac84 100644 --- a/include/import.php +++ b/include/import.php @@ -1417,6 +1417,8 @@ function sync_files($channel, $files) { $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); + $p['os_syspath'] = $stored_image; + // Override remote hub thumbnails storage settings if(! boolval(get_config('system','filesystem_storage_thumbnails', 0))) { $p['os_storage'] = 0; @@ -1425,7 +1427,6 @@ function sync_files($channel, $files) { } else { $p['os_storage'] = 1; - $p['os_syspath'] = $stored_image; $p['content'] = $stored_image; } } -- cgit v1.2.3 From 509067391b9e2b167827a7b999cb5ef455ac68d6 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 13 Apr 2019 14:08:44 +0200 Subject: Update xchan profile edited date only once --- include/import.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 585a0ac84..434a53f10 100644 --- a/include/import.php +++ b/include/import.php @@ -1417,8 +1417,6 @@ function sync_files($channel, $files) { $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]); fclose($fp); - $p['os_syspath'] = $stored_image; - // Override remote hub thumbnails storage settings if(! boolval(get_config('system','filesystem_storage_thumbnails', 0))) { $p['os_storage'] = 0; @@ -1428,6 +1426,7 @@ function sync_files($channel, $files) { else { $p['os_storage'] = 1; $p['content'] = $stored_image; + $p['os_syspath'] = $stored_image; } } @@ -1461,13 +1460,15 @@ function sync_files($channel, $files) { } } - // 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']) - ); - } + } + + // 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']) + ); } \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $att['hash'] ]); -- cgit v1.2.3