From b289de1d0e2eb0122b49ed74f17cd9c1fea93749 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 11 Oct 2020 15:41:49 -0700 Subject: [PATCH 1/6] more virtual lists --- Zotlabs/Lib/AccessList.php | 29 +++++++++++++++ Zotlabs/Module/Stream.php | 56 +++++++++++++++++++++-------- Zotlabs/Widget/Activity_filter.php | 58 +++++++++++++++++++++++------- 3 files changed, 115 insertions(+), 28 deletions(-) diff --git a/Zotlabs/Lib/AccessList.php b/Zotlabs/Lib/AccessList.php index 7b33b91df..a64f76825 100644 --- a/Zotlabs/Lib/AccessList.php +++ b/Zotlabs/Lib/AccessList.php @@ -221,6 +221,35 @@ class AccessList { $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($records), intval($start)); } + // process virtual groups + if (strpos($gid,':') === 0) { + $vg = substr($gid,1); + switch ($vg) { + case '1': + $sql_extra = EMPTY_STR; + break; + case '2': + $sql_extra = " and xchan_network = 'zot6' "; + break; + case '3': + $sql_extra = " and xchan_network = 'activitypub' "; + break; + default: + break; + } + if ($total) { + $r = q("SELECT count(*) FROM abook left join xchan on xchan_hash = abook_xchan WHERE abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 $sql_extra ORDER BY xchan_name ASC $pager_sql", + intval($uid) + ); + return ($r) ? $r[0]['total'] : false; + } + $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan + WHERE abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 $sql_extra ORDER BY xchan_name ASC $pager_sql", + intval($uid) + ); + return $r; + } + if (intval($gid)) { if ($total) { $r = q("SELECT count(xchan) as total FROM pgrp_member diff --git a/Zotlabs/Module/Stream.php b/Zotlabs/Module/Stream.php index ac5bb9b33..552e2f966 100644 --- a/Zotlabs/Module/Stream.php +++ b/Zotlabs/Module/Stream.php @@ -67,7 +67,7 @@ class Stream extends Controller { $datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); $datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); $static = ((x($_GET,'static')) ? intval($_GET['static']) : 0); - $gid = ((x($_GET,'gid')) ? intval($_GET['gid']) : 0); + $gid = ((x($_GET,'gid')) ? $_REQUEST($_GET['gid']) : 0); $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); @@ -110,18 +110,41 @@ class Stream extends Controller { } // filter by collection (e.g. group) - + + $vg = false; + if ($gid) { - $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1", - intval($gid), - intval(local_channel()) - ); - if (! $r) { - if ($update) { - killme(); + if (strpos($gid,':') === 0) { + $g = substr($gid,1); + switch ($g) { + case '1': + $r = [ 'hash' => 'connections:' . $channel['channel_hash'] ]; + $vg = t('Connections'); + break; + case '2': + $r = [ 'hash' => 'zot:' . $channel['channel_hash'] ]; + $vg = t('Zot'); + break; + case '3': + $r = [ 'hash' => 'activitypub:' . $channel['channel_hash'] ]; + $vg = t('ActivityPub'); + break; + default: + break; + } + } + else { + $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1", + intval($gid), + intval(local_channel()) + ); + if (! $r) { + if ($update) { + killme(); + } + notice( t('Access list not found') . EOL ); + goaway(z_root() . '/stream'); } - notice( t('Access list not found') . EOL ); - goaway(z_root() . '/stream'); } $group = $gid; @@ -257,12 +280,15 @@ class Stream extends Controller { $item_thread_top = ''; $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) "; + + + if (! $vg) { + $x = AccessList::rec_byhash(local_channel(), $group_hash); + } - $x = AccessList::rec_byhash(local_channel(), $group_hash); - - if ($x) { + if ($x || $vg) { $title = replace_macros(get_markup_template("section_title.tpl"),array( - '$title' => sprintf( t('Access list: %s'), $x['gname']) + '$title' => sprintf( t('Access list: %s'), (($vg) ? $vg : $x['gname'])) )); } diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index b4782e599..b4feb2adf 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -3,7 +3,7 @@ namespace Zotlabs\Widget; use App; - +use Zotlabs\Lib\Apps; class Activity_filter { @@ -85,19 +85,51 @@ class Activity_filter { intval(local_channel()) ); - if($groups) { - foreach($groups as $g) { - if(x($_GET,'gid')) { - $group_active = (($_GET['gid'] == $g['id']) ? 'active' : ''); - $filter_active = 'group'; + if($groups || Apps::system_app_installed(local_channel(),'Virtual Lists')) { + if ($groups) { + foreach($groups as $g) { + if(x($_GET,'gid')) { + $group_active = (($_GET['gid'] == $g['id']) ? 'active' : ''); + $filter_active = 'group'; + } + $gsub[] = [ + 'label' => $g['gname'], + 'icon' => '', + 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $g['id'], + 'sel' => $group_active, + 'title' => sprintf(t('Show posts related to the %s access list'), $g['gname']) + ]; + } + } + if (Apps::system_app_installed($channel['channel_id'],'Virtual Lists')) { + foreach ([ ':1', ':2', ':3' ] as $l) { + switch ($l) { + case ':1': + $gname = t('Connections'); + break; + case ':2': + $gname = t('Zot'); + break; + case ':3': + $gname = t('ActivityPub'); + break; + default: + break; + } + + if(x($_GET,'gid')) { + $group_active = (($_GET['gid'] == $l) ? 'active' : ''); + $filter_active = 'group'; + } + + $gsub[] = [ + 'label' => $gname, + 'icon' => '', + 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $l, + 'sel' => $group_active, + 'title' => sprintf(t('Show posts related to the %s access list'), $gname) + ]; } - $gsub[] = [ - 'label' => $g['gname'], - 'icon' => '', - 'url' => z_root() . '/' . $cmd . '/?f=&gid=' . $g['id'], - 'sel' => $group_active, - 'title' => sprintf(t('Show posts related to the %s access list'), $g['gname']) - ]; } $tabs[] = [ 'id' => 'privacy_groups', From 590ed7041874744b690750421500a103ca27e56a Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 11 Oct 2020 16:07:28 -0700 Subject: [PATCH 2/6] virtual list fixes --- Zotlabs/Lib/AccessList.php | 8 +++++++- Zotlabs/Module/Stream.php | 2 +- view/tpl/build_query.tpl | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Lib/AccessList.php b/Zotlabs/Lib/AccessList.php index a64f76825..245357beb 100644 --- a/Zotlabs/Lib/AccessList.php +++ b/Zotlabs/Lib/AccessList.php @@ -242,11 +242,17 @@ class AccessList { intval($uid) ); return ($r) ? $r[0]['total'] : false; - } + } + $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan WHERE abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 $sql_extra ORDER BY xchan_name ASC $pager_sql", intval($uid) ); + if ($r) { + for($x = 0; $x < count($r); $x ++) { + $r[$x]['xchan'] = $r[$x]['abook_xchan']; + } + } return $r; } diff --git a/Zotlabs/Module/Stream.php b/Zotlabs/Module/Stream.php index 552e2f966..d64229bbf 100644 --- a/Zotlabs/Module/Stream.php +++ b/Zotlabs/Module/Stream.php @@ -67,7 +67,7 @@ class Stream extends Controller { $datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); $datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); $static = ((x($_GET,'static')) ? intval($_GET['static']) : 0); - $gid = ((x($_GET,'gid')) ? $_REQUEST($_GET['gid']) : 0); + $gid = ((x($_GET,'gid')) ? $_REQUEST['gid'] : 0); $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl index 01852500b..87bed9716 100755 --- a/view/tpl/build_query.tpl +++ b/view/tpl/build_query.tpl @@ -4,7 +4,8 @@ var bParam_uid = {{$uid}}; - var bParam_gid = {{$gid}}; + // lists can be either type string (virtual lists) or integer (normal accesslists) + var bParam_gid = "{{$gid}}"; var bParam_cid = {{$cid}}; var bParam_cmin = {{$cmin}}; var bParam_cmax = {{$cmax}}; From 75169ede9b6aa7657a67cb0b64ad534f63d06bcd Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 11 Oct 2020 22:31:30 -0700 Subject: [PATCH 3/6] issue with activity_filter widget and virtual lists --- Zotlabs/Widget/Activity_filter.php | 2 +- boot.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index b4feb2adf..97370a6ef 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -101,7 +101,7 @@ class Activity_filter { ]; } } - if (Apps::system_app_installed($channel['channel_id'],'Virtual Lists')) { + if (Apps::system_app_installed(local_channel(),'Virtual Lists')) { foreach ([ ':1', ':2', ':3' ] as $l) { switch ($l) { case ':1': diff --git a/boot.php b/boot.php index a63720664..8fb6ec13a 100755 --- a/boot.php +++ b/boot.php @@ -16,7 +16,7 @@ use Zotlabs\Daemon\Run; * @brief This file defines some global constants and includes the central App class. */ -define ( 'STD_VERSION', '20.10.06' ); +define ( 'STD_VERSION', '20.10.12' ); define ( 'ZOT_REVISION', '6.0' ); define ( 'DB_UPDATE_VERSION', 1243 ); From 1b22ce2efe5a65c1a97ef94af4b866ec187c91cb Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 12 Oct 2020 16:25:11 -0700 Subject: [PATCH 4/6] mark dead AP sites alive if we hear from them --- Zotlabs/Module/Inbox.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Zotlabs/Module/Inbox.php b/Zotlabs/Module/Inbox.php index 293441280..55f247b01 100644 --- a/Zotlabs/Module/Inbox.php +++ b/Zotlabs/Module/Inbox.php @@ -139,6 +139,12 @@ class Inbox extends Controller { dbesc(datetime_convert()), dbesc($observer_hash) ); + $m = parse_url($observer_hash); + if ($m['scheme'] && $m['host']) { + $test = q("update site set site_dead = 0 where site_dead = 1 and site_url = '%s' ", + dbesc($m['scheme'] . '://' . $m['host']) + ); + } if ($is_public) { From b6e2e7aff43e320b060827e33840b964a1dbd1da Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 12 Oct 2020 19:56:07 -0700 Subject: [PATCH 5/6] include dead sites in delivery reports --- Zotlabs/Daemon/Notifier.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 05337d3db..2209a4c43 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -556,8 +556,8 @@ class Notifier { } } if (! $found_localhost) { - $localhub = q("select hubloc.*, site.site_crypto, site.site_flags from hubloc left join site on site_url = hubloc_url - where hubloc_id_url = '%s' and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) ", + $localhub = q("select hubloc.*, site.site_crypto, site.site_flags, site.site_dead from hubloc + left join site on site_url = hubloc_url where hubloc_id_url = '%s' and hubloc_error = 0 and hubloc_deleted = 0 ", dbesc(z_root() . '/channel/sys') ); if ($localhub) { @@ -583,8 +583,13 @@ class Notifier { $keys = []; // array of keys to check uniquness for zot hubs $urls = []; // array of urls to check uniqueness of hubs from other networks $hub_env = []; // per-hub envelope so we don't broadcast the entire envelope to all + $dead = []; // known dead hubs - report them as undeliverable foreach ($hubs as $hub) { + if (intval($hub['site_dead'])) { + $dead[] = $hub; + continue; + } if (self::$env_recips) { foreach (self::$env_recips as $er) { @@ -720,9 +725,31 @@ class Notifier { do_delivery(self::$deliveries); } + if ($dead) { + foreach ($dead as $deceased) { + if (is_array($target_item) && (! $target_item['item_deleted']) && (! get_config('system','disable_dreport'))) { + q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan, dreport_queue ) + values ( '%s', '%s','%s','%s','%s','%s','%s','%s' ) ", + dbesc($target_item['mid']), + dbesc($deceased['hubloc_host']), + dbesc($deceased['hubloc_host']), + dbesc($deceased['hubloc_host']), + dbesc('undeliverable/unresponsive site'), + dbesc(datetime_convert()), + dbesc(self::$channel['channel_hash']), + dbesc(new_uuid()) + ); + } + } + } + call_hooks('notifier_end',$target_item); logger('notifer: complete.'); + + + + return; } From 29857253bcd53398cd618bcd21c0e4f8e9481393 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 13 Oct 2020 19:16:18 -0700 Subject: [PATCH 6/6] version --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 8fb6ec13a..a141a5d33 100755 --- a/boot.php +++ b/boot.php @@ -16,7 +16,7 @@ use Zotlabs\Daemon\Run; * @brief This file defines some global constants and includes the central App class. */ -define ( 'STD_VERSION', '20.10.12' ); +define ( 'STD_VERSION', '20.10.14' ); define ( 'ZOT_REVISION', '6.0' ); define ( 'DB_UPDATE_VERSION', 1243 );