From b6cc0bc6b86046d53941f3aaf973cf6493250fb1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 5 Oct 2019 01:07:02 -0700 Subject: [PATCH 1/8] more work on channel manager --- Zotlabs/Module/Manage.php | 4 ++-- include/nav.php | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index 64b09fc74..48164194f 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -181,10 +181,10 @@ class Manage extends Controller { '$msg_selected' => t('Current Channel'), '$selected' => local_channel(), '$desc' => t('Switch to one of your channels by selecting it.'), - '$msg_default' => t('Default Channel'), + '$msg_default' => t('Default Login Channel'), '$msg_make_default' => t('Make Default'), '$msg_include' => t('Add to menu'), - '$msg_no_include' => t('Remove from menu'), + '$msg_no_include' => t('Add to menu'), '$create' => $create, '$all_channels' => $channels, '$mail_format' => t('%d new messages'), diff --git a/include/nav.php b/include/nav.php index bc24bd66f..ee1c9d871 100644 --- a/include/nav.php +++ b/include/nav.php @@ -31,9 +31,8 @@ function nav($template = 'default') { ); if(! $_SESSION['delegate']) { - $chans = q("select channel_name, channel_id from channel left join pconfig on channel_id = pconfig.uid where channel_account_id = %d and channel_removed = 0 and pconfig.cat = 'system' and pconfig.k = 'include_in_menu' and pconfig.v = '1' and channel_id != %d order by channel_name ", - intval(get_account_id()), - intval(local_channel()) + $chans = q("select channel_name, channel_id from channel left join pconfig on channel_id = pconfig.uid where channel_account_id = %d and channel_removed = 0 and pconfig.cat = 'system' and pconfig.k = 'include_in_menu' and pconfig.v = '1' order by channel_name ", + intval(get_account_id()) ); } From e90c9807a0c24fd4b1f12ee1903ee7f3150cceba Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 5 Oct 2019 14:42:38 -0700 Subject: [PATCH 2/8] siteinfo protocol changes --- Zotlabs/Module/Siteinfo.php | 13 ++++++------- include/network.php | 5 +++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Zotlabs/Module/Siteinfo.php b/Zotlabs/Module/Siteinfo.php index 144ec2ef0..f03365824 100644 --- a/Zotlabs/Module/Siteinfo.php +++ b/Zotlabs/Module/Siteinfo.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; use Zotlabs\Lib\System; +use Zotlabs\Lib\Config; use Zotlabs\Web\Controller; class Siteinfo extends Controller { @@ -15,11 +16,9 @@ class Siteinfo extends Controller { function get() { - if(! get_config('system','activitypub')) { - $federated = [ 'zot6' ]; - } - else { - $federated = [ 'zot6','activitypub' ]; + $federated = 'Zot6'; + if (Config::get('system','activitypub')) { + $federated .= ', ActivityPub'; } @@ -41,8 +40,8 @@ class Siteinfo extends Controller { '$transport_link' => 'https://zotlabs.com', '$ebs' => System::ebs(), - '$additional_text' => t('Additional federated transport protocols:'), - '$additional_fed' => implode(', ',array_unique($federated)), + '$additional_text' => t('Federated transport protocols:'), + '$additional_fed' => $federated, '$prj_version' => ((get_config('system','hidden_version_siteinfo')) ? '' : sprintf( t('Version %s'), System::get_project_version())), '$prj_linktxt' => t('Project homepage'), '$prj_srctxt' => t('Developer homepage'), diff --git a/include/network.php b/include/network.php index d841eb6d4..bc05c80b8 100644 --- a/include/network.php +++ b/include/network.php @@ -1632,6 +1632,10 @@ function get_site_info() { } } + $protocols = [ 'zot' ]; + if (get_config('system','activitypub')) { + $protocols[] = 'activitypub'; + } $data = [ 'url' => z_root(), @@ -1642,6 +1646,7 @@ function get_site_info() { 'addon_version' => defined('ADDON_VERSION') ? ADDON_VERSION : 'unknown', 'server_role' => System::get_server_role(), 'commit' => $commit, + 'protocols' => $protocols, 'plugins' => $visible_plugins, 'register_policy' => $register_policy[get_config('system','register_policy')], 'invitation_only' => (bool) intval(get_config('system','invitation_only')), From 5831c83844206bb6bdc329d2eda62d20014059f9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 6 Oct 2019 13:07:41 -0700 Subject: [PATCH 3/8] deprecate public stream uids calculations --- Zotlabs/Module/Display.php | 26 ++------- Zotlabs/Module/Pubstream.php | 7 +-- Zotlabs/Module/Search.php | 21 +++----- include/security.php | 100 ----------------------------------- include/taxonomy.php | 4 +- 5 files changed, 14 insertions(+), 144 deletions(-) diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 89504c6e3..4f257608a 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -283,24 +283,15 @@ class Display extends Controller { } if($r === null) { - - // in case somebody turned off public access to sys channel content using permissions - // make that content unsearchable by ensuring the owner uid can't match - - if(! perm_is_allowed($sysid,$observer_hash,'view_stream')) - $sysid = 0; - $r = q("SELECT item.id as item_id from item WHERE mid = '%s' AND (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) - and uid in ( " . stream_perms_api_uids(($observer_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) - OR uid = %d ) + and uid != 0)) $sql_extra ) $item_normal limit 1", - dbesc($target_item['parent_mid']), - intval($sysid) + dbesc($target_item['parent_mid']) ); } } @@ -328,22 +319,16 @@ class Display extends Controller { } if(! $r) { - // in case somebody turned off public access to sys channel content using permissions - // make that content unsearchable by ensuring the owner_xchan can't match - if(! perm_is_allowed($sysid,$observer_hash,'view_stream')) - $sysid = 0; $r = q("SELECT item.parent AS item_id from item WHERE parent_mid = '%s' - AND (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' + AND ((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) - and uid in ( " . stream_perms_api_uids(($observer_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) - OR uid = %d ) + and uid != 0 ) $sql_extra ) $item_normal_update $simple_update limit 1", - dbesc($target_item['parent_mid']), - intval($sysid) + dbesc($target_item['parent_mid']) ); } $_SESSION['loadtime'] = datetime_convert(); @@ -370,7 +355,6 @@ class Display extends Controller { $items = array(); } - switch($module_format) { case 'html': diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 9a7076b76..bd2df9484 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -88,11 +88,6 @@ class Pubstream extends Controller { $o .= status_editor($a,$x); $o .= ''; } - - - - - if(! $update && !$load) { @@ -162,7 +157,7 @@ class Pubstream extends Controller { require_once('include/security.php'); if($site_firehose) { - $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 "; + $uids = " and item_private = 0 and item_wall = 1 "; } else { $sys = get_sys_channel(); diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 1858bf813..ec51162f3 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -163,36 +163,27 @@ class Search extends \Zotlabs\Web\Controller { $itemspage = get_pconfig(local_channel(),'system','itemspage'); App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); - - // in case somebody turned off public access to sys channel content with permissions - - if (! perm_is_allowed($sys['channel_id'],$observer_hash,'view_stream')) - $sys['xchan_hash'] .= 'disabled'; - + if ($load) { $r = null; if (local_channel()) { $r = q("SELECT mid, MAX(id) as item_id from item - WHERE ((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) - OR ( item.uid = %d )) OR item.owner_xchan = '%s' ) + WHERE ((item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) OR item.uid = %d ) $item_normal $sql_extra group by mid, created order by created desc $pager_sql ", - intval(local_channel()), - dbesc($sys['xchan_hash']) + intval(local_channel()) ); } if ($r === null) { $r = q("SELECT mid, MAX(id) as item_id from item - WHERE (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' + WHERE (( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) - and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) - $pub_sql ) OR owner_xchan = '%s') + $pub_sql ) $item_normal $sql_extra - group by mid, created order by created desc $pager_sql", - dbesc($sys['xchan_hash']) + group by mid, created order by created desc $pager_sql" ); } if ($r) { diff --git a/include/security.php b/include/security.php index 0f5bd2da3..de5a1ab8c 100644 --- a/include/security.php +++ b/include/security.php @@ -684,103 +684,3 @@ function get_security_ids($channel_id, $ob_hash) { return $ret; } - - -// This is used to determine which uid have posts which are visible to the logged in user (from the API) for the -// public_timeline, and we can use this in a community page by making -// $perms = (PERMS_NETWORK|PERMS_PUBLIC) unless logged in. -// Collect uids of everybody on this site who has opened their posts to everybody on this site (or greater visibility) -// We always include yourself if logged in because you can always see your own posts -// resolving granular permissions for the observer against every person and every post on the site -// will likely be too expensive. -// Returns a string list of comma separated channel_ids suitable for direct inclusion in a SQL query - -function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) { - $perms = is_null($perms) ? (PERMS_SITE|PERMS_NETWORK|PERMS_PUBLIC) : $perms; - - $ret = array(); - $limit_sql = (($limit) ? " LIMIT " . intval($limit) . " " : ''); - $random_sql = (($rand) ? " ORDER BY " . db_getfunc('RAND') . " " : ''); - if(local_channel()) - $ret[] = local_channel(); - $x = q("select uid, v from pconfig where cat = 'perm_limits' and k = 'view_stream' "); - if($x) { - $y = []; - foreach($x as $xv) { - if(intval($xv['v']) & $perms) { - $y[] = $xv; - } - } - if($y) { - $ids = ids_to_querystr($y,'uid'); - $r = q("select channel_id from channel where channel_id in ( $ids ) and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 $random_sql $limit_sql ", - intval(PAGE_ADULT|PAGE_CENSORED) - ); - if($r) { - foreach($r as $rr) - if(! in_array($rr['channel_id'], $ret)) - $ret[] = $rr['channel_id']; - } - } - } - - $str = ''; - if($ret) { - foreach($ret as $rr) { - if($str) - $str .= ','; - $str .= intval($rr); - } - } - else - $str = "''"; - - logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG); - - return $str; -} - -function stream_perms_xchans($perms = NULL ) { - $perms = is_null($perms) ? (PERMS_SITE|PERMS_NETWORK|PERMS_PUBLIC) : $perms; - - $ret = array(); - if(local_channel()) - $ret[] = get_observer_hash(); - - $x = q("select uid, v from pconfig where cat = 'perm_limits' and k = 'view_stream' "); - if($x) { - $y = []; - foreach($x as $xv) { - if(intval($xv['v']) & $perms) { - $y[] = $xv; - } - } - if($y) { - $ids = ids_to_querystr($y,'uid'); - - $r = q("select channel_hash from channel where channel_id in ( $ids ) and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 ", - intval(PAGE_ADULT|PAGE_CENSORED) - ); - - if($r) { - foreach($r as $rr) - if(! in_array($rr['channel_hash'], $ret)) - $ret[] = $rr['channel_hash']; - } - } - } - $str = ''; - if($ret) { - foreach($ret as $rr) { - if($str) - $str .= ','; - $str .= "'" . dbesc($rr) . "'"; - } - } - else - $str = "''"; - - logger('stream_perms_xchans: ' . $str, LOGGER_DEBUG); - - return $str; -} diff --git a/include/taxonomy.php b/include/taxonomy.php index 920475bc8..215ea0495 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -1,4 +1,4 @@ - Date: Sun, 6 Oct 2019 13:29:01 -0700 Subject: [PATCH 4/8] fixes to public search refactoring --- Zotlabs/Module/Display.php | 32 ++++++-------------------------- Zotlabs/Module/Search.php | 8 ++------ include/taxonomy.php | 2 +- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 4f257608a..ef7cc68d0 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -122,7 +122,7 @@ class Display extends Controller { // \App::$poi = $x[0]; } - //if the item is to be moderated redirect to /moderate + // if the item is to be moderated redirect to /moderate if($target_item['item_blocked'] == ITEM_MODERATED) { goaway(z_root() . '/moderate/' . $target_item['id']); } @@ -283,33 +283,21 @@ class Display extends Controller { } if($r === null) { - $r = q("SELECT item.id as item_id from item - WHERE mid = '%s' - AND (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' - AND item.deny_gid = '' AND item_private = 0 ) - and uid != 0)) - $sql_extra ) - $item_normal - limit 1", + $r = q("SELECT item.id as item_id from item WHERE mid = '%s' $sql_extra $item_normal limit 1", dbesc($target_item['parent_mid']) ); } } - elseif($update && !$load) { + elseif ($update && !$load) { $r = null; require_once('include/channel.php'); $sys = get_sys_channel(); $sysid = $sys['channel_id']; - if(local_channel()) { - $r = q("SELECT item.parent AS item_id from item - WHERE uid = %d - and parent_mid = '%s' - $item_normal_update - $simple_update - limit 1", + if (local_channel()) { + $r = q("SELECT item.parent AS item_id from item WHERE uid = %d and parent_mid = '%s' $item_normal_update $simple_update limit 1", intval(local_channel()), dbesc($target_item['parent_mid']) ); @@ -319,15 +307,7 @@ class Display extends Controller { } if(! $r) { - $r = q("SELECT item.parent AS item_id from item - WHERE parent_mid = '%s' - AND ((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' - AND item.deny_gid = '' AND item_private = 0 ) - and uid != 0 ) - $sql_extra ) - $item_normal_update - $simple_update - limit 1", + $r = q("SELECT item.parent AS item_id from item WHERE parent_mid = '%s' $sql_extra $item_normal_update $simple_update limit 1", dbesc($target_item['parent_mid']) ); } diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index ec51162f3..ecac0c99c 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -168,8 +168,7 @@ class Search extends \Zotlabs\Web\Controller { $r = null; if (local_channel()) { - $r = q("SELECT mid, MAX(id) as item_id from item - WHERE ((item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) OR item.uid = %d ) + $r = q("SELECT mid, MAX(id) as item_id from item where uid = %d $item_normal $sql_extra group by mid, created order by created desc $pager_sql ", @@ -177,10 +176,7 @@ class Search extends \Zotlabs\Web\Controller { ); } if ($r === null) { - $r = q("SELECT mid, MAX(id) as item_id from item - WHERE (( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' - AND item.deny_gid = '' AND item_private = 0 ) - $pub_sql ) + $r = q("SELECT mid, MAX(id) as item_id from item $pub_sql $item_normal $sql_extra group by mid, created order by created desc $pager_sql" diff --git a/include/taxonomy.php b/include/taxonomy.php index 215ea0495..ba5d97b40 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -1,4 +1,4 @@ -?php /** @file */ + Date: Mon, 7 Oct 2019 14:40:51 -0700 Subject: [PATCH 5/8] fix hyperdrive --- Zotlabs/Lib/Activity.php | 8 +++++--- Zotlabs/Lib/Libzot.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4c856f336..13090338c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2280,18 +2280,20 @@ class Activity { if (! $n) { break; } - $a = new ActivityStreams($n); + // set client flag to convert objects to implied activities + $a = new ActivityStreams($n,null,true); if ($a->type === 'Announce' && is_array($a->obj) && array_key_exists('object',$a->obj) && array_key_exists('actor',$a->obj)) { // This is a relayed/forwarded Activity (as opposed to a shared/boosted object) // Reparse the encapsulated Activity and use that instead logger('relayed activity',LOGGER_DEBUG); - $a = new ActivityStreams($a->obj); + $a = new ActivityStreams($a->obj,null,true); } logger($a->debug()); if (! $a->is_valid()) { + logger('not a valid activity'); break; } if (is_array($a->actor) && array_key_exists('id',$a->actor)) { @@ -2300,7 +2302,7 @@ class Activity { $item = null; - switch($a->type) { + switch ($a->type) { case 'Create': case 'Update': case 'Like': diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 1ea965880..20c23d48a 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1050,7 +1050,7 @@ class Libzot { } if (! is_array($x)) { - btlogger('failed communication - no useful response: ' . $x); + logger('no useful response: ' . $x); } if ($x) { From dbf2541aacb0f69ecea17048ed2086f24585ebf5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 Oct 2019 16:48:46 -0700 Subject: [PATCH 6/8] rename hyperdrive setting, add acl patches from upstream --- Zotlabs/Module/Settings/Channel.php | 2 +- view/js/acl.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 12b1cb3d9..89685d235 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -512,7 +512,7 @@ class Channel { $autoperms = ''; } - $hyperdrive = [ 'hyperdrive', t('Enable hyperdrive'), ((get_pconfig(local_channel(),'system','hyperdrive',true)) ? 1 : 0), t('Import public third-party conversations in which your connections participate.'), $yes_no ]; + $hyperdrive = [ 'hyperdrive', t('Friend-of-friend conversations'), ((get_pconfig(local_channel(),'system','hyperdrive',true)) ? 1 : 0), t('Import public third-party conversations in which your connections participate.'), $yes_no ]; if (get_config('system','activitypub')) { $apconfig = true; diff --git a/view/js/acl.js b/view/js/acl.js index 730b515a0..9415113dd 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -207,7 +207,7 @@ ACL.prototype.on_button_hide = function(event) { ACL.prototype.set_allow = function(itemid) { type = itemid[0]; - id = itemid.substr(1); + id = decodeURIComponent(itemid.substr(1)); switch(type) { case "g": if (that.allow_gid.indexOf(id)<0) { @@ -231,7 +231,7 @@ ACL.prototype.set_allow = function(itemid) { ACL.prototype.set_deny = function(itemid) { type = itemid[0]; - id = itemid.substr(1); + id = decodeURIComponent(itemid.substr(1)); switch(type) { case "g": if (that.deny_gid.indexOf(id)<0) { @@ -310,8 +310,12 @@ ACL.prototype.update_view = function(value) { else { that.list.show(); //show acl-list + datasrc2src('#acl-list-content .list-group-item img[data-src]'); that.info.hide(); //hide acl-info that.update_select('custom'); + if(typeof value === 'undefined') { + value = 'custom'; + } /* jot acl */ if(that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'custom') { @@ -334,7 +338,7 @@ ACL.prototype.update_view = function(value) { $("#acl-list-content .acl-list-item").each(function() { itemid = $(this).attr('id'); type = itemid[0]; - id = itemid.substr(1); + id = decodeURIComponent(itemid.substr(1)); btshow = $(this).children(".acl-button-show").removeClass("btn-success").addClass("btn-outline-success"); bthide = $(this).children(".acl-button-hide").removeClass("btn-danger").addClass("btn-outline-danger"); From d70ff3bb22b85f4bb689f2ed06e31ad123bab09d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 Oct 2019 17:10:48 -0700 Subject: [PATCH 7/8] logic issue: mod_manage remove from menu --- view/tpl/channel.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/tpl/channel.tpl b/view/tpl/channel.tpl index b4bef83f3..70317e178 100755 --- a/view/tpl/channel.tpl +++ b/view/tpl/channel.tpl @@ -49,7 +49,7 @@ {{/if}}
{{if $channel.include_in_menu}} - +  {{$msg_no_include}} {{else}} From 5ec254ec892dd2d07f07d8440aedaaee47c74ffc Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 Oct 2019 17:49:32 -0700 Subject: [PATCH 8/8] rev update --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 057331f01..23b8fb055 100755 --- a/boot.php +++ b/boot.php @@ -48,7 +48,7 @@ require_once('include/items.php'); -define ( 'STD_VERSION', '19.10.5' ); +define ( 'STD_VERSION', '19.10.9' ); define ( 'ZOT_REVISION', '6.0' ); define ( 'DB_UPDATE_VERSION', 1236 );