From 368f88740a3bc6fca610ad0a0d6e68f86e7ef968 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 18 Apr 2017 17:26:50 -0700 Subject: envelope privacy --- Zotlabs/Daemon/Notifier.php | 60 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 63ced4f56..48f1d2757 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -5,6 +5,11 @@ namespace Zotlabs\Daemon; require_once('include/queue_fn.php'); require_once('include/html2plain.php'); require_once('include/conversation.php'); +require_once('include/zot.php'); +require_once('include/items.php'); +require_once('include/bbcode.php'); + + /* * This file was at one time responsible for doing all deliveries, but this caused @@ -68,13 +73,6 @@ require_once('include/conversation.php'); */ -require_once('include/zot.php'); -require_once('include/queue_fn.php'); -require_once('include/datetime.php'); -require_once('include/items.php'); -require_once('include/bbcode.php'); -require_once('include/channel.php'); - class Notifier { @@ -98,16 +96,6 @@ class Notifier { $deliveries = array(); - $dead_hubs = array(); - - $dh = q("select site_url from site where site_dead = 1"); - if($dh) { - foreach($dh as $dead) { - $dead_hubs[] = $dead['site_url']; - } - } - - $request = false; $mail = false; $top_level = false; @@ -489,10 +477,10 @@ class Notifier { // Now we have collected recipients (except for external mentions, FIXME) - // Let's reduce this to a set of hubs. + // Let's reduce this to a set of hubs; checking that the site is not dead. $r = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ") - and hubloc_error = 0 and hubloc_deleted = 0" + and hubloc_error = 0 and hubloc_deleted = 0 and site_dead = 0" ); @@ -506,23 +494,31 @@ class Notifier { /** - * Reduce the hubs to those that are unique. For zot hubs, we need to verify uniqueness by the sitekey, since it may have been - * a re-install which has not yet been detected and pruned. + * Reduce the hubs to those that are unique. For zot hubs, we need to verify uniqueness by the sitekey, + * since it may have been a re-install which has not yet been detected and pruned. * For other networks which don't have or require sitekeys, we'll have to use the URL */ - $hublist = array(); // this provides an easily printable list for the logs - $dhubs = array(); // delivery hubs where we store our resulting unique array - $keys = array(); // array of keys to check uniquness for zot hubs - $urls = array(); // array of urls to check uniqueness of hubs from other networks - + $hublist = []; // this provides an easily printable list for the logs + $dhubs = []; // delivery hubs where we store our resulting unique array + $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 foreach($hubs as $hub) { - if(in_array($hub['hubloc_url'],$dead_hubs)) { - logger('skipping dead hub: ' . $hub['hubloc_url'], LOGGER_DEBUG, LOG_INFO); - continue; + + if($env_recips) { + foreach($env_recips as $er) { + if($hub['hubloc_hash'] === $er['hash']) { + if(! array_key_exists($hub['hubloc_host'] . $hub['hubloc_sitekey'], $hub_env)) { + $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] = []; + } + $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']][] = $er; + } + } } + if($hub['hubloc_network'] == 'zot') { if(! in_array($hub['hubloc_sitekey'],$keys)) { @@ -603,7 +599,8 @@ class Notifier { $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } elseif($packet_type === 'request') { - $packet = zot_build_packet($channel,$packet_type,$env_recips,$hub['hubloc_sitekey'],$hub['site_crypto'], + $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); + $packet = zot_build_packet($channel,$packet_type,$env,$hub['hubloc_sitekey'],$hub['site_crypto'], $hash, array('message_id' => $request_message_id) ); } @@ -618,7 +615,8 @@ class Notifier { )); } else { - $packet = zot_build_packet($channel,'notify',$env_recips,(($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); + $packet = zot_build_packet($channel,'notify',$env,(($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); queue_insert(array( 'hash' => $hash, 'account_id' => $target_item['aid'], -- cgit v1.2.3 From 32eead15425d9e807e5cb85bc706e70f76329de5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 11 Apr 2017 22:02:29 -0700 Subject: webfinger cleanup --- Zotlabs/Module/Wfinger.php | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 04eed47c3..5c22772c4 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -38,6 +38,9 @@ class Wfinger extends \Zotlabs\Web\Controller { $channel = str_replace('acct:','',$resource); if(strpos($channel,'@') !== false) { $host = substr($channel,strpos($channel,'@')+1); + + // If the webfinger address points off site, redirect to the correct site + if(strcasecmp($host,\App::get_hostname())) { goaway('https://' . $host . '/.well-known/webfinger?f=&resource=' . $resource . (($zot) ? '&zot=' . $zot : '')); } @@ -77,54 +80,54 @@ class Wfinger extends \Zotlabs\Web\Controller { } } - $result['aliases'] = array(); + $result['aliases'] = []; - $result['properties'] = array( - 'http://webfinger.net/ns/name' => $r[0]['channel_name'], + $result['properties'] = [ + 'http://webfinger.net/ns/name' => $r[0]['channel_name'], 'http://xmlns.com/foaf/0.1/name' => $r[0]['channel_name'] - ); + ]; foreach($aliases as $alias) if($alias != $resource) $result['aliases'][] = $alias; - $result['links'] = array( + $result['links'] = [ - array( + [ 'rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_l'] - ), + ], - array( + [ 'rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address'], - ), + ], - array( + [ 'rel' => 'http://webfinger.net/rel/blog', 'href' => z_root() . '/channel/' . $r[0]['channel_address'], - ), + ], - array( + [ 'rel' => 'http://ostatus.org/schema/1.0/subscribe', 'template' => z_root() . '/follow/url={uri}', - ), + ], - array( + [ 'rel' => 'http://purl.org/zot/protocol', 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], - ), + ], - array( + [ 'rel' => 'magic-public-key', 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), - ) - ); + ] + ]; if($zot) { // get a zotinfo packet and return it with webfinger - $result['zot'] = zotinfo(array('address' => $r[0]['xchan_addr'])); + $result['zot'] = zotinfo( [ 'address' => $r[0]['xchan_addr'] ]); } } else { @@ -132,7 +135,7 @@ class Wfinger extends \Zotlabs\Web\Controller { killme(); } - $arr = array('channel' => $r[0], 'request' => $_REQUEST, 'result' => $result); + $arr = [ 'channel' => $r[0], 'request' => $_REQUEST, 'result' => $result ]; call_hooks('webfinger',$arr); json_return_and_die($arr['result'],'application/jrd+json'); -- cgit v1.2.3 From f174c4fccb92388a8f3ce43472da29ea02f2be35 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 11 Apr 2017 23:05:56 -0700 Subject: don't allow any null fields in notify creation --- Zotlabs/Lib/Enotify.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 5db5fb42d..a10675a87 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -495,13 +495,14 @@ class Enotify { } } - $r = q("insert into notify (hash,xname,url,photo,created,aid,uid,link,parent,seen,ntype,verb,otype) - values('%s','%s','%s','%s','%s',%d,%d,'%s','%s',%d,%d,'%s','%s')", + $r = q("insert into notify (hash,xname,url,photo,created,msg,aid,uid,link,parent,seen,ntype,verb,otype) + values('%s','%s','%s','%s','%s','%s',%d,%d,'%s','%s',%d,%d,'%s','%s')", dbesc($datarray['hash']), dbesc($datarray['xname']), dbesc($datarray['url']), dbesc($datarray['photo']), dbesc($datarray['created']), + dbesc(''), // will fill this in below after the record is created intval($datarray['aid']), intval($datarray['uid']), dbesc($datarray['link']), -- cgit v1.2.3 From a3b1eec5484eef8e2872df139cdd868222c95dda Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 12 Apr 2017 17:32:28 -0700 Subject: backend infrastructure for 'channel protection password'; which will be used to optionally encrypt export files and resolve channel/identity ownership/hijacking disputes --- install/schema_postgres.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index be72a85e1..1a5fe942f 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -170,7 +170,7 @@ CREATE TABLE "attach" ( "is_photo" smallint NOT NULL DEFAULT '0', "os_storage" smallint NOT NULL DEFAULT '0', "os_path" text NOT NULL, - "display_path" text NOT NULL, +4 "display_path" text NOT NULL, "content" bytea NOT NULL, "created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', -- cgit v1.2.3 From d3feb93619b7e453d07710e0e32c3049eed85bcc Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 12 Apr 2017 18:48:06 -0700 Subject: typo --- install/schema_postgres.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index 1a5fe942f..be72a85e1 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -170,7 +170,7 @@ CREATE TABLE "attach" ( "is_photo" smallint NOT NULL DEFAULT '0', "os_storage" smallint NOT NULL DEFAULT '0', "os_path" text NOT NULL, -4 "display_path" text NOT NULL, + "display_path" text NOT NULL, "content" bytea NOT NULL, "created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "edited" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', -- cgit v1.2.3 From 09967598e15eb5d201bcc676ffb329b97e1b89b8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 19 Apr 2017 10:51:50 +0200 Subject: order wiki pages by creation date --- Zotlabs/Lib/NativeWikiPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 960fe014e..bd40367c9 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -21,7 +21,7 @@ class NativeWikiPage { $sql_extra = item_permissions_sql($channel_id,$observer_hash); $r = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s' and uid = %d and item_deleted = 0 - $sql_extra group by mid", + $sql_extra group by mid order by created asc", dbesc($resource_id), intval($channel_id) ); -- cgit v1.2.3