From b4efe8ad8d91c70bf869259e6764e7e4a079563b Mon Sep 17 00:00:00 2001 From: git-marijus Date: Mon, 31 Jul 2017 02:24:49 +0200 Subject: implement system configs as app requirement and add the pubstream app --- Zotlabs/Lib/Apps.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 68587df49..7287bdd52 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -169,6 +169,7 @@ class Apps { $requires = explode(',',$ret['requires']); foreach($requires as $require) { $require = trim(strtolower($require)); + $toggle = (($require[0] == '!') ? 0 : 1); switch($require) { case 'nologin': if(local_channel()) @@ -191,10 +192,12 @@ class Apps { unset($ret); break; default: - if(! (local_channel() && feature_enabled(local_channel(),$require))) + $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); + $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); + + if($unset) unset($ret); break; - } } } @@ -307,6 +310,7 @@ class Apps { $requires = explode(',',$v); foreach($requires as $require) { $require = trim(strtolower($require)); + $toggle = (($require[0] == '!') ? 0 : 1); switch($require) { case 'nologin': if(local_channel()) @@ -330,10 +334,12 @@ class Apps { return ''; break; default: - if(! (local_channel() && feature_enabled(local_channel(),$require))) + $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); + $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); + + if($unset) return ''; break; - } } } -- cgit v1.2.3 From 1f2482f6abf5986ebf4b9ee292ba229a4a3b6797 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Tue, 1 Aug 2017 03:38:41 +0200 Subject: correct the logic for configs in app requirement --- Zotlabs/Lib/Apps.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 7287bdd52..1fb841008 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -169,7 +169,15 @@ class Apps { $requires = explode(',',$ret['requires']); foreach($requires as $require) { $require = trim(strtolower($require)); + $config = false; + + if(substr($require, 0, 7) == 'config:') { + $config = true; + $require = ltrim($require, 'config:'); + } + $toggle = (($require[0] == '!') ? 0 : 1); + switch($require) { case 'nologin': if(local_channel()) @@ -192,9 +200,10 @@ class Apps { unset($ret); break; default: - $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); - $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); - + if($config) + $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); + else + $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); if($unset) unset($ret); break; @@ -308,9 +317,18 @@ class Apps { if($k === 'requires') { $requires = explode(',',$v); + foreach($requires as $require) { $require = trim(strtolower($require)); + $config = false; + + if(substr($require, 0, 7) == 'config:') { + $config = true; + $require = ltrim($require, 'config:'); + } + $toggle = (($require[0] == '!') ? 0 : 1); + switch($require) { case 'nologin': if(local_channel()) @@ -334,9 +352,10 @@ class Apps { return ''; break; default: - $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); - $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); - + if($config) + $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); + else + $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); if($unset) return ''; break; -- cgit v1.2.3 From a97b09210e977d52a5bda1dee2b1eddc19afc013 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 1 Aug 2017 18:05:04 -0700 Subject: auto preview when inserting a media item or embed into a post. Since this unanticipated action could be alarming (some might think the post was actually submitted), also provide a visible preview indicator within the previewed content. Remove the css for the old striped background image which hasn't been available for previewed content for a year or two. --- Zotlabs/Lib/ThreadItem.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 72d8af4dd..9ee16480a 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -407,6 +407,7 @@ class ThreadItem { 'showdislike' => $showdislike, 'comment' => $this->get_comment_box($indent), 'previewing' => ($conv->is_preview() ? true : false ), + 'preview_lbl' => t('This is an unsaved preview'), 'wait' => t('Please wait'), 'submid' => str_replace(['+','='], ['',''], base64_encode(substr($item['mid'],0,32))), 'thread_level' => $thread_level -- cgit v1.2.3 From 1c0c01ccfe918d0d5eea8fcbba6d5a59d1ab5c84 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sun, 6 Aug 2017 23:20:24 +0200 Subject: make config requirements in apps more universal - provide key and value --- Zotlabs/Lib/Apps.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 1fb841008..3730f3a23 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -174,10 +174,9 @@ class Apps { if(substr($require, 0, 7) == 'config:') { $config = true; $require = ltrim($require, 'config:'); + $require = explode('=', $require); } - $toggle = (($require[0] == '!') ? 0 : 1); - switch($require) { case 'nologin': if(local_channel()) @@ -201,7 +200,7 @@ class Apps { break; default: if($config) - $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); + $unset = ((get_config('system', $require[0]) == $require[1]) ? false : true); else $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); if($unset) @@ -325,10 +324,9 @@ class Apps { if(substr($require, 0, 7) == 'config:') { $config = true; $require = ltrim($require, 'config:'); + $require = explode('=', $require); } - $toggle = (($require[0] == '!') ? 0 : 1); - switch($require) { case 'nologin': if(local_channel()) @@ -353,7 +351,7 @@ class Apps { break; default: if($config) - $unset = ((get_config('system', ltrim($require, '!')) == $toggle) ? false : true); + $unset = ((get_config('system', $require[0]) == $require[1]) ? false : true); else $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); if($unset) -- cgit v1.2.3 From ca11d7b9a76c41c7cea0dbec1befacb0ff182de2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 Aug 2017 22:55:47 -0700 Subject: support upload of files and attachments into comments. This has some repercussions when it comes to post permissions since the commenter will not know the distribution of the post. Basically the files will be uploaded with the commenter's default ACL. Most of the time this will do the right thing. --- Zotlabs/Lib/ThreadItem.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 9ee16480a..a705e3c2b 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -735,6 +735,7 @@ class ThreadItem { '$edquote' => t('Quote'), '$edcode' => t('Code'), '$edimg' => t('Image'), + '$edatt' => t('Attach File'), '$edurl' => t('Insert Link'), '$edvideo' => t('Video'), '$preview' => t('Preview'), // ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), -- cgit v1.2.3 From 8eb6dafe312746ea85ccdd0544b17241b2f95a9c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 Aug 2017 23:12:08 -0700 Subject: only show upload button to those with write_storage permission --- Zotlabs/Lib/ThreadItem.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index a705e3c2b..3e76890b6 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -740,6 +740,7 @@ class ThreadItem { '$edvideo' => t('Video'), '$preview' => t('Preview'), // ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), '$indent' => $indent, + '$can_upload' => perm_is_allowed($conv->get_profile_owner(),get_observer_hash(),'write_storage'), '$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false), '$encrypt' => t('Encrypt text'), '$cipher' => $conv->get_cipher(), -- cgit v1.2.3 From 6531cbd1d286738acb9448b141bf4d7d5f97ccf3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 9 Aug 2017 17:35:03 -0700 Subject: libxml errors --- Zotlabs/Lib/ThreadItem.php | 1 - Zotlabs/Lib/ThreadStream.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 3e76890b6..4a66c84bc 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -713,7 +713,6 @@ class ThreadItem { call_hooks('comment_buttons',$arr); $comment_buttons = $arr['comment_buttons']; - $comment_box = replace_macros($template,array( '$return_path' => '', '$threaded' => $this->is_threaded(), diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 1fd746c38..35ccf4fdb 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -18,6 +18,7 @@ class ThreadStream { private $observer = null; private $writable = false; private $commentable = false; + private $uploadable = false; private $profile_owner = 0; private $preview = false; private $prepared_item = ''; -- cgit v1.2.3 From 568690186961d2946543c8320faf5575758acfca Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 9 Aug 2017 22:45:52 -0700 Subject: some doco fixes and other real minor stuff to improve logreading ability --- Zotlabs/Lib/PConfig.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php index 25478e764..2a0b18aac 100644 --- a/Zotlabs/Lib/PConfig.php +++ b/Zotlabs/Lib/PConfig.php @@ -20,11 +20,12 @@ class PConfig { if(is_null($uid) || $uid === false) return false; - if(! array_key_exists($uid, \App::$config)) - \App::$config[$uid] = array(); - if(! is_array(\App::$config)) { - btlogger('App::$config not an array: ' . $uid); + btlogger('App::$config not an array'); + } + + if(! array_key_exists($uid, \App::$config)) { + \App::$config[$uid] = array(); } if(! is_array(\App::$config[$uid])) { -- cgit v1.2.3 From 1408e3da3bcb818134b76db338fb913ae0b54aa1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 10 Aug 2017 21:08:07 -0700 Subject: prevent uploads to comments if the channel has a default private ACL. --- Zotlabs/Lib/ThreadItem.php | 2 +- Zotlabs/Lib/ThreadStream.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 4a66c84bc..2a9a7e779 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -739,7 +739,7 @@ class ThreadItem { '$edvideo' => t('Video'), '$preview' => t('Preview'), // ((feature_enabled($conv->get_profile_owner(),'preview')) ? t('Preview') : ''), '$indent' => $indent, - '$can_upload' => perm_is_allowed($conv->get_profile_owner(),get_observer_hash(),'write_storage'), + '$can_upload' => (perm_is_allowed($conv->get_profile_owner(),get_observer_hash(),'write_storage') && $conv->is_uploadable()), '$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false), '$encrypt' => t('Encrypt text'), '$cipher' => $conv->get_cipher(), diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 35ccf4fdb..0465b20ef 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -28,9 +28,10 @@ class ThreadStream { // wherein we've already prepared a top level item which doesn't look anything like // a normal "post" item - public function __construct($mode, $preview, $prepared_item = '') { + public function __construct($mode, $preview, $uploadable, $prepared_item = '') { $this->set_mode($mode); $this->preview = $preview; + $this->uploadable = $uploadable; $this->prepared_item = $prepared_item; $c = ((local_channel()) ? get_pconfig(local_channel(),'system','default_cipher') : ''); if($c) @@ -61,6 +62,7 @@ class ThreadStream { // pull some trickery which allows us to re-invoke this function afterward // it's an ugly hack so @FIXME $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); + $this->uploadable = false; break; case 'page': $this->profile_owner = \App::$profile['uid']; @@ -92,6 +94,11 @@ class ThreadStream { return $this->commentable; } + public function is_uploadable() { + return $this->uploadable; + } + + /** * Check if page is a preview */ -- cgit v1.2.3 From 4848dc5ec8f943348f5263632ea24990fdef6a77 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sat, 12 Aug 2017 22:29:57 +0200 Subject: minor js and css changes --- Zotlabs/Lib/ThreadItem.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 2a9a7e779..ad944203c 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -746,9 +746,9 @@ class ThreadItem { '$sourceapp' => \App::$sourcename, '$observer' => get_observer_hash(), '$anoncomments' => (($conv->get_mode() === 'channel' && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), - '$anonname' => [ 'anonname', t('Your full name (required)'),'','' ], - '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','' ], - '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','' ] + '$anonname' => [ 'anonname', t('Your full name (required)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ], + '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ], + '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ] )); return $comment_box; -- cgit v1.2.3 From 65a320c5091c6aaac86b0de661b5eac8a0e9521d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 17 Aug 2017 16:53:14 -0700 Subject: move activitystreams parser back to core; we will eventually need it in core utilities --- Zotlabs/Lib/ActivityStreams.php | 94 ++++++++++++++++++++++++++++++++++++++++ Zotlabs/Lib/ActivityStreams2.php | 86 ------------------------------------ 2 files changed, 94 insertions(+), 86 deletions(-) create mode 100644 Zotlabs/Lib/ActivityStreams.php delete mode 100644 Zotlabs/Lib/ActivityStreams2.php (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php new file mode 100644 index 000000000..2b610c7a4 --- /dev/null +++ b/Zotlabs/Lib/ActivityStreams.php @@ -0,0 +1,94 @@ +data = json_decode($string,true); + if($this->data) { + $this->valid = true; + } + + if($this->is_valid()) { + $this->id = $this->get_property_obj('id'); + $this->type = $this->get_primary_type(); + $this->actor = $this->get_compound_property('actor'); + $this->obj = $this->get_compound_property('object'); + $this->tgt = $this->get_compound_property('target'); + $this->origin = $this->get_compound_property('origin'); + + if(($this->type === 'Note') && (! $this->obj)) { + $this->obj = $this->data; + $this->type = 'Create'; + } + } + } + + function is_valid() { + return $this->valid; + } + + function get_property_obj($property,$base = '') { + $base = (($base) ? $base : $this->data); + return ((array_key_exists($property,$base)) ? $base[$property] : null); + } + + function fetch_property($url) { + $redirects = 0; + if(! check_siteallowed($url)) { + logger('blacklisted: ' . $url); + return null; + } + + $x = z_fetch_url($url,true,$redirects, + ['headers' => [ 'Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); + if($x['success']) + return json_decode($x['body'],true); + return null; + } + + function get_compound_property($property,$base = '') { + $x = $this->get_property_obj($property,$base); + if($this->is_url($x)) { + $x = $this->fetch_property($x); + } + return $x; + } + + function is_url($url) { + if(($url) && (! is_array($url)) && (strpos($url,'http') === 0)) { + return true; + } + return false; + } + + function get_primary_type($base = '') { + if(! $base) + $base = $this->data; + $x = $this->get_property_obj('type',$base); + if(is_array($x)) { + foreach($x as $y) { + if(strpos($y,':') === false) { + return $y; + } + } + } + return $x; + } + + function debug() { + $x = var_export($this,true); + return $x; + } + +} \ No newline at end of file diff --git a/Zotlabs/Lib/ActivityStreams2.php b/Zotlabs/Lib/ActivityStreams2.php deleted file mode 100644 index 904782bf7..000000000 --- a/Zotlabs/Lib/ActivityStreams2.php +++ /dev/null @@ -1,86 +0,0 @@ -data = json_decode($string,true); - if($this->data) { - $this->valid = true; - } - - if($this->is_valid()) { - $this->id = $this->get_property_obj('id'); - $this->type = $this->get_primary_type(); - $this->actor = $this->get_compound_property('actor'); - $this->obj = $this->get_compound_property('object'); - $this->tgt = $this->get_compound_property('target'); - } - } - - function is_valid() { - return $this->valid; - } - - function get_property_obj($property,$base = '') { - if(! $base) { - $base = $this->data; - } - return $base[$property]; - } - - function fetch_property($url) { - $redirects = 0; - $x = z_fetch_url($url,true,$redirects, - ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); - if($x['success']) - return json_decode($x['body'],true); - return null; - } - - function get_compound_property($property,$base = '') { - $x = $this->get_property_obj($property,$base); - if($this->is_url($x)) { - $x = $this->fetch_property($x); - } - return $x; - } - - function is_url($url) { - if(($url) && (! is_array($url)) && (strpos($url,'http') === 0)) { - return true; - } - return false; - } - - function get_primary_type($base = '') { - if(! $base) - $base = $this->data; - $x = $this->get_property_obj('type',$base); - if(is_array($x)) { - foreach($x as $y) { - if(strpos($y,':') === false) { - return $y; - } - } - } - return $x; - } - - function debug() { - $x = var_export($this,true); - return $x; - } - -} \ No newline at end of file -- cgit v1.2.3 From f15d96bebe754d9cb38b1e043a30521d9fbcd668 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 20 Aug 2017 19:40:37 -0700 Subject: add namespaces to activitystreams parser --- Zotlabs/Lib/ActivityStreams.php | 65 +++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 2b610c7a4..3bbe3b190 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -5,12 +5,14 @@ namespace Zotlabs\Lib; class ActivityStreams { public $data; - public $valid = false; - public $id = ''; - public $type = ''; - public $actor = null; - public $obj = null; - public $tgt = null; + public $valid = false; + public $id = ''; + public $type = ''; + public $actor = null; + public $obj = null; + public $tgt = null; + public $origin = null; + public $owner = null; function __construct($string) { @@ -26,6 +28,7 @@ class ActivityStreams { $this->obj = $this->get_compound_property('object'); $this->tgt = $this->get_compound_property('target'); $this->origin = $this->get_compound_property('origin'); + $this->owner = $this->get_compound_property('owner','','http://purl.org/zot/protocol'); if(($this->type === 'Note') && (! $this->obj)) { $this->obj = $this->data; @@ -38,9 +41,47 @@ class ActivityStreams { return $this->valid; } - function get_property_obj($property,$base = '') { + function get_namespace($base,$namespace) { + + $key = null; + + foreach( [ $this->data, $base ] as $b ) { + if(! $b) + continue; + if(array_key_exists('@context',$b)) { + if(is_array($b['@context'])) { + foreach($b['@context'] as $ns) { + if(is_array($ns)) { + foreach($ns as $k => $v) { + if($namespace === $v) + $key = $k; + } + } + else { + if($namespace === $ns) { + $key = ''; + } + } + } + } + else { + if($namespace === $b['@context']) { + $key = ''; + } + } + } + } + return $key; + } + + + function get_property_obj($property,$base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + $prefix = $this->get_namespace($base,$namespace); + if($prefix === null) + return null; $base = (($base) ? $base : $this->data); - return ((array_key_exists($property,$base)) ? $base[$property] : null); + $propname = (($prefix) ? $prefix . ':' : '') . $property; + return ((array_key_exists($propname,$base)) ? $base[$propname] : null); } function fetch_property($url) { @@ -57,8 +98,8 @@ class ActivityStreams { return null; } - function get_compound_property($property,$base = '') { - $x = $this->get_property_obj($property,$base); + function get_compound_property($property,$base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + $x = $this->get_property_obj($property,$base,$namespace); if($this->is_url($x)) { $x = $this->fetch_property($x); } @@ -72,10 +113,10 @@ class ActivityStreams { return false; } - function get_primary_type($base = '') { + function get_primary_type($base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { if(! $base) $base = $this->data; - $x = $this->get_property_obj('type',$base); + $x = $this->get_property_obj('type',$base,$namespace); if(is_array($x)) { foreach($x as $y) { if(strpos($y,':') === false) { -- cgit v1.2.3 From e084b776eee9f1fc66e3f4a37b92ec70ccc49286 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 00:01:02 -0700 Subject: cards feature --- Zotlabs/Lib/Apps.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 3730f3a23..37cbf9497 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -221,6 +221,7 @@ class Apps { static public function translate_system_apps(&$arr) { $apps = array( 'Apps' => t('Apps'), + 'Cards' => t('Cards'), 'Site Admin' => t('Site Admin'), 'Report Bug' => t('Report Bug'), 'View Bookmarks' => t('View Bookmarks'), -- cgit v1.2.3 From 3b68df1be6173cbcc50386efc0161ece2015112d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 17:46:20 -0700 Subject: several card enhancements --- Zotlabs/Lib/ThreadItem.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index ad944203c..526169e1b 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -101,10 +101,13 @@ class ThreadItem { if($item['author']['xchan_network'] === 'rss') $shareable = true; + $mode = $conv->get_mode(); + $edlink = (($item['item_type'] == ITEM_TYPE_CARD) ? 'card_edit' : 'editpost'); + if(local_channel() && $observer['xchan_hash'] === $item['author_xchan']) - $edpost = array(z_root()."/editpost/".$item['id'], t("Edit")); + $edpost = array(z_root() . '/' . $edlink . '/' . $item['id'], t('Edit')); else $edpost = false; -- cgit v1.2.3 From e157e3bec8722c04ed8dc2d215cd2efd0ce3ce79 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 23 Aug 2017 22:06:42 -0700 Subject: cards: make page load after comment post --- Zotlabs/Lib/ThreadItem.php | 11 ++++++++++- Zotlabs/Lib/ThreadStream.php | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 526169e1b..313001cc7 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -29,6 +29,7 @@ class ThreadItem { private $visiting = false; private $channel = null; private $display_mode = 'normal'; + private $reload = ''; public function __construct($data) { @@ -483,6 +484,14 @@ class ThreadItem { return $this->threaded; } + public function set_reload($val) { + $this->reload = $val; + } + + public function get_reload() { + return $this->reload; + } + public function set_commentable($val) { $this->commentable = $val; foreach($this->get_children() as $child) @@ -719,7 +728,7 @@ class ThreadItem { $comment_box = replace_macros($template,array( '$return_path' => '', '$threaded' => $this->is_threaded(), - '$jsreload' => '', //(($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''), + '$jsreload' => $conv->reload, '$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'), '$id' => $this->get_id(), '$parent' => $this->get_id(), diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 0465b20ef..d7a898704 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -22,6 +22,7 @@ class ThreadStream { private $profile_owner = 0; private $preview = false; private $prepared_item = ''; + public $reload = ''; private $cipher = 'aes256'; // $prepared_item is for use by alternate conversation structures such as photos @@ -57,6 +58,11 @@ class ThreadStream { $this->profile_owner = \App::$profile['profile_uid']; $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); break; + case 'cards': + $this->profile_owner = \App::$profile['profile_uid']; + $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); + $this->reload = $_SESSION['return_url']; + break; case 'display': // in this mode we set profile_owner after initialisation (from conversation()) and then // pull some trickery which allows us to re-invoke this function afterward -- cgit v1.2.3 From 6385d11b5489d3d3cf0c8200e689276824af148e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 27 Aug 2017 21:46:10 -0700 Subject: AS2: recipient collection --- Zotlabs/Lib/ActivityStreams.php | 43 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 3bbe3b190..686f4a140 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -14,6 +14,8 @@ class ActivityStreams { public $origin = null; public $owner = null; + public $recips = null; + function __construct($string) { $this->data = json_decode($string,true); @@ -28,7 +30,7 @@ class ActivityStreams { $this->obj = $this->get_compound_property('object'); $this->tgt = $this->get_compound_property('target'); $this->origin = $this->get_compound_property('origin'); - $this->owner = $this->get_compound_property('owner','','http://purl.org/zot/protocol'); + $this->recips = $this->collect_recips(); if(($this->type === 'Note') && (! $this->obj)) { $this->obj = $this->data; @@ -41,6 +43,45 @@ class ActivityStreams { return $this->valid; } + function collect_recips($base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + $x = []; + $fields = [ 'to','cc','bto','bcc','audience']; + foreach($fields as $f) { + $y = $this->get_compound_property($f,$base,$namespace); + if($y) + $x = array_merge($x,$y); + } +// not yet ready for prime time +// $x = $this->expand($x,$base,$namespace); + return $x; + } + + function expand($arr,$base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + $ret = []; + + // right now use a hardwired recursion depth of 5 + + for($z = 0; $z < 5; $z ++) { + if(is_array($arr) && $arr) { + foreach($arr as $a) { + if(is_array($a)) { + $ret[] = $a; + } + else { + $x = $this->get_compound_property($a,$base,$namespace); + if($x) { + $ret = array_merge($ret,$x); + } + } + } + } + } + + // @fixme de-duplicate + + return $ret; + } + function get_namespace($base,$namespace) { $key = null; -- cgit v1.2.3 From e70bf975084ee44662bc2c1c19d2fe6aa0268dee Mon Sep 17 00:00:00 2001 From: git-marijus Date: Mon, 28 Aug 2017 23:42:17 +0200 Subject: rewrite comment form handling --- Zotlabs/Lib/ThreadItem.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 313001cc7..f9565d339 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -758,9 +758,9 @@ class ThreadItem { '$sourceapp' => \App::$sourcename, '$observer' => get_observer_hash(), '$anoncomments' => (($conv->get_mode() === 'channel' && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), - '$anonname' => [ 'anonname', t('Your full name (required)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ], - '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ], - '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ] + '$anonname' => [ 'anonname', t('Your full name (required)') ], + '$anonmail' => [ 'anonmail', t('Your email address (required)') ], + '$anonurl' => [ 'anonurl', t('Your website URL (optional)') ] )); return $comment_box; -- cgit v1.2.3 From ab5e7ad7a20d86dc611988df487b2edb38d14c21 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 28 Aug 2017 19:06:01 -0700 Subject: provide support for json-ld signatures (https://w3c-dvcg.github.io/ld-signatures/) --- Zotlabs/Lib/LDSignatures.php | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Zotlabs/Lib/LDSignatures.php (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php new file mode 100644 index 000000000..7afce7700 --- /dev/null +++ b/Zotlabs/Lib/LDSignatures.php @@ -0,0 +1,81 @@ + 'RsaSignature2017', + 'creator' => z_root() . '/channel/' . $channel['channel_address'] . '/public_key_pem', + 'created' => datetime_convert('UTC','UTC', 'now', 'Y-m-d\Th:i:s\Z') + ]; + + $ohash = self::hash(self::signable_options($options)); + $dhash = self::hash(self::signable_data($data)); + $options['signatureValue'] = base64_encode(rsa_sign($ohash . $dhash,$channel['channel_prvkey'])); + + $signed = array_merge([ + '@context' => [ 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1' ], + ],$options); + + return $signed; + } + + + static function signable_data($data) { + + $newdata = []; + if($data) { + foreach($data as $k => $v) { + if(! in_array($k,[ 'signature' ])) { + $newopts[$k] = $v; + } + } + } + return json_encode($newdata,JSON_UNESCAPED_SLASHES); + } + + + static function signable_options($options) { + + $newopts = [ '@context' => 'https://w3id.org/identity/v1' ]; + if($options) { + foreach($options as $k => $v) { + if(! in_array($k,[ 'type','id','signatureValue' ])) { + $newopts[$k] = $v; + } + } + } + return json_encode($newopts,JSON_UNESCAPED_SLASHES); + } + + static function hash($obj) { + return hash('sha256',self::normalise($obj)); + } + + static function normalise($data) { + if(is_string($data)) { + $data = json_decode($data); + } + + if(! is_object($data)) + return ''; + + return jsonld_normalize($data,[ 'algorithm' => 'URDNA2015', 'format' => 'application/nquads' ]); + } + +} \ No newline at end of file -- cgit v1.2.3 From 06be21af0521f135ba0de41b90f9e64ad8e4b691 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 28 Aug 2017 19:12:35 -0700 Subject: use top level for verification --- Zotlabs/Lib/LDSignatures.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 7afce7700..7bc4fe957 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -10,7 +10,7 @@ class LDSignatures { static function verify($data,$pubkey) { $ohash = self::hash(self::signable_options($data['signature'])); - $dhash = self::hash(self::signable_data($data['signature'])); + $dhash = self::hash(self::signable_data($data)); return rsa_verify($ohash . $dhash,base64_decode($data['signature']['signatureValue']), $pubkey); } -- cgit v1.2.3 From 1f42d2333271cec8c439abe0ebb0ecd05b1954f5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 29 Aug 2017 18:46:00 -0700 Subject: add reliable signatures --- Zotlabs/Lib/LDSignatures.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 7bc4fe957..ba7025927 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -15,7 +15,10 @@ class LDSignatures { return rsa_verify($ohash . $dhash,base64_decode($data['signature']['signatureValue']), $pubkey); } - + static function dopplesign(&$data,$channel) { + $data['magicEnv'] = self::salmon_sign($data,$channel); + return self::sign($data,$channel); + } static function sign($data,$channel) { $options = [ @@ -78,4 +81,34 @@ class LDSignatures { return jsonld_normalize($data,[ 'algorithm' => 'URDNA2015', 'format' => 'application/nquads' ]); } + static function salmon_sign($data,$channel) { + + $data = json_encode($data,JSON_UNESCAPED_SLASHES); + $data = base64url_encode($data, false); // do not strip padding + $data_type = 'application/activity+json'; + $encoding = 'base64url'; + $algorithm = 'RSA-SHA256'; + $keyhash = base64url_encode(z_root() . '/channel/' . $channel['channel_address']); + + $data = str_replace(array(" ","\t","\r","\n"),array("","","",""),$data); + + // precomputed base64url encoding of data_type, encoding, algorithm concatenated with periods + + $precomputed = '.' . base64url_encode($data_type,false) . '.YmFzZTY0dXJs.UlNBLVNIQTI1Ng=='; + + $signature = base64url_encode(rsa_sign($data . $precomputed,$channel['channel_prvkey'])); + + return ([ + 'meData' => $data, + 'meDataType' => $data_type, + 'meEncoding' => $encoding, + 'meAlgorithm' => $algorithm, + 'meCreator' => z_root() . '/channel/' . $channel['channel_address'] . '/public_key_pem', + 'meSignatureValue' => $signature + ]); + + } + + + } \ No newline at end of file -- cgit v1.2.3 From d47df8663f16aa2180bf0658c4d7782845fb9362 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 29 Aug 2017 20:57:30 -0700 Subject: add a nonce --- Zotlabs/Lib/LDSignatures.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index ba7025927..a52946a32 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -23,6 +23,7 @@ class LDSignatures { static function sign($data,$channel) { $options = [ 'type' => 'RsaSignature2017', + 'nonce' => random_string(64), 'creator' => z_root() . '/channel/' . $channel['channel_address'] . '/public_key_pem', 'created' => datetime_convert('UTC','UTC', 'now', 'Y-m-d\Th:i:s\Z') ]; -- cgit v1.2.3 From 5abc9ef10b385dea34c16337df65f99e8ec4d883 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 29 Aug 2017 22:08:37 -0700 Subject: bring back nomadic locations --- Zotlabs/Lib/LDSignatures.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index a52946a32..88dfe80c0 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -84,6 +84,7 @@ class LDSignatures { static function salmon_sign($data,$channel) { + $arr = $data; $data = json_encode($data,JSON_UNESCAPED_SLASHES); $data = base64url_encode($data, false); // do not strip padding $data_type = 'application/activity+json'; @@ -100,6 +101,7 @@ class LDSignatures { $signature = base64url_encode(rsa_sign($data . $precomputed,$channel['channel_prvkey'])); return ([ + 'id' => $arr['id'], 'meData' => $data, 'meDataType' => $data_type, 'meEncoding' => $encoding, -- cgit v1.2.3 From 68a91ec3ea7eaf56689545535a7481a838eff4da Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 5 Sep 2017 23:18:02 +0200 Subject: 32 characters are often not enough to distinguish gnu-social mids - use the entire mid. in /display if we are not dealing with posts (eg likes) provide the thr_parent mid as bParam_mid so we can still adress the right post in javascript --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index f9565d339..d33f3c183 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -413,7 +413,7 @@ class ThreadItem { 'previewing' => ($conv->is_preview() ? true : false ), 'preview_lbl' => t('This is an unsaved preview'), 'wait' => t('Please wait'), - 'submid' => str_replace(['+','='], ['',''], base64_encode(substr($item['mid'],0,32))), + 'submid' => str_replace(['+','='], ['',''], base64_encode($item['mid'])), 'thread_level' => $thread_level ); -- cgit v1.2.3 From 45eb61bcf079557094fed8714afc994f1120e6db Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 5 Sep 2017 18:32:37 -0700 Subject: provide sharing of cards --- Zotlabs/Lib/ThreadItem.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index d33f3c183..d916ce2c1 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -313,7 +313,8 @@ class ThreadItem { $tmp_item = array( 'template' => $this->get_template(), - 'mode' => $mode, + 'mode' => $mode, + 'item_type' => intval($item['item_type']), 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'body' => $body['html'], 'tags' => $body['tags'], -- cgit v1.2.3 From d4e53bb86fbeff0dd0b4f069f4fa07993ddf9e65 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 11 Sep 2017 18:56:17 -0700 Subject: typo in ldsigs --- Zotlabs/Lib/ActivityStreams.php | 12 +++++++++++- Zotlabs/Lib/LDSignatures.php | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 686f4a140..2846ea476 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -13,7 +13,9 @@ class ActivityStreams { public $tgt = null; public $origin = null; public $owner = null; - + public $signer = null; + public $ldsig = null; + public $sigok = false; public $recips = null; function __construct($string) { @@ -32,6 +34,14 @@ class ActivityStreams { $this->origin = $this->get_compound_property('origin'); $this->recips = $this->collect_recips(); + $this->ldsig = $this->get_compound_property('signature'); + if($this->ldsig) { + $this->signer = $this->get_compound_property('creator',$this->ldsig); + if($this->signer && $this->signer['publicKey'] && $this->signer['publicKey']['publicKeyPem']) { + $this->sigok = \Zotlabs\Lib\LDSignatures::verify($this->data,$this->signer['publicKey']['publicKeyPem']); + } + } + if(($this->type === 'Note') && (! $this->obj)) { $this->obj = $this->data; $this->type = 'Create'; diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 88dfe80c0..7d468782a 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -21,6 +21,7 @@ class LDSignatures { } static function sign($data,$channel) { + $options = [ 'type' => 'RsaSignature2017', 'nonce' => random_string(64), @@ -46,7 +47,7 @@ class LDSignatures { if($data) { foreach($data as $k => $v) { if(! in_array($k,[ 'signature' ])) { - $newopts[$k] = $v; + $newdata[$k] = $v; } } } @@ -68,6 +69,7 @@ class LDSignatures { } static function hash($obj) { + return hash('sha256',self::normalise($obj)); } -- cgit v1.2.3 From 4ff89a58625e647ee74087dfab79ac6dd76cbe6c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 Sep 2017 20:24:57 -0700 Subject: drop salmon until we improve performance --- Zotlabs/Lib/LDSignatures.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 7d468782a..fa2758044 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -16,7 +16,8 @@ class LDSignatures { } static function dopplesign(&$data,$channel) { - $data['magicEnv'] = self::salmon_sign($data,$channel); + // remove for the time being - performance issues + // $data['magicEnv'] = self::salmon_sign($data,$channel); return self::sign($data,$channel); } -- cgit v1.2.3 From 5e99295bf6f85e7a6d50e0c8f0701a9b37f03332 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 Sep 2017 22:32:31 -0700 Subject: wiki mimetype selection --- Zotlabs/Lib/NativeWikiPage.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 78b54ebda..97dad5813 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -55,7 +55,12 @@ class NativeWikiPage { } - static public function create_page($channel_id, $observer_hash, $name, $resource_id) { + static public function create_page($channel_id, $observer_hash, $name, $resource_id, $mimetype = 'text/bbcode') { + + logger('mimetype: ' . $mimetype); + + if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html'])) + $mimetype = 'text/markdown; $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id); @@ -68,6 +73,7 @@ class NativeWikiPage { $arr = []; $arr['uid'] = $channel_id; $arr['author_xchan'] = $observer_hash; + $arr['mimetype'] = $mimetype; $arr['resource_type'] = 'nwikipage'; $arr['resource_id'] = $resource_id; $arr['allow_cid'] = $w['wiki']['allow_cid']; -- cgit v1.2.3 From 7489a4442ea2041450b3477400c0ecb29b8670d9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 Sep 2017 22:35:30 -0700 Subject: wiki mimetype --- Zotlabs/Lib/NativeWikiPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 97dad5813..dd1e8f9d9 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -60,7 +60,7 @@ class NativeWikiPage { logger('mimetype: ' . $mimetype); if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html'])) - $mimetype = 'text/markdown; + $mimetype = 'text/markdown'; $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id); -- cgit v1.2.3 From 796228b7ad3cac90b23de2954445021578635105 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 Sep 2017 23:15:30 -0700 Subject: wiki mimetype selection. We can add text/plain as soon as we add code to purify and render it specifically. --- Zotlabs/Lib/NativeWikiPage.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index dd1e8f9d9..ffd5aec31 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -59,7 +59,7 @@ class NativeWikiPage { logger('mimetype: ' . $mimetype); - if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html'])) + if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html' ])) $mimetype = 'text/markdown'; $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id); @@ -173,10 +173,11 @@ class NativeWikiPage { $content = $item['body']; return [ - 'content' => $content, - 'mimeType' => $w['mimeType'], - 'message' => '', - 'success' => true + 'content' => $content, + 'mimeType' => $w['mimeType'], + 'pageMimeType' => $item['mimetype'], + 'message' => '', + 'success' => true ]; } @@ -339,7 +340,6 @@ class NativeWikiPage { return array('message' => t('Error reading wiki'), 'success' => false); } - $mimetype = $w['mimeType']; // fetch the most recently saved revision. @@ -348,6 +348,8 @@ class NativeWikiPage { return array('message' => t('Page not found'), 'success' => false); } + $mimetype = $item['mimetype']; + // change just the fields we need to change to create a revision; unset($item['id']); -- cgit v1.2.3 From 55aaabc2f13a36f73af944e17558b59f265322ea Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Sep 2017 22:37:18 -0700 Subject: add text/plain type to wiki --- Zotlabs/Lib/NativeWikiPage.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index ffd5aec31..558a70a3c 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -607,10 +607,13 @@ class NativeWikiPage { } static public function get_file_ext($arr) { - if($arr['mimeType'] == 'text/bbcode') + if($arr['mimeType'] === 'text/bbcode') return '.bb'; - else + elseif($arr['mimeType'] === 'text/markdown') return '.md'; + elseif($arr['mimeType'] === 'text/plain') + return '.txt'; + } // This function is derived from -- cgit v1.2.3 From d7ec6865b4ed07f1c5d37158f5e20d97a27617a7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 14 Sep 2017 04:06:09 -0700 Subject: bring back wiki download --- Zotlabs/Lib/NativeWikiPage.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 558a70a3c..4b637781e 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -607,11 +607,11 @@ class NativeWikiPage { } static public function get_file_ext($arr) { - if($arr['mimeType'] === 'text/bbcode') + if($arr['mimetype'] === 'text/bbcode') return '.bb'; - elseif($arr['mimeType'] === 'text/markdown') + elseif($arr['mimetype'] === 'text/markdown') return '.md'; - elseif($arr['mimeType'] === 'text/plain') + elseif($arr['mimetype'] === 'text/plain') return '.txt'; } -- cgit v1.2.3 From cf120b235117017a81b8a9b1a073919fb1b7d50b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 14 Sep 2017 17:14:50 -0700 Subject: wiki: lock mimetype --- Zotlabs/Lib/NativeWiki.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 4301feaa0..0c1894625 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -22,6 +22,7 @@ class NativeWiki { $w['htmlName'] = escape_tags($w['rawName']); $w['urlName'] = urlencode(urlencode($w['rawName'])); $w['mimeType'] = get_iconfig($w, 'wiki', 'mimeType'); + $w['typelock'] = get_iconfig($w, 'wiki', 'typelock'); $w['lock'] = (($w['item_private'] || $w['allow_cid'] || $w['allow_gid'] || $w['deny_cid'] || $w['deny_gid']) ? true : false); } } @@ -84,7 +85,9 @@ class NativeWiki { if(! set_iconfig($arr, 'wiki', 'mimeType', $wiki['mimeType'], true)) { return array('item' => null, 'success' => false); } - + + set_iconfig($arr,'wiki','typelock',$wiki['typelock'],true); + $post = item_store($arr); $item_id = $post['item_id']; @@ -150,13 +153,15 @@ class NativeWiki { // Get wiki metadata $rawName = get_iconfig($w, 'wiki', 'rawName'); $mimeType = get_iconfig($w, 'wiki', 'mimeType'); + $typelock = get_iconfig($w, 'wiki', 'typelock'); return array( - 'wiki' => $w, - 'rawName' => $rawName, + 'wiki' => $w, + 'rawName' => $rawName, 'htmlName' => escape_tags($rawName), - 'urlName' => urlencode(urlencode($rawName)), - 'mimeType' => $mimeType + 'urlName' => urlencode(urlencode($rawName)), + 'mimeType' => $mimeType, + 'typelock' => $typelock ); } } -- cgit v1.2.3 From 4c5722c766643af368f600abb93a44fc72d27c11 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Fri, 15 Sep 2017 16:27:30 +0200 Subject: some work on wiki acl --- Zotlabs/Lib/NativeWiki.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 4301feaa0..375fad4d7 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -18,11 +18,18 @@ class NativeWiki { if($wikis) { foreach($wikis as &$w) { + + $w['allow_cid'] = acl2json($w['allow_cid']); + $w['allow_gid'] = acl2json($w['allow_gid']); + $w['deny_cid'] = acl2json($w['deny_cid']); + $w['deny_gid'] = acl2json($w['deny_gid']); + $w['rawName'] = get_iconfig($w, 'wiki', 'rawName'); $w['htmlName'] = escape_tags($w['rawName']); $w['urlName'] = urlencode(urlencode($w['rawName'])); $w['mimeType'] = get_iconfig($w, 'wiki', 'mimeType'); - $w['lock'] = (($w['item_private'] || $w['allow_cid'] || $w['allow_gid'] || $w['deny_cid'] || $w['deny_gid']) ? true : false); + + } } // TODO: query db for wikis the observer can access. Return with two lists, for read and write access -- cgit v1.2.3 From 373651c3dbb9d6d79b9c5a1519a7ef336f2d615e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Sep 2017 22:17:18 +0200 Subject: implement wiki editing --- Zotlabs/Lib/NativeWiki.php | 51 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 39952ed5f..6d4dd888b 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -19,17 +19,17 @@ class NativeWiki { if($wikis) { foreach($wikis as &$w) { - $w['allow_cid'] = acl2json($w['allow_cid']); - $w['allow_gid'] = acl2json($w['allow_gid']); - $w['deny_cid'] = acl2json($w['deny_cid']); - $w['deny_gid'] = acl2json($w['deny_gid']); + $w['json_allow_cid'] = acl2json($w['allow_cid']); + $w['json_allow_gid'] = acl2json($w['allow_gid']); + $w['json_deny_cid'] = acl2json($w['deny_cid']); + $w['json_deny_gid'] = acl2json($w['deny_gid']); $w['rawName'] = get_iconfig($w, 'wiki', 'rawName'); $w['htmlName'] = escape_tags($w['rawName']); $w['urlName'] = urlencode(urlencode($w['rawName'])); $w['mimeType'] = get_iconfig($w, 'wiki', 'mimeType'); $w['typelock'] = get_iconfig($w, 'wiki', 'typelock'); - $w['lock'] = (($w['item_private'] || $w['allow_cid'] || $w['allow_gid'] || $w['deny_cid'] || $w['deny_gid']) ? true : false); + $w['lockstate'] = (($w['allow_cid'] || $w['allow_gid'] || $w['deny_cid'] || $w['deny_gid']) ? 'lock' : 'unlock'); } } // TODO: query db for wikis the observer can access. Return with two lists, for read and write access @@ -107,6 +107,47 @@ class NativeWiki { } } + function update_wiki($channel_id, $observer_hash, $arr, $acl) { + + $w = self::get_wiki($channel_id, $observer_hash, $arr['resource_id']); + $item = $w['wiki']; + + if(! $item) { + return array('item' => null, 'success' => false); + } + + $x = $acl->get(); + + $item['allow_cid'] = $x['allow_cid']; + $item['allow_gid'] = $x['allow_gid']; + $item['deny_cid'] = $x['deny_cid']; + $item['deny_gid'] = $x['deny_gid']; + $item['item_private'] = intval($acl->is_private()); + + if($item['title'] !== $arr['updateRawName']) { + $update_title = true; + $item['title'] = $arr['updateRawName']; + } + + $update = item_store_update($item); + + $item_id = $update['item_id']; + + if($update['item_id']) { + info( t('Wiki updated successfully')); + if($update_title) { + // Update the wiki name information using iconfig. + if(! set_iconfig($update['item_id'], 'wiki', 'rawName', $arr['updateRawName'], true)) { + return array('item' => null, 'success' => false); + } + } + return array('item' => $update['item'], 'item_id' => $update['item_id'], 'success' => $update['success']); + } + else { + return array('item' => null, 'success' => false); + } + } + static public function sync_a_wiki_item($uid,$id,$resource_id) { -- cgit v1.2.3 From eef1fcbb07a689725a4812ca0b3eb302424268b9 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Sep 2017 22:28:27 +0200 Subject: set update_title to false --- Zotlabs/Lib/NativeWiki.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 6d4dd888b..390b83958 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -124,6 +124,8 @@ class NativeWiki { $item['deny_gid'] = $x['deny_gid']; $item['item_private'] = intval($acl->is_private()); + $update_title = false; + if($item['title'] !== $arr['updateRawName']) { $update_title = true; $item['title'] = $arr['updateRawName']; -- cgit v1.2.3 From ca24bfdc464a414ad30aec2dec307c174ef60a0f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 16 Sep 2017 16:42:01 -0700 Subject: wiki sync - we weren't getting the child pages --- Zotlabs/Lib/NativeWiki.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 390b83958..22aa1817a 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -160,6 +160,12 @@ class NativeWiki { dbesc($resource_id) ); if($r) { + $q = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s'", + dbesc($r[0]['resource_type']) + ); + if($q) { + $r = array_merge($r,$q); + } xchan_query($r); $sync_item = fetch_post_tags($r); build_sync_packet($uid,array('wiki' => array(encode_item($sync_item[0],true)))); -- cgit v1.2.3 From 9120a82ab4c4051b37794ca4d87ee3ae52084459 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 16 Sep 2017 16:52:25 -0700 Subject: wiki: update acl on child pages when wiki perms change --- Zotlabs/Lib/NativeWiki.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 22aa1817a..7642dbb3e 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -135,6 +135,18 @@ class NativeWiki { $item_id = $update['item_id']; + // update acl for any existing wiki pages + + q("update item set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d where resource_type = 'nwikipage' and resource_id = '%s'", + dbesc($item['allow_cid']), + dbesc($item['allow_gid']), + dbesc($item['deny_cid']), + dbesc($item['deny_gid']), + dbesc($item['item_private']), + dbesc($arr['resource_id']) + ); + + if($update['item_id']) { info( t('Wiki updated successfully')); if($update_title) { -- cgit v1.2.3 From 1d9e0f17a6e945a10c05ad6543682ad1c8cd87d9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 17 Sep 2017 18:40:32 -0700 Subject: more mastodon testing --- Zotlabs/Lib/ActivityStreams.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 2846ea476..d9735881a 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -17,6 +17,7 @@ class ActivityStreams { public $ldsig = null; public $sigok = false; public $recips = null; + public $raw_recips = null; function __construct($string) { @@ -53,13 +54,21 @@ class ActivityStreams { return $this->valid; } + function set_recips($arr) { + $this->saved_recips = $arr; + } + function collect_recips($base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { $x = []; $fields = [ 'to','cc','bto','bcc','audience']; foreach($fields as $f) { $y = $this->get_compound_property($f,$base,$namespace); - if($y) + if($y) { $x = array_merge($x,$y); + if(! is_array($this->raw_recips)) + $this->raw_recips = []; + $this->raw_recips[$f] = $x; + } } // not yet ready for prime time // $x = $this->expand($x,$base,$namespace); -- cgit v1.2.3 From 4500faf463e7fd6fcf9948666421c941a1292df9 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 19 Sep 2017 18:59:06 +0200 Subject: fix various wikipage widget issues (sort pages by name, respect locked mime type setting, move create tool back to the bottom) --- Zotlabs/Lib/NativeWikiPage.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 4b637781e..209a5ef3c 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 order by created asc", + $sql_extra order by title asc", dbesc($resource_id), intval($channel_id) ); @@ -74,6 +74,7 @@ class NativeWikiPage { $arr['uid'] = $channel_id; $arr['author_xchan'] = $observer_hash; $arr['mimetype'] = $mimetype; + $arr['title'] = $name; $arr['resource_type'] = 'nwikipage'; $arr['resource_id'] = $resource_id; $arr['allow_cid'] = $w['wiki']['allow_cid']; @@ -139,8 +140,14 @@ class NativeWikiPage { if($ic) { foreach($ic as $c) { set_iconfig($c['item_id'],'nwikipage','pagetitle',$pageNewName); + $ids[] = $c['item_id']; } + $str_ids = implode(',', $ids); + q("update item set title = '%s' where id in ($str_ids)", + dbesc($pageNewName) + ); + $page = [ 'rawName' => $pageNewName, 'htmlName' => escape_tags($pageNewName), -- cgit v1.2.3 From b0cdec0c35136db8cbb0cf13135a1f5cc8d1bc05 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 19 Sep 2017 19:15:15 -0700 Subject: perform caching of jsonld schemas --- Zotlabs/Lib/LDSignatures.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index fa2758044..77e2ef332 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -82,6 +82,8 @@ class LDSignatures { if(! is_object($data)) return ''; + jsonld_set_document_loader('jsonld_document_loader'); + return jsonld_normalize($data,[ 'algorithm' => 'URDNA2015', 'format' => 'application/nquads' ]); } -- cgit v1.2.3 From 00fe4e747f9884ab11fe94621f645fc351285964 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 19 Sep 2017 21:40:38 -0700 Subject: use frozen jsonld contexts --- Zotlabs/Lib/ActivityStreams.php | 10 +++++----- Zotlabs/Lib/LDSignatures.php | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index d9735881a..1b9f82ddf 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -58,7 +58,7 @@ class ActivityStreams { $this->saved_recips = $arr; } - function collect_recips($base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + function collect_recips($base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { $x = []; $fields = [ 'to','cc','bto','bcc','audience']; foreach($fields as $f) { @@ -75,7 +75,7 @@ class ActivityStreams { return $x; } - function expand($arr,$base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + function expand($arr,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { $ret = []; // right now use a hardwired recursion depth of 5 @@ -135,7 +135,7 @@ class ActivityStreams { } - function get_property_obj($property,$base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + function get_property_obj($property,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV ) { $prefix = $this->get_namespace($base,$namespace); if($prefix === null) return null; @@ -158,7 +158,7 @@ class ActivityStreams { return null; } - function get_compound_property($property,$base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + function get_compound_property($property,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { $x = $this->get_property_obj($property,$base,$namespace); if($this->is_url($x)) { $x = $this->fetch_property($x); @@ -173,7 +173,7 @@ class ActivityStreams { return false; } - function get_primary_type($base = '',$namespace = 'https://www.w3.org/ns/activitystreams') { + function get_primary_type($base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { if(! $base) $base = $this->data; $x = $this->get_property_obj('type',$base,$namespace); diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 77e2ef332..31ffd71f1 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -35,7 +35,9 @@ class LDSignatures { $options['signatureValue'] = base64_encode(rsa_sign($ohash . $dhash,$channel['channel_prvkey'])); $signed = array_merge([ - '@context' => [ 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1' ], + '@context' => [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1' ], ],$options); return $signed; -- cgit v1.2.3 From 90f759412b32485b029c2a43f9c01372e9fc83a7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 20 Sep 2017 16:26:33 -0700 Subject: fix namespace parsing issue --- Zotlabs/Lib/ActivityStreams.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 1b9f82ddf..10ae24670 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -58,7 +58,7 @@ class ActivityStreams { $this->saved_recips = $arr; } - function collect_recips($base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { + function collect_recips($base = '',$namespace = '') { $x = []; $fields = [ 'to','cc','bto','bcc','audience']; foreach($fields as $f) { @@ -75,7 +75,7 @@ class ActivityStreams { return $x; } - function expand($arr,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { + function expand($arr,$base = '',$namespace = '') { $ret = []; // right now use a hardwired recursion depth of 5 @@ -103,8 +103,12 @@ class ActivityStreams { function get_namespace($base,$namespace) { + if(! $namespace) + return ''; + $key = null; + foreach( [ $this->data, $base ] as $b ) { if(! $b) continue; @@ -135,7 +139,7 @@ class ActivityStreams { } - function get_property_obj($property,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV ) { + function get_property_obj($property,$base = '',$namespace = '' ) { $prefix = $this->get_namespace($base,$namespace); if($prefix === null) return null; @@ -158,7 +162,7 @@ class ActivityStreams { return null; } - function get_compound_property($property,$base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { + function get_compound_property($property,$base = '',$namespace = '') { $x = $this->get_property_obj($property,$base,$namespace); if($this->is_url($x)) { $x = $this->fetch_property($x); @@ -173,7 +177,7 @@ class ActivityStreams { return false; } - function get_primary_type($base = '',$namespace = ACTIVITYSTREAMS_JSONLD_REV) { + function get_primary_type($base = '',$namespace = '') { if(! $base) $base = $this->data; $x = $this->get_property_obj('type',$base,$namespace); -- cgit v1.2.3 From 24a9c3ba79cc7639a9cc6082c13dfedbc989bc8d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 20 Sep 2017 21:20:00 -0700 Subject: add more signature logging --- Zotlabs/Lib/LDSignatures.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 31ffd71f1..d500799c0 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -12,7 +12,10 @@ class LDSignatures { $ohash = self::hash(self::signable_options($data['signature'])); $dhash = self::hash(self::signable_data($data)); - return rsa_verify($ohash . $dhash,base64_decode($data['signature']['signatureValue']), $pubkey); + $x = rsa_verify($ohash . $dhash,base64_decode($data['signature']['signatureValue']), $pubkey); + logger('LD-verify: ' . intval($x)); + + return $x; } static function dopplesign(&$data,$channel) { -- cgit v1.2.3 From 2e9336beb5c3881b7f17cd4ffca29894344c779c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 20 Sep 2017 23:42:57 -0700 Subject: change back to the ugly content-type --- Zotlabs/Lib/ActivityStreams.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 10ae24670..379e78a59 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -156,7 +156,7 @@ class ActivityStreams { } $x = z_fetch_url($url,true,$redirects, - ['headers' => [ 'Accept: application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); + ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/activity+json' ]]); if($x['success']) return json_decode($x['body'],true); return null; -- cgit v1.2.3 From 06a674775e5606a98e0e7357b0c88378ca679e6d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 24 Sep 2017 20:18:36 -0700 Subject: handle jsonld parse errors and send them to the app log instead of the php log. --- Zotlabs/Lib/LDSignatures.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index d500799c0..6d7127cde 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -88,8 +88,16 @@ class LDSignatures { return ''; jsonld_set_document_loader('jsonld_document_loader'); + + try { + $d = jsonld_normalize($data,[ 'algorithm' => 'URDNA2015', 'format' => 'application/nquads' ]); + } + catch (\Exception $e) { + logger('normalise error:' . print_r($e,true)); + logger('normalise error: ' . print_r($data,true)); + } - return jsonld_normalize($data,[ 'algorithm' => 'URDNA2015', 'format' => 'application/nquads' ]); + return $d; } static function salmon_sign($data,$channel) { -- cgit v1.2.3 From 237aca32e31ca1651d12797ac82994fb2f0c1bec Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 24 Sep 2017 21:21:49 -0700 Subject: missing Zlib file --- Zotlabs/Lib/SConfig.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Zotlabs/Lib/SConfig.php (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/SConfig.php b/Zotlabs/Lib/SConfig.php new file mode 100644 index 000000000..ca0d133b2 --- /dev/null +++ b/Zotlabs/Lib/SConfig.php @@ -0,0 +1,25 @@ + Date: Mon, 25 Sep 2017 20:11:21 -0700 Subject: more zot6 basic stuff --- Zotlabs/Lib/System.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index a5790fb07..8b4d7258a 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -61,6 +61,13 @@ class System { return 'pro'; } + + static public function get_zot_revision() { + $x = [ 'revision' => ZOT_REVISION ]; + call_hooks('zot_revision',$x) + return $x['revision']; + } + static public function get_std_version() { if(defined('STD_VERSION')) return STD_VERSION; -- cgit v1.2.3 From be8061b64b47d96ae67e672bf2835e8cec73d979 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 25 Sep 2017 20:12:43 -0700 Subject: typo --- Zotlabs/Lib/System.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 8b4d7258a..c3e11eb6a 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -64,7 +64,7 @@ class System { static public function get_zot_revision() { $x = [ 'revision' => ZOT_REVISION ]; - call_hooks('zot_revision',$x) + call_hooks('zot_revision',$x); return $x['revision']; } -- cgit v1.2.3 From 80ca99fe5b9f7bb10ffae5789527b7a5d3c4f65e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 4 Oct 2017 16:37:14 -0700 Subject: wiki double encoding html entities --- Zotlabs/Lib/MarkdownSoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index 534ad819f..fa279b07c 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -94,7 +94,7 @@ class MarkdownSoap { } function escape($s) { - return htmlspecialchars($s,ENT_QUOTES); + return htmlspecialchars($s,ENT_QUOTES,'UTF-8',false); } static public function unescape($s) { -- cgit v1.2.3 From 2ed77b598676b1070bd8488fe48666bb25213763 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 5 Oct 2017 19:51:00 -0700 Subject: add admin app - the site admin link probably does not belong in the 'usermenu' and this is a first step to straigtening out that historical mistake. --- Zotlabs/Lib/Apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 37cbf9497..c4f4038dc 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -222,7 +222,7 @@ class Apps { $apps = array( 'Apps' => t('Apps'), 'Cards' => t('Cards'), - 'Site Admin' => t('Site Admin'), + 'Admin' => t('Site Admin'), 'Report Bug' => t('Report Bug'), 'View Bookmarks' => t('View Bookmarks'), 'My Chatrooms' => t('My Chatrooms'), -- cgit v1.2.3 From 34a0ec4089ad7bcf730e5399d7e05c119743946d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 5 Oct 2017 20:09:21 -0700 Subject: Add JSalmon signing library for Zot6. See https://macgirvin.com/wiki/mike/Zot%2BVI/Encryption/Signatures --- Zotlabs/Lib/JSalmon.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Zotlabs/Lib/JSalmon.php (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/JSalmon.php b/Zotlabs/Lib/JSalmon.php new file mode 100644 index 000000000..763f687fa --- /dev/null +++ b/Zotlabs/Lib/JSalmon.php @@ -0,0 +1,38 @@ + true, + 'data' => $data, + 'data_type' => $data_type, + 'encoding' => $encoding, + 'alg' => $algorithm, + 'sigs' => [ + 'value' => $signature + 'key_id' => base64url_encode($key_id) + ] + ]); + + } +} \ No newline at end of file -- cgit v1.2.3 From 052ed1f88b11e60ce770a2743192d3bdd78642fc Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 5 Oct 2017 22:01:45 -0700 Subject: typo --- Zotlabs/Lib/JSalmon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/JSalmon.php b/Zotlabs/Lib/JSalmon.php index 763f687fa..43d5f9d09 100644 --- a/Zotlabs/Lib/JSalmon.php +++ b/Zotlabs/Lib/JSalmon.php @@ -29,7 +29,7 @@ class JSalmon { 'encoding' => $encoding, 'alg' => $algorithm, 'sigs' => [ - 'value' => $signature + 'value' => $signature, 'key_id' => base64url_encode($key_id) ] ]); -- cgit v1.2.3 From b883b9c983773f51965680af813dd7e930823460 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 21:30:44 +0200 Subject: enable anonymous comments also in /display --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index d916ce2c1..67a507025 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -758,7 +758,7 @@ class ThreadItem { '$cipher' => $conv->get_cipher(), '$sourceapp' => \App::$sourcename, '$observer' => get_observer_hash(), - '$anoncomments' => (($conv->get_mode() === 'channel' && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), + '$anoncomments' => ((($conv->get_mode() === 'channel' || $conv->get_mode() === 'display') && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), '$anonname' => [ 'anonname', t('Your full name (required)') ], '$anonmail' => [ 'anonmail', t('Your email address (required)') ], '$anonurl' => [ 'anonurl', t('Your website URL (optional)') ] -- cgit v1.2.3 From 9bd30eb8bf0299e62a975f4f8ba0a868e5789417 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 21:32:06 +0200 Subject: to find out if a comment is to be moderated we need to look at the actual comment not at its parent --- Zotlabs/Lib/Enotify.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 9f3347d19..6513bcda7 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -97,6 +97,7 @@ class Enotify { $title = $i['title']; $body = $i['body']; $private = (($i['item_private']) || intval($i['item_obscured'])); + $moderated = (($i['item_blocked'] == ITEM_MODERATED) ? true : false); } else { $title = $params['item']['title']; @@ -170,8 +171,6 @@ class Enotify { xchan_query($p); - $moderated = (($p[0]['item_blocked'] == ITEM_MODERATED) ? true : false); - $item_post_type = item_post_type($p[0]); // $private = $p[0]['item_private']; $parent_id = $p[0]['id']; -- cgit v1.2.3 From e7c8012794ffe6ac746223a9d67fa338f7360c57 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 6 Oct 2017 22:25:53 +0200 Subject: no need to move $modrated check up --- Zotlabs/Lib/Enotify.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 6513bcda7..e82c11a35 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -97,7 +97,6 @@ class Enotify { $title = $i['title']; $body = $i['body']; $private = (($i['item_private']) || intval($i['item_obscured'])); - $moderated = (($i['item_blocked'] == ITEM_MODERATED) ? true : false); } else { $title = $params['item']['title']; @@ -131,7 +130,9 @@ class Enotify { if ($params['type'] == NOTIFY_COMMENT) { // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); - $itemlink = $params['link']; + $moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false); + + $itemlink = $params['link']; // ignore like/unlike activity on posts - they probably require a separate notification preference -- cgit v1.2.3 From c37908f344ecbac3ee60e3e36701161a4047d639 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 8 Oct 2017 17:22:38 -0700 Subject: check write_storage permission in /display --- Zotlabs/Lib/ThreadStream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index d7a898704..436723f8c 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -68,7 +68,7 @@ class ThreadStream { // pull some trickery which allows us to re-invoke this function afterward // it's an ugly hack so @FIXME $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); - $this->uploadable = false; + $this->uploadable = perm_is_allowed($this->profile_owner,$ob_hash,'write_storage'); break; case 'page': $this->profile_owner = \App::$profile['uid']; -- cgit v1.2.3 From 23812e5b48b7a4d4f0c275c0fbb3d244a582397c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 8 Oct 2017 19:43:03 -0700 Subject: ability to pin apps to the navbar when using named navbars --- Zotlabs/Lib/Apps.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index c4f4038dc..f13fbe362 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -383,6 +383,13 @@ class Apps { $install_action = (($installed) ? t('Update') : t('Install')); $icon = ((strpos($papp['photo'],'icon:') === 0) ? substr($papp['photo'],5) : ''); + if($mode === 'navbar') { + return replace_macros(get_markup_template('app_nav.tpl'),array( + '$app' => $papp, + '$icon' => $icon, + )); + } + return replace_macros(get_markup_template('app.tpl'),array( '$app' => $papp, '$icon' => $icon, -- cgit v1.2.3