From 13788af90838d66b1c701f935862a37fcc7262f4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Sep 2017 19:20:16 -0700 Subject: Zot6: some things that need to be done ahead of time so we can turbocharge the delivery engine and split off site records from channel records. --- Zotlabs/Daemon/Deliver.php | 31 +++++++++++++++++++------------ Zotlabs/Daemon/Notifier.php | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php index dbc311cf5..7c1ff717f 100644 --- a/Zotlabs/Daemon/Deliver.php +++ b/Zotlabs/Daemon/Deliver.php @@ -53,22 +53,29 @@ class Deliver { remove_queue_item($r[0]['outq_hash']); if($dresult && is_array($dresult)) { - foreach($dresult as $xx) { - if(is_array($xx) && array_key_exists('message_id',$xx)) { - if(delivery_report_is_storable($xx)) { - q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", - dbesc($xx['message_id']), - dbesc($xx['location']), - dbesc($xx['recipient']), - dbesc($xx['status']), - dbesc(datetime_convert($xx['date'])), - dbesc($xx['sender']) - ); + if(array_key_exists('iv',$dresult)) { + $dresult = json_decode(crypto_unencapsulate($dresult,get_config('system','prvkey')),true); + } + if(! $dresult) { + logger('dreport decryption failure'); + } + else { + foreach($dresult as $xx) { + if(is_array($xx) && array_key_exists('message_id',$xx)) { + if(delivery_report_is_storable($xx)) { + q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", + dbesc($xx['message_id']), + dbesc($xx['location']), + dbesc($xx['recipient']), + dbesc($xx['status']), + dbesc(datetime_convert($xx['date'])), + dbesc($xx['sender']) + ); + } } } } } - q("delete from dreport where dreport_queue = '%s'", dbesc($argv[$x]) ); diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index e8cd4dac8..0e8c99572 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -492,7 +492,7 @@ class Notifier { // Now we have collected recipients (except for external mentions, FIXME) // 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) . ") + $r = q("select hubloc.*, site.site_crypto, site.site_flags 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 ( site_dead = 0 OR site_dead is null ) " ); -- cgit v1.2.3 From b5966041be46ab7a16dc1ee93b5a07c5461bc73c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Sep 2017 20:40:01 -0700 Subject: more zot6 --- Zotlabs/Module/Post.php | 9 ++++++++- Zotlabs/Web/HTTPSig.php | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Post.php b/Zotlabs/Module/Post.php index c78484a45..dba26075f 100644 --- a/Zotlabs/Module/Post.php +++ b/Zotlabs/Module/Post.php @@ -19,12 +19,19 @@ class Post extends \Zotlabs\Web\Controller { function init() { if(array_key_exists('auth', $_REQUEST)) { $x = new \Zotlabs\Zot\Auth($_REQUEST); - exit; } } function post() { + + + + + + + + $z = new \Zotlabs\Zot\Receiver($_REQUEST['data'], get_config('system', 'prvkey'), new \Zotlabs\Zot\ZotHandler()); // notreached; diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index fee8aaa41..6526fa7c8 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -95,13 +95,18 @@ class HTTPSig { $algorithm = 'sha512'; } + if($key && function_exists($key)) { + $result['signer'] = $sig_block['keyId']; + $key = $key($sig_block['keyId']); + } + if(! $key) { $result['signer'] = $sig_block['keyId']; $key = self::get_activitypub_key($sig_block['keyId']); } if(! $key) - return null; + return $result; $x = rsa_verify($signed_data,$sig_block['signature'],$key,$algorithm); -- cgit v1.2.3 From 5be132f877f792e7b122a2b6ca18934b31b2f10c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 13 Sep 2017 21:36:59 -0700 Subject: make wiki page mimetype default to wiki mimetype (this was the original intent but the wrong variable was used) --- Zotlabs/Widget/Wiki_pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php index ac6549ffd..9d248759b 100644 --- a/Zotlabs/Widget/Wiki_pages.php +++ b/Zotlabs/Widget/Wiki_pages.php @@ -50,7 +50,7 @@ class Wiki_pages { '$canadd' => $can_create, '$candel' => $can_delete, '$addnew' => t('Add new page'), - '$mimetype' => mimetype_select(0,$p['mimeType'], [ 'text/markdown','text/bbcode' ]), + '$mimetype' => mimetype_select(0,$w['mimeType'], [ 'text/markdown','text/bbcode' ]), '$pageName' => array('pageName', t('Page name')), '$refresh' => $arr['refresh'] )); -- 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 +++++-- Zotlabs/Module/Wiki.php | 19 +++++++++++++------ Zotlabs/Widget/Wiki_pages.php | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'Zotlabs') 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 diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index df747a07a..1eb600f51 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -170,7 +170,7 @@ class Wiki extends \Zotlabs\Web\Controller { '$create' => t('Create New'), '$submit' => t('Submit'), '$wikiName' => array('wikiName', t('Wiki name')), - '$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => 'Markdown', 'text/bbcode' => 'BB Code']), + '$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => t('Markdown'), 'text/bbcode' => t('BBcode'), 'text/plain' => t('Text') ]), '$name' => t('Name'), '$type' => t('Type'), '$lockstate' => $x['lockstate'], @@ -262,6 +262,8 @@ class Wiki extends \Zotlabs\Web\Controller { $mimeType = $p['pageMimeType']; $sampleContent = (($mimeType == 'text/bbcode') ? '[h3]' . t('New page') . '[/h3]' : '### ' . t('New page')); + if($mimeType === 'text/plain') + $sampleContent = t('New page'); $content = (($p['content'] == '') ? $sampleContent : $p['content']); @@ -269,7 +271,10 @@ class Wiki extends \Zotlabs\Web\Controller { if($mimeType == 'text/bbcode') { $renderedContent = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))), argv(0) . '/' . argv(1) . '/' . $wikiUrlName); } - else { + elseif($mimeType === 'text/plain') { + $renderedContent = str_replace(["\n",' ',"\t"],[EOL,' ','    '],htmlentities($content,ENT_COMPAT,'UTF-8',false)); + } + elseif($mimeType === 'text/markdown') { $content = Zlib\MarkdownSoap::unescape($content); $html = Zlib\NativeWikiPage::generate_toc(zidify_text(MarkdownExtra::defaultTransform(Zlib\NativeWikiPage::bbcode($content)))); $renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName); @@ -323,7 +328,7 @@ class Wiki extends \Zotlabs\Web\Controller { '$modalerroralbum' => t('Error getting album'), )); - if($p['pageMimeType'] != 'text/bbcode') + if($p['pageMimeType'] === 'text/markdown') head_add_js('/library/ace/ace.js'); // Ace Code Editor return $o; @@ -354,11 +359,10 @@ class Wiki extends \Zotlabs\Web\Controller { $mimeType = $_POST['mimetype']; - if($mimeType == 'text/bbcode') { + if($mimeType === 'text/bbcode') { $html = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))),$wikiURL); } - else { - + elseif($mimeType === 'text/markdown') { $bb = Zlib\NativeWikiPage::bbcode($content); $x = new ZLib\MarkdownSoap($bb); $md = $x->clean(); @@ -367,6 +371,9 @@ class Wiki extends \Zotlabs\Web\Controller { $html = Zlib\NativeWikiPage::generate_toc(zidify_text($html)); $html = Zlib\NativeWikiPage::convert_links($html,$wikiURL); } + elseif($mimeType === 'text/plain') { + $html = str_replace(["\n",' ',"\t"],[EOL,' ','    '],htmlentities($content,ENT_COMPAT,'UTF-8',false)); + } json_return_and_die(array('html' => $html, 'success' => true)); } diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php index 9d248759b..3999d9858 100644 --- a/Zotlabs/Widget/Wiki_pages.php +++ b/Zotlabs/Widget/Wiki_pages.php @@ -50,7 +50,7 @@ class Wiki_pages { '$canadd' => $can_create, '$candel' => $can_delete, '$addnew' => t('Add new page'), - '$mimetype' => mimetype_select(0,$w['mimeType'], [ 'text/markdown','text/bbcode' ]), + '$mimetype' => mimetype_select(0,$w['mimeType'], [ 'text/markdown','text/bbcode', 'text/plain' ]), '$pageName' => array('pageName', t('Page name')), '$refresh' => $arr['refresh'] )); -- cgit v1.2.3