diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/api.php | 2 | ||||
-rwxr-xr-x | include/items.php | 33 | ||||
-rw-r--r-- | include/notifier.php | 24 | ||||
-rw-r--r-- | include/photo/photo_driver.php | 2 | ||||
-rw-r--r-- | include/photos.php | 7 |
5 files changed, 50 insertions, 18 deletions
diff --git a/include/api.php b/include/api.php index 463d29cf8..e854012e5 100644 --- a/include/api.php +++ b/include/api.php @@ -556,7 +556,7 @@ require_once('include/photos.php'); function api_photos(&$a,$type) { $album = $_REQUEST['album']; - json_return_and_die(photos_list_photos($a->get_channel(),$a->get_observer()),$album); + json_return_and_die(photos_list_photos($a->get_channel(),$a->get_observer(),$album)); } api_register_func('api/red/photos','api_photos', true); diff --git a/include/items.php b/include/items.php index ea46df9bf..12823c6f9 100755 --- a/include/items.php +++ b/include/items.php @@ -18,10 +18,17 @@ function collect_recipients($item,&$private) { require_once('include/group.php'); - if($item['item_private']) - $private = true; + $private = ((intval($item['item_private'])) ? true : false); + $recipients = array(); + + // if the post is marked private but there are no recipients, only add the author and owner + // as recipients. The ACL for the post may live on the hub of a different clone. We need to + // get the post to that hub. if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) { + + // it is private + $allow_people = expand_acl($item['allow_cid']); $allow_groups = expand_groups(expand_acl($item['allow_gid'])); @@ -54,19 +61,19 @@ function collect_recipients($item,&$private) { $private = true; } else { - $recipients = array(); - $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d)", - intval($item['uid']), - intval(ABOOK_FLAG_SELF), - intval(ABOOK_FLAG_PENDING), - intval(ABOOK_FLAG_ARCHIVED) - ); - if($r) { - foreach($r as $rr) { - $recipients[] = $rr['abook_xchan']; + if(! $private) { + $r = q("select abook_xchan from abook where abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d)", + intval($item['uid']), + intval(ABOOK_FLAG_SELF), + intval(ABOOK_FLAG_PENDING), + intval(ABOOK_FLAG_ARCHIVED) + ); + if($r) { + foreach($r as $rr) { + $recipients[] = $rr['abook_xchan']; + } } } - $private = false; } // This is a somewhat expensive operation but important. diff --git a/include/notifier.php b/include/notifier.php index 0868ac77e..81f971107 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -425,8 +425,28 @@ function notifier_run($argv, $argc){ $sql_extra = (($private) ? "" : " or hubloc_url = '" . dbesc(z_root()) . "' "); - $r = q("select hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc - where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey"); + + if($relay_to_owner && (! $private) && ($cmd !== 'relay')) { + + // If sending a followup to the post owner, only send it to one channel clone - to avoid race conditions. + // In this case we'll pick the most recently contacted hub, as their primary might be down and the most + // recently contacted has the best chance of being alive. + + // For private posts or uplinks we have to do things differently as only the sending clone will have the recipient list. + // We have to send to all clone channels of the owner to find out who has the definitive list. Posts with + // item_private set (but no ACL list) will return empty recipients (except for the sender and owner) in + // collect_recipients() above. The end result is we should get only one delivery per delivery chain if we + // aren't the owner or author. + + + $r = q("select hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc + where hubloc_hash in (" . implode(',',$recipients) . ") group by hubloc_sitekey order by hubloc_connected desc limit 1"); + } + else { + $r = q("select hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc + where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey"); + } + if(! $r) { logger('notifier: no hubs'); return; diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index ff92e5a0f..c2eeafa54 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -357,7 +357,7 @@ abstract class photo_driver { dbesc($p['resource_id']), dbesc(datetime_convert()), dbesc(datetime_convert()), - dbesc(basename($filename)), + dbesc(basename($p['filename'])), dbesc($this->getType()), dbesc($p['album']), intval($this->getHeight()), diff --git a/include/photos.php b/include/photos.php index 5c03b2cdb..82af4aaeb 100644 --- a/include/photos.php +++ b/include/photos.php @@ -77,6 +77,7 @@ function photo_upload($channel, $observer, $args) { $filesize = intval($_FILES['userfile']['size']); $type = $_FILES['userfile']['type']; } + if (! $type) $type=guess_image_type($filename); @@ -268,7 +269,11 @@ function photos_albums_list($channel,$observer) { if($albums) { $ret['success'] = true; foreach($albums as $k => $album) { - $entry = array('text' => $album['album'], 'urlencode' => urlencode($album['album']),'bin2hex' => bin2hex($album['album'])); + $entry = array( + 'text' => $album['album'], + 'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']), + 'urlencode' => urlencode($album['album']), + 'bin2hex' => bin2hex($album['album'])); $ret[] = $entry; } } |