diff options
author | Max Kostikov <max@kostikov.co> | 2019-04-12 14:56:07 +0200 |
---|---|---|
committer | Max Kostikov <max@kostikov.co> | 2019-04-12 14:56:07 +0200 |
commit | 074ee656f039442244396efa1ccf641ad1d9822e (patch) | |
tree | 28b869e718dfb482acdfb76262dfe83ea3158b27 | |
parent | 775285cdf8faebb77e1725e7c88de82129acd3c4 (diff) | |
download | volse-hubzilla-074ee656f039442244396efa1ccf641ad1d9822e.tar.gz volse-hubzilla-074ee656f039442244396efa1ccf641ad1d9822e.tar.bz2 volse-hubzilla-074ee656f039442244396efa1ccf641ad1d9822e.zip |
Fetch thumbnails and store it in filesystem or DB; update xchan profile edit time on fetch
-rw-r--r-- | include/import.php | 26 |
1 files changed, 22 insertions, 4 deletions
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'] ]); |