From eb868f6df8ce31497992bab1e8c4fd39bee8fe15 Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 22 Jan 2014 17:18:40 +0100 Subject: [PATCH 1/6] make network tabs regard selected group (collection) and vice versa --- include/conversation.php | 6 +++--- include/group.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 708348ddd..c0bed2a6b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1374,13 +1374,13 @@ function network_tabs() { $tabs = array( array( 'label' => t('Commented Order'), - 'url'=>$a->get_baseurl(true) . '/' . $cmd . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), + 'url'=>$a->get_baseurl(true) . '/' . $cmd . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . ((x($_GET,'gid')) ? '&gid=' . $_GET['gid'] : ''), 'sel'=>$all_active, 'title'=> t('Sort by Comment Date'), ), array( 'label' => t('Posted Order'), - 'url'=>$a->get_baseurl(true) . '/' . $cmd . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), + 'url'=>$a->get_baseurl(true) . '/' . $cmd . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . ((x($_GET,'gid')) ? '&gid=' . $_GET['gid'] : ''), 'sel'=>$postord_active, 'title' => t('Sort by Post Date'), ), @@ -1393,7 +1393,7 @@ function network_tabs() { ), array( 'label' => t('New'), - 'url' => $a->get_baseurl(true) . '/' . $cmd . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&new=1', + 'url' => $a->get_baseurl(true) . '/' . $cmd . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&new=1' . ((x($_GET,'gid')) ? '&gid=' . $_GET['gid'] : ''), 'sel' => $new_active, 'title' => t('Activity Stream - by date'), ), diff --git a/include/group.php b/include/group.php index cdd779df2..56a7555bc 100644 --- a/include/group.php +++ b/include/group.php @@ -272,7 +272,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id 'cid' => $cid, 'text' => $rr['name'], 'selected' => $selected, - 'href' => (($mode == 0) ? $each.'?f=&gid='.$rr['id'] : $each."/".$rr['id']), + 'href' => (($mode == 0) ? $each.'?f=&gid='.$rr['id'] : $each."/".$rr['id']) . ((x($_GET,'new')) ? '&new=' . $_GET['new'] : '') . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : ''), 'edit' => $groupedit, 'ismember' => in_array($rr['id'],$member_of), ); From 25f7a7fac975f9858b771f7bb57d4c06c5ab0daf Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Wed, 22 Jan 2014 22:17:12 +0000 Subject: [PATCH 2/6] Give pages enough to construct a share button. --- include/conversation.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 708348ddd..13f0d8970 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1301,7 +1301,8 @@ function prepare_page($item) { $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); $observer = $a->get_observer(); $zid = ($observer['xchan_addr']); - + $preview = substr(urlencode($item['body']), 0, 100); + $link = z_root() . '/' . $a->cmd; if(array_key_exists('webpage',$a->layout) && array_key_exists('authored',$a->layout['webpage'])) { if($a->layout['webpage']['authored'] === 'none') $naked = 1; @@ -1313,7 +1314,9 @@ function prepare_page($item) { '$zid' => $zid, '$date' => (($naked) ? '' : datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i')), '$title' => smilies(bbcode($item['title'])), - '$body' => prepare_body($item,true) + '$body' => prepare_body($item,true), + '$preview' => $preview, + '$link' => $link )); } From 040d87c999c02df82dd3acad97db498d12f8580a Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 22 Jan 2014 23:24:09 +0100 Subject: [PATCH 3/6] update argument ?f= --- include/conversation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index c0bed2a6b..ddcb12b07 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1387,13 +1387,13 @@ function network_tabs() { array( 'label' => t('Personal'), - 'url' => $a->get_baseurl(true) . '/' . $cmd . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1', + 'url' => $a->get_baseurl(true) . '/' . $cmd . '?f=' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . '&conv=1', 'sel' => $conv_active, 'title' => t('Posts that mention or involve you'), ), array( 'label' => t('New'), - 'url' => $a->get_baseurl(true) . '/' . $cmd . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&new=1' . ((x($_GET,'gid')) ? '&gid=' . $_GET['gid'] : ''), + 'url' => $a->get_baseurl(true) . '/' . $cmd . '?f=' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') . '&new=1' . ((x($_GET,'gid')) ? '&gid=' . $_GET['gid'] : ''), 'sel' => $new_active, 'title' => t('Activity Stream - by date'), ), From 66baa3cab0537a5a2f1a4aad54526b35987da90d Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 22 Jan 2014 22:07:47 -0800 Subject: [PATCH 4/6] try to reduce the number of simulaneous deliveries of the same post when dealing with owner relays that have more than one channel instance. If things melt down in the next few hours and I'm not available please revert this. I've reviewed a few times and think it's OK, but this part of the delivery code is traditionally touchy. --- include/items.php | 33 ++++++++++++++++++++------------- include/notifier.php | 24 ++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 15 deletions(-) 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; From 43f2d6972c365d35924018311ac706690a6094ca Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 22 Jan 2014 22:56:16 -0800 Subject: [PATCH 5/6] API: provide a link to photo albums in api/red/albums --- include/photos.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/photos.php b/include/photos.php index 5c03b2cdb..eebddd393 100644 --- a/include/photos.php +++ b/include/photos.php @@ -268,7 +268,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; } } From bc98f4ddf4cdfa655385c705d97fa006ada9c49f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 22 Jan 2014 23:04:19 -0800 Subject: [PATCH 6/6] fix api/red/photos when supplied with an album name --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);