diff options
author | Mario <mario@mariovavti.com> | 2019-04-13 21:19:06 +0200 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-04-13 21:19:06 +0200 |
commit | 9c8cb4dea37a25d4602930373624607b570f2f06 (patch) | |
tree | 0cb60e30fd71c75055b5a3c652b57d61f5d46bbf /include/import.php | |
parent | 064f93185cf4204df2afa7ce23f8fe2dc8ce26ae (diff) | |
parent | ed902fdb703103944494e5c70ae354087c2208ad (diff) | |
download | volse-hubzilla-9c8cb4dea37a25d4602930373624607b570f2f06.tar.gz volse-hubzilla-9c8cb4dea37a25d4602930373624607b570f2f06.tar.bz2 volse-hubzilla-9c8cb4dea37a25d4602930373624607b570f2f06.zip |
Merge branch 'dev' into 'dev'
Thumbnails storage in filesystem or database implementation
See merge request hubzilla/core!1588
Diffstat (limited to 'include/import.php')
-rw-r--r-- | include/import.php | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/include/import.php b/include/import.php index 21cdfb68f..434a53f10 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,18 @@ 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; + $p['content'] = $stored_image; + $p['os_syspath'] = $stored_image; + } } if(!isset($p['display_path'])) @@ -1446,6 +1459,16 @@ 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'] ]); |