From 492665a8a15454a5a409e1af3c6acaf1c7890036 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Jun 2017 16:26:24 -0700 Subject: provide hook when deleting a connection - we need this to clean up dangling PuSH subscriptions --- doc/hooklist.bb | 3 +++ include/connections.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/doc/hooklist.bb b/doc/hooklist.bb index 6933edad2..db606cbdc 100644 --- a/doc/hooklist.bb +++ b/doc/hooklist.bb @@ -118,6 +118,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the [zrl=[baseurl]/help/hook/connect_premium]connect_premium[/zrl] Called when connecting to a premium channel +[zrl=[baseurl]/help/hook/connection_remove]connection_remove[/zrl] + Called when deleting/removing a connection + [zrl=[baseurl]/help/hook/connector_settings]connector_settings[/zrl] Called when posting to the features/addon settings page diff --git a/include/connections.php b/include/connections.php index 167f7e2c4..85b961b65 100644 --- a/include/connections.php +++ b/include/connections.php @@ -341,6 +341,11 @@ function contact_remove($channel_id, $abook_id) { logger('removing contact ' . $abook_id . ' for channel ' . $channel_id,LOGGER_DEBUG); + + $x = [ 'channel_id' => $channel_id, 'abook_id' => $abook_id ]; + call_hooks('connection_remove',$x); + + $archive = get_pconfig($channel_id, 'system','archive_removed_contacts'); if($archive) { q("update abook set abook_archived = 1 where abook_id = %d and abook_channel = %d", -- cgit v1.2.3 From 30358100ab729e7ce7bd3f05cc64a391239906e0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Jun 2017 20:28:59 -0700 Subject: partial fix for failure to sync photos - appears to be memory exhaustion and dependent on filesize although an unrelated issue was found with directory creation during file sync (we didn't check ownership when looking for duplicates). This checkin provides the means for a sync process to fetch the contents for various photo scales from the original server just as is done for the attach data now. It is still missing the bit for the sync process to spawn a mob of children to fetch these suckers and update the photo table with the results. --- Zotlabs/Module/Getfile.php | 35 +++++++++++++++++++++++++++++++++++ include/import.php | 5 +++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 3d859d94b..0b05d78a4 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -35,6 +35,7 @@ class Getfile extends \Zotlabs\Web\Controller { $sig = $_POST['signature']; $resource = $_POST['resource']; $revision = intval($_POST['revision']); + $resolution = (-1); if(! $hash) killme(); @@ -46,6 +47,11 @@ class Getfile extends \Zotlabs\Web\Controller { killme(); } + if(substr($resource,-2,1) == '-') { + $resolution = intval(substr($resource,-1,1)); + $resource = substr($resource,0,-2); + } + $slop = intval(get_pconfig($channel['channel_id'],'system','getfile_time_slop')); if($slop < 1) $slop = 3; @@ -63,6 +69,35 @@ class Getfile extends \Zotlabs\Web\Controller { killme(); } + + if($resolution > 0) { + $r = q("select * from photo where resource_id = '%s' and uid = %d limit 1", + dbesc($resource), + intval($channel['channel_id']) + ); + if($r) { + header('Content-type: ' . $r[0]['mimetype']); + + if(intval($r[0]['os_storage'])) { + $fname = dbunescbin($r[0]['content']); + if(strpos($fname,'store') !== false) + $istream = fopen($fname,'rb'); + else + $istream = fopen('store/' . $channel['channel_address'] . '/' . $fname,'rb'); + $ostream = fopen('php://output','wb'); + if($istream && $ostream) { + pipe_streams($istream,$ostream); + fclose($istream); + fclose($ostream); + } + } + else { + echo dbunescbin($r[0]['content']); + } + } + killme(); + } + $r = attach_by_hash($resource,$channel['channel_hash'],$revision); if(! $r['success']) { diff --git a/include/import.php b/include/import.php index 3b5ddd1f1..01f356f2f 100644 --- a/include/import.php +++ b/include/import.php @@ -1093,11 +1093,12 @@ function sync_files($channel, $files) { $ext = ''; } - $r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' and hash != '%s' ", + $r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' and hash != '%s' and uid = %d ", dbesc($basename . $ext), dbesc($basename . '(%)' . $ext), dbesc($att['folder']), - dbesc($att['hash']) + dbesc($att['hash']), + intval($channel['channel_id']) ); if($r) { -- cgit v1.2.3 From 912be5a792b286f844a2c933fd5f7775a34887a4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Jun 2017 20:44:44 -0700 Subject: it appears to also work a bit better if you don't use imaginary function names --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/import.php b/include/import.php index 01f356f2f..faab29bc0 100644 --- a/include/import.php +++ b/include/import.php @@ -1264,7 +1264,7 @@ function sync_files($channel, $files) { $r = dbq("update photo set " . $str . " where id = " . intval($exists[0]['id']) ); } else { - create_attach_from_array('photo',$p); + create_table_from_array('photo',$p); } } } -- cgit v1.2.3 From 3563568f6f965c755323a233a99a60e3b0b85102 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Jun 2017 21:49:50 -0700 Subject: fall back on feed logo if an author avatar cannot be found --- include/feedutils.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/feedutils.php b/include/feedutils.php index 708532013..f1cee4194 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1185,6 +1185,10 @@ function feed_meta($xml) { } } + if(! $author['author_photo']) + $author['author_photo'] = $feed->get_image_url(); + + if(substr($author['author_link'],-1,1) == '/') $author['author_link'] = substr($author['author_link'],0,-1); -- cgit v1.2.3 From f730e476f0d6db20eea29cd97e995f91a793d61c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 8 Jun 2017 15:34:19 +0200 Subject: bump std version --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index b0c4adabd..300df9271 100755 --- a/boot.php +++ b/boot.php @@ -50,7 +50,7 @@ require_once('include/attach.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '2.5.2' ); +define ( 'STD_VERSION', '2.5.3' ); define ( 'ZOT_REVISION', '1.2' ); define ( 'DB_UPDATE_VERSION', 1191 ); -- cgit v1.2.3