From b033597ada02ef045bc9fbdb2237f81935b73e47 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 11 Nov 2019 21:30:38 +0100 Subject: sse notifications --- Zotlabs/Lib/Enotify.php | 136 +++++++++++- Zotlabs/Lib/ThreadItem.php | 5 +- Zotlabs/Module/Mail.php | 2 +- Zotlabs/Module/Sse.php | 108 ++++++++++ Zotlabs/Module/Sse_bs.php | 519 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 764 insertions(+), 6 deletions(-) create mode 100644 Zotlabs/Module/Sse.php create mode 100644 Zotlabs/Module/Sse_bs.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 92a488f67..de2bfba24 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -550,6 +550,11 @@ class Enotify { if ((\App::$language === 'en' || (! \App::$language)) && strpos($msg,', ')) $msg = substr($msg,strpos($msg,', ')+1); + $datarray['id'] = $notify_id; + $datarray['msg'] = $msg; + + call_hooks('enotify_store_end', $datarray); + $r = q("update notify set msg = '%s' where id = %d and uid = %d", dbesc($msg), intval($notify_id), @@ -838,7 +843,7 @@ class Enotify { 'addr' => (($item[$who]['xchan_addr']) ? $item[$who]['xchan_addr'] : $item[$who]['xchan_url']), 'url' => $item[$who]['xchan_url'], 'photo' => $item[$who]['xchan_photo_s'], - 'when' => relative_date(($edit)? $item['edited'] : $item['created']), + 'when' => (($edit) ? datetime_convert('UTC', date_default_timezone_get(), $item['edited']) : datetime_convert('UTC', date_default_timezone_get(), $item['created'])), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), 'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', @@ -846,7 +851,7 @@ class Enotify { 'message' => strip_tags(bbcode($itemem_text)), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], - 'uid' => local_channel(), + 'uid' => $item['uid'], 'display' => true ); @@ -858,4 +863,131 @@ class Enotify { return $x; } + static public function format_notify($tt) { + + $message = trim(strip_tags(bbcode($tt['msg']))); + + if(strpos($message, $tt['xname']) === 0) + $message = substr($message, strlen($tt['xname']) + 1); + + $mid = basename($tt['link']); + $mid = ((strpos($mid, 'b64.') === 0) ? @base64url_decode(substr($mid, 4)) : $mid); + + if(in_array($tt['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { + // we need the thread parent + $r = q("select thr_parent from item where mid = '%s' and uid = %d limit 1", + dbesc($mid), + intval(local_channel()) + ); + $b64mid = ((strpos($r[0]['thr_parent'], 'b64.') === 0) ? $r[0]['thr_parent'] : 'b64.' . base64url_encode($r[0]['thr_parent'])); + } + else { + $b64mid = ((strpos($mid, 'b64.') === 0) ? $mid : 'b64.' . base64url_encode($mid)); + } + + $x = [ + 'notify_link' => z_root() . '/notify/view/' . $tt['id'], + 'name' => $tt['xname'], + 'url' => $tt['url'], + 'photo' => $tt['photo'], + 'when' => datetime_convert('UTC', date_default_timezone_get(), $tt['created']), + 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), + 'b64mid' => (($tt['otype'] == 'item') ? $b64mid : 'undefined'), + 'notify_id' => (($tt['otype'] == 'item') ? $tt['id'] : 'undefined'), + 'message' => $message + ]; + + return $x; + + } + + static public function format_intros($rr) { + + $x = [ + 'notify_link' => z_root() . '/connections/ifpending', + 'name' => $rr['xchan_name'], + 'addr' => $rr['xchan_addr'], + 'url' => $rr['xchan_url'], + 'photo' => $rr['xchan_photo_s'], + 'when' => datetime_convert('UTC', date_default_timezone_get(), $rr['abook_created']), + 'hclass' => ('notify-unseen'), + 'message' => t('added your channel') + ]; + + return $x; + + } + + static public function format_files($rr) { + + $x = [ + 'notify_link' => z_root() . '/sharedwithme', + 'name' => $rr['author']['xchan_name'], + 'addr' => $rr['author']['xchan_addr'], + 'url' => $rr['author']['xchan_url'], + 'photo' => $rr['author']['xchan_photo_s'], + 'when' => datetime_convert('UTC', date_default_timezone_get(), $rr['created']), + 'hclass' => ('notify-unseen'), + 'message' => t('shared a file with you') + ]; + + return $x; + + } + + static public function format_mail($rr) { + + $x = [ + 'notify_link' => z_root() . '/mail/' . $rr['id'], + 'name' => $rr['xchan_name'], + 'addr' => $rr['xchan_addr'], + 'url' => $rr['xchan_url'], + 'photo' => $rr['xchan_photo_s'], + 'when' => datetime_convert('UTC', date_default_timezone_get(), $rr['created']), + 'hclass' => (intval($rr['mail_seen']) ? 'notify-seen' : 'notify-unseen'), + 'message' => t('sent you a private message'), + ]; + + return $x; + + } + + static public function format_all_events($rr) { + + $bd_format = t('g A l F d') ; // 8 AM Friday January 18 + $strt = datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart']); + $today = ((substr($strt, 0, 10) === datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d')) ? true : false); + $when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); + + $x = [ + 'notify_link' => z_root() . '/cdav/calendar/' . $rr['event_hash'], + 'name' => $rr['xchan_name'], + 'addr' => $rr['xchan_addr'], + 'url' => $rr['xchan_url'], + 'photo' => $rr['xchan_photo_s'], + 'when' => $when, + 'hclass' => ('notify-unseen'), + 'message' => t('posted an event') + ]; + + return $x; + + } + + static public function format_register($rr) { + + $x = [ + 'notify_link' => z_root() . '/admin/accounts', + 'name' => $rr['account_email'], + 'addr' => $rr['account_email'], + 'url' => '', + 'photo' => z_root() . '/' . get_default_profile_photo(48), + 'when' => datetime_convert('UTC', date_default_timezone_get(),$rr['account_created']), + 'hclass' => ('notify-unseen'), + 'message' => t('requires approval') + ]; + + return $x; + + } } diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 5e4600df2..174af7f0e 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -369,7 +369,7 @@ class ThreadItem { 'folders' => $body['folders'], 'text' => strip_tags($body['html']), 'id' => $this->get_id(), - 'mid' => $item['mid'], + 'mid' => 'b64.' . base64url_encode($item['mid']), 'parent' => $item['parent'], 'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), 'isevent' => $isevent, @@ -467,10 +467,9 @@ 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($item['mid'])), 'thread_level' => $thread_level, 'settings' => $settings, - 'thr_parent' => (($item['parent_mid'] != $item['thr_parent']) ? $item['thr_parent'] : '') + 'thr_parent' => (($item['parent_mid'] != $item['thr_parent']) ? 'b64.' . base64url_encode($item['thr_parent']) : '') ); $arr = array('item' => $item, 'output' => $tmp_item); diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 7c344966b..636fc4e33 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -145,7 +145,7 @@ class Mail extends \Zotlabs\Web\Controller { $o = ''; nav_set_selected('Mail'); - + if(! local_channel()) { notice( t('Permission denied.') . EOL); return login(); diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php new file mode 100644 index 000000000..97fee5f49 --- /dev/null +++ b/Zotlabs/Module/Sse.php @@ -0,0 +1,108 @@ + 0) + self::$offset = argv(2); + else + $_SESSION['sse_loadtime'] = datetime_convert(); + + $network = false; + $home = false; + $pubs = false; + $f = ''; + + switch (argv(1)) { + case 'network': + $network = true; + $f = 'bs_network'; + break; + case 'home': + $home = true; + $f = 'bs_home'; + break; + case 'pubs': + $pubs = true; + $f = 'bs_pubs'; + break; + default: + } + + //hz_syslog('init: ' . argv(1)); + //hz_syslog('offset: ' . argv(2)); + + if(self::$offset && $f) { + $result = self::$f(true); + json_return_and_die($result); + } + + $result = array_merge( + self::bs_network($network), + self::bs_home($home), + self::bs_notify(), + self::bs_intros(), + self::bs_forums(), + self::bs_pubs($pubs), + self::bs_files(), + self::bs_mail(), + self::bs_all_events(), + self::bs_register() + ); + + json_return_and_die($result); + } + + function bs_network($notifications) { + + $result['network']['notifications'] = []; + $result['network']['count'] = 0; + + if(! self::$uid) + return $result; + + $limit = intval(self::$limit); + $offset = self::$offset; + + $sql_extra = ''; + if(! (self::$vnotify & VNOTIFY_LIKE)) + $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + + $sql_extra2 = ''; + if(self::$xchans) + $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) "; + + $item_normal = item_normal(); + + if ($notifications) { + $items = q("SELECT * FROM item + WHERE uid = %d + AND created <= '%s' + AND item_unseen = 1 AND item_wall = 0 + AND author_xchan != '%s' + $item_normal + $sql_extra + $sql_extra2 + ORDER BY created DESC LIMIT $limit OFFSET $offset", + intval(self::$uid), + dbescdate($_SESSION['sse_loadtime']), + dbesc(self::$ob_hash) + ); + + if($items) { + $result['network']['offset'] = ((count($items) == $limit) ? intval($offset + $limit) : -1); + xchan_query($items); + foreach($items as $item) { + $result['network']['notifications'][] = Enotify::format($item); + } + } + else { + $result['network']['offset'] = -1; + } + + } + + $r = q("SELECT count(id) as total FROM item + WHERE uid = %d and item_unseen = 1 AND item_wall = 0 + $item_normal + $sql_extra + AND author_xchan != '%s'", + intval(self::$uid), + dbesc(self::$ob_hash) + ); + + if($r) + $result['network']['count'] = intval($r[0]['total']); + + return $result; + } + + function bs_home($notifications) { + + $result['home']['notifications'] = []; + $result['home']['count'] = 0; + + if(! self::$uid) + return $result; + + $limit = intval(self::$limit); + $offset = self::$offset; + + $sql_extra = ''; + if(! (self::$vnotify & VNOTIFY_LIKE)) + $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + + $sql_extra2 = ''; + if(self::$xchans) + $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) "; + + + $item_normal = item_normal(); + + if ($notifications) { + $items = q("SELECT * FROM item + WHERE uid = %d + AND created <= '%s' + AND item_unseen = 1 AND item_wall = 1 + AND author_xchan != '%s' + $item_normal + $sql_extra + $sql_extra2 + ORDER BY created DESC LIMIT $limit OFFSET $offset", + intval(self::$uid), + dbescdate($_SESSION['sse_loadtime']), + dbesc(self::$ob_hash) + ); + + if($items) { + $result['home']['offset'] = ((count($items) == $limit) ? intval($offset + $limit) : -1); + xchan_query($items); + foreach($items as $item) { + $result['home']['notifications'][] = Enotify::format($item); + } + } + else { + $result['home']['offset'] = -1; + } + + } + + $r = q("SELECT count(id) as total FROM item + WHERE uid = %d and item_unseen = 1 AND item_wall = 1 + $item_normal + $sql_extra + AND author_xchan != '%s'", + intval(self::$uid), + dbesc(self::$ob_hash) + ); + + if($r) + $result['home']['count'] = intval($r[0]['total']); + + return $result; + } + + function bs_pubs($notifications) { + + $result['pubs']['notifications'] = []; + $result['pubs']['count'] = 0; + + if(! isset($_SESSION['static_loadtime'])) + $_SESSION['static_loadtime'] = datetime_convert(); + + $limit = intval(self::$limit); + $offset = self::$offset; + + $sys = get_sys_channel(); + $sql_extra = ''; + if(! (self::$vnotify & VNOTIFY_LIKE)) + $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + + $sql_extra2 = ''; + if(self::$xchans) + $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) "; + + $item_normal = item_normal(); + + if ($notifications) { + $items = q("SELECT * FROM item + WHERE uid = %d + AND created <= '%s' + AND item_unseen = 1 + AND author_xchan != '%s' + AND created > '%s' + $item_normal + $sql_extra + $sql_extra2 + ORDER BY created DESC LIMIT $limit OFFSET $offset", + intval($sys['channel_id']), + dbescdate($_SESSION['sse_loadtime']), + dbesc(self::$ob_hash), + dbescdate($_SESSION['static_loadtime']) + ); + + if($items) { + $result['pubs']['offset'] = ((count($items) == $limit) ? intval($offset + $limit) : -1); + xchan_query($items); + foreach($items as $item) { + $result['pubs']['notifications'][] = Enotify::format($item); + } + } + else { + $result['pubs']['offset'] = -1; + } + + + } + + $r = q("SELECT count(id) as total FROM item + WHERE uid = %d AND item_unseen = 1 + AND created > '%s' + $item_normal + $sql_extra + AND author_xchan != '%s'", + intval($sys['channel_id']), + dbescdate($_SESSION['static_loadtime']), + dbesc(self::$ob_hash) + ); + + if($r) + $result['pubs']['count'] = intval($r[0]['total']); + + return $result; + } + + + function bs_notify() { + + $result['notify']['notifications'] = []; + $result['notify']['count'] = 0; + $result['notify']['offset'] = -1; + + if(! self::$uid) + return $result; + + $r = q("SELECT * FROM notify WHERE uid = %d AND seen = 0 ORDER BY created DESC", + intval(self::$uid) + ); + if($r) { + foreach($r as $rr) { + $result['notify']['notifications'][] = Enotify::format_notify($rr); + } + $result['notify']['count'] = count($r); + } + + return $result; + + } + + function bs_intros() { + + $result['intros']['notifications'] = []; + $result['intros']['count'] = 0; + $result['intros']['offset'] = -1; + + if(! self::$uid) + return $result; + + $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ORDER BY abook_created DESC LIMIT 50", + intval(self::$uid) + ); + + if($r) { + foreach($r as $rr) { + $result['intros']['notifications'][] = Enotify::format_intros($rr); + } + $result['intros']['count'] = count($r); + } + + return $result; + + } + + function bs_forums() { + + $result['forums']['notifications'] = []; + $result['forums']['count'] = 0; + $result['forums']['offset'] = -1; + + if(! self::$uid) + return $result; + + $forums = get_forum_channels(self::$uid); + + if($forums) { + $item_normal = item_normal(); + + $sql_extra = ''; + if(! (self::$vnotify & VNOTIFY_LIKE)) + $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + + $fcount = count($forums); + $i = 0; + + for($x = 0; $x < $fcount; $x ++) { + $p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'", + intval(self::$uid), + intval(TERM_FORUM), + dbesc($forums[$x]['xchan_name']) + ); + + $p_str = ids_to_querystr($p, 'parent'); + $p_sql = (($p_str) ? "OR parent IN ( $p_str )" : ''); + + $r = q("select count(id) as unseen from item + where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $sql_extra $item_normal", + intval(self::$uid), + dbesc($forums[$x]['xchan_hash']), + dbesc($forums[$x]['xchan_hash']) + ); + + if($r[0]['unseen']) { + $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']); + $forums[$x]['name'] = $forums[$x]['xchan_name']; + $forums[$x]['addr'] = $forums[$x]['xchan_addr']; + $forums[$x]['url'] = $forums[$x]['xchan_url']; + $forums[$x]['photo'] = $forums[$x]['xchan_photo_s']; + $forums[$x]['unseen'] = $r[0]['unseen']; + $forums[$x]['private_forum'] = (($forums[$x]['private_forum']) ? 'lock' : ''); + $forums[$x]['message'] = (($forums[$x]['private_forum']) ? t('Private forum') : t('Public forum')); + + unset($forums[$x]['abook_id']); + unset($forums[$x]['xchan_hash']); + unset($forums[$x]['xchan_name']); + unset($forums[$x]['xchan_url']); + unset($forums[$x]['xchan_photo_s']); + + $i = $i + $r[0]['unseen']; + + } + else { + unset($forums[$x]); + } + } + + $result['forums']['count'] = $i; + $result['forums']['notifications'] = array_values($forums); + + } + + return $result; + + } + + function bs_files() { + + $result['files']['notifications'] = []; + $result['files']['count'] = 0; + $result['files']['offset'] = -1; + + if(! self::$uid) + return $result; + + $r = q("SELECT * FROM item + WHERE verb = '%s' + AND obj_type = '%s' + AND uid = %d + AND owner_xchan != '%s' + AND item_unseen = 1", + dbesc(ACTIVITY_POST), + dbesc(ACTIVITY_OBJ_FILE), + intval(self::$uid), + dbesc(self::$ob_hash) + ); + if($r) { + xchan_query($r); + foreach($r as $rr) { + $result['files']['notifications'][] = Enotify::format_files($rr); + } + $result['files']['count'] = count($r); + } + + return $result; + + } + + function bs_mail() { + + $result['mail']['notifications'] = []; + $result['mail']['count'] = 0; + $result['mail']['offset'] = -1; + + if(! self::$uid) + return $result; + + $r = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan + where channel_id = %d and mail_seen = 0 and mail_deleted = 0 + and from_xchan != '%s' order by created desc", + intval(self::$uid), + dbesc(self::$ob_hash) + ); + + if($r) { + foreach($r as $rr) { + $result['mail']['notifications'][] = Enotify::format_mail($rr); + } + $result['mail']['count'] = count($r); + } + + return $result; + + } + + function bs_all_events() { + + $result['all_events']['notifications'] = []; + $result['all_events']['count'] = 0; + $result['all_events']['offset'] = -1; + + if(! self::$uid) + return $result; + + $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash + WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 + and etype in ( 'event', 'birthday' ) + ORDER BY dtstart DESC", + intval(self::$uid), + dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval(self::$evdays) . ' days')), + dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) + ); + + if($r) { + foreach($r as $rr) { + $result['all_events']['notifications'][] = Enotify::format_all_events($rr); + } + $result['all_events']['count'] = count($r); + } + + return $result; + } + + function bs_register() { + + $result['register']['notifications'] = []; + $result['register']['count'] = 0; + $result['register']['offset'] = -1; + + if(! self::$uid && ! is_site_admin()) + return $result; + + $r = q("SELECT account_email, account_created from account where (account_flags & %d) > 0", + intval(ACCOUNT_PENDING) + ); + if($r) { + foreach($r as $rr) { + $result['register']['notifications'][] = Enotify::format_register($rr); + } + $result['register']['count'] = count($r); + } + + return $result; + + } + +} -- cgit v1.2.3 From 209d06a8f795282ddf370dff8228d2385004d05a Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 12 Nov 2019 10:11:58 +0000 Subject: better detection for who to send sys notifications (needs addons update) --- Zotlabs/Module/Sse.php | 2 ++ Zotlabs/Module/Sse_bs.php | 3 +++ 2 files changed, 5 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index 97fee5f49..6f7e9543a 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -84,6 +84,7 @@ class Sse extends Controller { echo "\n\n"; del_xconfig(self::$ob_hash, 'sse', 'notifications'); + set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); unset($result); } @@ -96,6 +97,7 @@ class Sse extends Controller { flush(); if(connection_status() != CONNECTION_NORMAL || connection_aborted()) { + del_xconfig(self::$ob_hash, 'sse', 'timestamp'); break; } diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 672a6c5ef..c591a00bf 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -27,6 +27,9 @@ class Sse_bs extends Controller { self::$offset = 0; self::$xchans = ''; + if(self::$ob_hash) + set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); + if(!empty($_GET['nquery']) && $_GET['nquery'] !== '%') { $nquery = $_GET['nquery']; -- cgit v1.2.3 From 6e36820b1bbc35bc3d26ff4eca2b63a386b30462 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 12 Nov 2019 21:15:01 +0000 Subject: sse: do not delete xconfig - reset it --- Zotlabs/Module/Sse.php | 5 +++-- Zotlabs/Module/Sse_bs.php | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index 6f7e9543a..3e46a325c 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -83,7 +83,7 @@ class Sse extends Controller { echo 'data: ' . json_encode($result); echo "\n\n"; - del_xconfig(self::$ob_hash, 'sse', 'notifications'); + set_xconfig(self::$ob_hash, 'sse', 'notifications', []); set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); unset($result); } @@ -97,7 +97,8 @@ class Sse extends Controller { flush(); if(connection_status() != CONNECTION_NORMAL || connection_aborted()) { - del_xconfig(self::$ob_hash, 'sse', 'timestamp'); + //TODO: this does not seem to be triggered + set_xconfig(self::$ob_hash, 'sse', 'timestamp', NULL_DATE); break; } diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index c591a00bf..c7fcd0542 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -27,8 +27,10 @@ class Sse_bs extends Controller { self::$offset = 0; self::$xchans = ''; - if(self::$ob_hash) + if(self::$ob_hash) { set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); + set_xconfig(self::$ob_hash, 'sse', 'language', App::$language); + } if(!empty($_GET['nquery']) && $_GET['nquery'] !== '%') { $nquery = $_GET['nquery']; -- cgit v1.2.3 From e5e16da8cba85d347351f6d3f243fa7c5fee4c2f Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Nov 2019 13:26:28 +0000 Subject: sse: reset to empty string instead of empty array --- Zotlabs/Module/Sse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index 3e46a325c..e1778718c 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -83,7 +83,7 @@ class Sse extends Controller { echo 'data: ' . json_encode($result); echo "\n\n"; - set_xconfig(self::$ob_hash, 'sse', 'notifications', []); + set_xconfig(self::$ob_hash, 'sse', 'notifications', ''); set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); unset($result); } -- cgit v1.2.3 From 52bd27a0280c736e563ccc67a9307cd75bd14d3f Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Nov 2019 13:40:40 +0000 Subject: check if file exists --- Zotlabs/Web/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index c4db0ef3e..96bf131b8 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -56,7 +56,7 @@ class Router { $routes = Route::get(); if($routes) { foreach($routes as $route) { - if(is_array($route) && strtolower($route[1]) === $module) { + if(is_array($route) && file_exists($route[0]) && strtolower($route[1]) === $module) { include_once($route[0]); if(class_exists($modname)) { $this->controller = new $modname; -- cgit v1.2.3 From a982aecd5b2f8f36507f6893028232d7f7a4c008 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Nov 2019 13:51:00 +0000 Subject: sse: revert to reset to array --- Zotlabs/Module/Sse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index e1778718c..3e46a325c 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -83,7 +83,7 @@ class Sse extends Controller { echo 'data: ' . json_encode($result); echo "\n\n"; - set_xconfig(self::$ob_hash, 'sse', 'notifications', ''); + set_xconfig(self::$ob_hash, 'sse', 'notifications', []); set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); unset($result); } -- cgit v1.2.3 From f3fa2d853ab04441e223b0074462bf11c6f99184 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 13 Nov 2019 14:30:54 +0000 Subject: sse: make sure we have an observer --- Zotlabs/Module/Sse.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index 3e46a325c..556fe2853 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -24,6 +24,9 @@ class Sse extends Controller { self::$ob_hash = get_observer_hash(); self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify'); + if(! self::$ob_hash) + return; + $sleep_seconds = 3; header("Content-Type: text/event-stream"); -- cgit v1.2.3 From 3009c88d246ddcafabf1965f88c5ebd8fe1717fd Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 09:43:39 +0000 Subject: AP fixes --- Zotlabs/Lib/Activity.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index e41e165b1..08a8b8d03 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -609,9 +609,15 @@ class Activity { } if($i['id'] != $i['parent']) { - $ret['inReplyTo'] = ((strpos($i['thr_parent'],'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent'])); $reply = true; + // inReplyTo needs to be set in the activity for followup actiions (Like, Dislike, Attend, Announce, etc.), + // but *not* for comments, where it should only be present in the object + + if (! in_array($ret['type'],[ 'Create','Update' ])) { + $ret['inReplyTo'] = ((strpos($i['thr_parent'],'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent'])); + } + if($i['item_private']) { $d = q("select xchan_url, xchan_addr, xchan_name from item left join xchan on xchan_hash = author_xchan where id = %d limit 1", intval($i['parent']) -- cgit v1.2.3 From de9a7f0fa909792656d26d369f2ff21c57fc1e4d Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 09:55:44 +0000 Subject: make inline pdf a security option, move thumbnail security to security options from admin/site --- Zotlabs/Module/Admin/Security.php | 14 +++++++++++--- Zotlabs/Module/Admin/Site.php | 3 --- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Security.php b/Zotlabs/Module/Admin/Security.php index 80c1d85b7..16045f9ed 100644 --- a/Zotlabs/Module/Admin/Security.php +++ b/Zotlabs/Module/Admin/Security.php @@ -43,6 +43,12 @@ class Security { $be = $this->trim_array_elems(explode("\n",$_POST['embed_deny'])); set_config('system','embed_deny',$be); + + $thumbnail_security = ((x($_POST,'thumbnail_security')) ? intval($_POST['thumbnail_security']) : 0); + set_config('system', 'thumbnail_security' , $thumbnail_security); + + $inline_pdf = ((x($_POST,'inline_pdf')) ? intval($_POST['inline_pdf']) : 0); + set_config('system', 'inline_pdf' , $inline_pdf); $ts = ((x($_POST,'transport_security')) ? True : False); set_config('system','transport_security_header',$ts); @@ -86,7 +92,7 @@ class Security { $embedhelp2 = t("The recommended setting is to only allow unfiltered HTML from the following sites:"); $embedhelp3 = t("https://youtube.com/
https://www.youtube.com/
https://youtu.be/
https://vimeo.com/
https://soundcloud.com/
"); $embedhelp4 = t("All other embedded content will be filtered, unless embedded content from that site is explicitly blocked."); - + $t = get_markup_template('admin_security.tpl'); return replace_macros($t, array( '$title' => t('Administration'), @@ -106,7 +112,9 @@ class Security { '$embed_sslonly' => array('embed_sslonly',t('Only allow embeds from secure (SSL) websites and links.'), intval(get_config('system','embed_sslonly')),''), '$embed_allow' => array('embed_allow', t('Allow unfiltered embedded HTML content only from these domains'), $whiteembeds_str, t('One site per line. By default embedded content is filtered.')), '$embed_deny' => array('embed_deny', t('Block embedded HTML from these domains'), $blackembeds_str, ''), - + '$thumbnail_security' => [ 'thumbnail_security', t("Allow SVG thumbnails in file browser"), get_config('system','thumbnail_security',0), t("WARNING: SVG images may contain malicious code.") ], + '$inline_pdf' => [ 'inline_pdf', t("Allow embedded (inline) PDF files"), get_config('system','inline_pdf',0), '' ], + // '$embed_coop' => array('embed_coop', t('Cooperative embed security'), $embed_coop, t('Enable to share embed security with other compatible sites/hubs')), '$submit' => t('Submit') @@ -128,4 +136,4 @@ class Security { } -} \ No newline at end of file +} diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 55c8ca928..4bb34b7b7 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -73,7 +73,6 @@ class Site { $feed_contacts = ((x($_POST,'feed_contacts')) ? intval($_POST['feed_contacts']) : 0); $verify_email = ((x($_POST,'verify_email')) ? 1 : 0); $imagick_path = ((x($_POST,'imagick_path')) ? trim($_POST['imagick_path']) : ''); - $thumbnail_security = ((x($_POST,'thumbnail_security')) ? intval($_POST['thumbnail_security']) : 0); $force_queue = ((intval($_POST['force_queue']) > 0) ? intval($_POST['force_queue']) : 3000); $pub_incl = escape_tags(trim($_POST['pub_incl'])); $pub_excl = escape_tags(trim($_POST['pub_excl'])); @@ -100,7 +99,6 @@ class Site { set_config('system', 'from_email', $from_email); set_config('system', 'from_email_name' , $from_email_name); set_config('system', 'imagick_convert_path' , $imagick_path); - set_config('system', 'thumbnail_security' , $thumbnail_security); set_config('system', 'default_permissions_role', $permissions_role); set_config('system', 'pubstream_incl',$pub_incl); set_config('system', 'pubstream_excl',$pub_excl); @@ -341,7 +339,6 @@ class Site { '$force_queue' => array('force_queue', t("Queue Threshold"), get_config('system','force_queue_threshold',3000), t("Always defer immediate delivery if queue contains more than this number of entries.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$imagick_path' => array('imagick_path', t("Path to ImageMagick convert program"), get_config('system','imagick_convert_path'), t("If set, use this program to generate photo thumbnails for huge images ( > 4000 pixels in either dimension), otherwise memory exhaustion may occur. Example: /usr/bin/convert")), - '$thumbnail_security' => array('thumbnail_security', t("Allow SVG thumbnails in file browser"), get_config('system','thumbnail_security',0), t("WARNING: SVG images may contain malicious code.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (grid/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$active_expire_days' => array('active_expire_days', t('Do not expire any posts which have comments less than this many days ago'), intval(get_config('system','active_expire_days',7)), ''), -- cgit v1.2.3 From 5a6b14f8787927ee6ea99c622d02875811d3a74a Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 10:01:21 +0000 Subject: onepoll: do not update dead feeds --- Zotlabs/Daemon/Onepoll.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index 1d9fd5f72..2f06ec125 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -61,11 +61,13 @@ class Onepoll { if($contact['xchan_network'] === 'rss') { logger('onepoll: processing feed ' . $contact['xchan_name'], LOGGER_DEBUG); - handle_feed($importer['channel_id'],$contact_id,$contact['xchan_hash']); - q("update abook set abook_connected = '%s' where abook_id = %d", - dbesc(datetime_convert()), - intval($contact['abook_id']) - ); + $alive = handle_feed($importer['channel_id'],$contact_id,$contact['xchan_hash']); + if ($alive) { + q("update abook set abook_connected = '%s' where abook_id = %d", + dbesc(datetime_convert()), + intval($contact['abook_id']) + ); + } return; } -- cgit v1.2.3 From 965c51c2d45a98db10543c5108ac486e4fc6459e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 20:29:58 +0000 Subject: sse: implement notifications for anonymous visitors (info, notice and pubs) and fix a potential memory leak --- Zotlabs/Daemon/Cron_daily.php | 6 ++++++ Zotlabs/Module/Sse.php | 31 +++++++++++++++++++++++++------ Zotlabs/Module/Sse_bs.php | 32 +++++++++++++++++++++++++------- 3 files changed, 56 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index dbfcff439..b41625963 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -44,6 +44,12 @@ class Cron_daily { db_utcnow(), db_quoteinterval('1 YEAR') ); + // expire anonymous sse notification entries once a day + + q("delete from xconfig where xchan like '%s'", + dbesc('sse_id.%') + ); + //update statistics in config require_once('include/statistics_fns.php'); diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index 556fe2853..b227a396d 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -11,22 +11,41 @@ class Sse extends Controller { public static $uid; public static $ob_hash; + public static $sse_id; public static $vnotify; function init() { + if((observer_prohibited(true))) { + killme(); + } + + if(! intval(get_config('system','open_pubstream',1))) { + if(! get_observer_hash()) { + killme(); + } + } + // this is important! session_write_close(); - $sys = get_sys_channel(); - self::$uid = local_channel(); self::$ob_hash = get_observer_hash(); - self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify'); + self::$sse_id = false; - if(! self::$ob_hash) - return; + if(! self::$ob_hash) { + if(session_id()) { + self::$sse_id = true; + self::$ob_hash = 'sse_id.' . session_id(); + } + else { + return; + } + } + self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify'); + + $sys = get_sys_channel(); $sleep_seconds = 3; header("Content-Type: text/event-stream"); @@ -40,7 +59,7 @@ class Sse extends Controller { * Update chat presence indication (if applicable) */ - if(self::$ob_hash) { + if(! self::$sse_id) { $r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1", dbesc(self::$ob_hash), dbesc($_SERVER['REMOTE_ADDR']) diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index c7fcd0542..270e8b9b9 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -11,6 +11,7 @@ class Sse_bs extends Controller { public static $uid; public static $ob_hash; + public static $sse_id; public static $vnotify; public static $evdays; public static $limit; @@ -21,16 +22,26 @@ class Sse_bs extends Controller { self::$uid = local_channel(); self::$ob_hash = get_observer_hash(); + self::$sse_id = false; + + if(! self::$ob_hash) { + if(session_id()) { + self::$sse_id = true; + self::$ob_hash = 'sse_id.' . session_id(); + } + else { + return; + } + } + self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify'); self::$evdays = intval(get_pconfig(self::$uid, 'system', 'evdays')); self::$limit = 100; self::$offset = 0; self::$xchans = ''; - if(self::$ob_hash) { - set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); - set_xconfig(self::$ob_hash, 'sse', 'language', App::$language); - } + set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); + set_xconfig(self::$ob_hash, 'sse', 'language', App::$language); if(!empty($_GET['nquery']) && $_GET['nquery'] !== '%') { $nquery = $_GET['nquery']; @@ -69,9 +80,6 @@ class Sse_bs extends Controller { default: } - //hz_syslog('init: ' . argv(1)); - //hz_syslog('offset: ' . argv(2)); - if(self::$offset && $f) { $result = self::$f(true); json_return_and_die($result); @@ -227,6 +235,16 @@ class Sse_bs extends Controller { $result['pubs']['notifications'] = []; $result['pubs']['count'] = 0; + if((observer_prohibited(true))) { + return $result; + } + + if(! intval(get_config('system','open_pubstream',1))) { + if(! get_observer_hash()) { + return $result; + } + } + if(! isset($_SESSION['static_loadtime'])) $_SESSION['static_loadtime'] = datetime_convert(); -- cgit v1.2.3 From 9ad2902addd2cdf17559a1b2927cdf0f5230af63 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 18 Nov 2019 12:55:02 +0100 Subject: Remove unnecessary brackets --- Zotlabs/Module/Articles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php index e3ad54be8..f15a15efb 100644 --- a/Zotlabs/Module/Articles.php +++ b/Zotlabs/Module/Articles.php @@ -211,7 +211,7 @@ class Articles extends Controller { } // Add Opengraph markup - opengraph_add_meta(((! empty($items)) ? $r[0] : array()), App::$profile); + opengraph_add_meta((! empty($items) ? $r[0] : array()), App::$profile); $mode = 'articles'; -- cgit v1.2.3 From 5ee133843f166a58e0c6236e543204be8dae70d3 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 18 Nov 2019 12:55:09 +0100 Subject: Remove base64 decode check on Opengraph tags create --- Zotlabs/Module/Channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 3f617fd18..3bf7ad501 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -376,7 +376,7 @@ class Channel extends Controller { } // Add Opengraph markup - opengraph_add_meta((isset($decoded) && (! empty($items)) ? $r[0] : array()), App::$profile); + opengraph_add_meta((! empty($items) ? $r[0] : array()), App::$profile); if((! $update) && (! $load)) { -- cgit v1.2.3 From c7a05264282122162fc43bb680924daf8f22a95f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 18 Nov 2019 15:40:51 +0100 Subject: Move back Opengraph markup creation to init stage --- Zotlabs/Module/Channel.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 3bf7ad501..6034bd7da 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -110,8 +110,20 @@ class Channel extends Controller { // Run profile_load() here to make sure the theme is set before // we start loading content - profile_load($which,$profile); + + // Add Opengraph markup + $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); + if(strpos($mid,'b64.') === 0) + $mid = @base64url_decode(substr($mid,4)); + + if($mid) + $r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d AND item_private = 0 LIMIT 1", + dbesc($mid), + intval($channel['channel_id']) + ); + + opengraph_add_meta($r ? $r[0] : [], $channel); } function get($update = 0, $load = false) { -- cgit v1.2.3 From 78868314a72f529be16504409afdbe071444dcc0 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 18 Nov 2019 15:47:03 +0100 Subject: Use channelx array on Opengraph markup procedure --- Zotlabs/Module/Articles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php index f15a15efb..44aa4c1ec 100644 --- a/Zotlabs/Module/Articles.php +++ b/Zotlabs/Module/Articles.php @@ -211,7 +211,7 @@ class Articles extends Controller { } // Add Opengraph markup - opengraph_add_meta((! empty($items) ? $r[0] : array()), App::$profile); + opengraph_add_meta((! empty($items) ? $r[0] : array()), $channel); $mode = 'articles'; -- cgit v1.2.3 From 6f1188f44feca7055e4fad2a902dca1fa1d1914f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 18 Nov 2019 15:52:59 +0100 Subject: Update Articles.php --- Zotlabs/Module/Articles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php index 44aa4c1ec..2c43b4764 100644 --- a/Zotlabs/Module/Articles.php +++ b/Zotlabs/Module/Articles.php @@ -211,7 +211,7 @@ class Articles extends Controller { } // Add Opengraph markup - opengraph_add_meta((! empty($items) ? $r[0] : array()), $channel); + opengraph_add_meta((! empty($items) ? $r[0] : []), $channel); $mode = 'articles'; -- cgit v1.2.3 From 53ad04cdc4bd55e4d5b182ebaca2792a81d3c75a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 18 Nov 2019 20:33:55 +0100 Subject: Remove duplicate Opengraph creation --- Zotlabs/Module/Channel.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 6034bd7da..d975ac1bf 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -387,9 +387,6 @@ class Channel extends Controller { $items = array(); } - // Add Opengraph markup - opengraph_add_meta((! empty($items) ? $r[0] : array()), App::$profile); - if((! $update) && (! $load)) { if($decoded) -- cgit v1.2.3 From 23c47f78eada85c1f897bbf348a4f802db9ef2f9 Mon Sep 17 00:00:00 2001 From: "M. Dent" Date: Fri, 22 Nov 2019 14:59:45 +0100 Subject: More descriptive connection status icons --- Zotlabs/Module/Connections.php | 23 +++++++++++++++++++++++ Zotlabs/Module/Viewconnections.php | 24 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index f6133d5f8..f9d9c7135 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -283,6 +283,28 @@ class Connections extends \Zotlabs\Web\Controller { if(! intval(get_abconfig(local_channel(),$rr['xchan_hash'],'their_perms','post_comments'))) { $oneway = true; } + + $perminfo['connpermcount']=0; + $perminfo['connperms']=t('Accepts').': '; + if(intval(get_abconfig(local_channel(),$rr['xchan_hash'],'their_perms','post_comments'))) { + $perminfo['connpermcount']++; + $perminfo['connperms'] .= t('Comments'); + } + if(intval(get_abconfig(local_channel(),$rr['xchan_hash'],'their_perms','send_stream'))) { + $perminfo['connpermcount']++; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] .= t('Stream items'); + } + if(intval(get_abconfig(local_channel(),$rr['xchan_hash'],'their_perms','post_wall'))) { + $perminfo['connpermcount']++; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] .= t('Wall posts'); + } + + if ($perminfo['connpermcount'] == 0) { + $perminfo['connperms'] .= t('Nothing'); + } + foreach($status as $str) { if(!$str) @@ -323,6 +345,7 @@ class Connections extends \Zotlabs\Web\Controller { 'recent_label' => t('Recent activity'), 'recentlink' => z_root() . '/network/?f=&cid=' . intval($rr['abook_id']) . '&name=' . $rr['xchan_name'], 'oneway' => $oneway, + 'perminfo' => $perminfo, 'connect' => (intval($rr['abook_not_here']) ? t('Connect') : ''), 'follow' => z_root() . '/follow/?f=&url=' . urlencode($rr['xchan_hash']) . '&interactive=0', 'connect_hover' => t('Connect at this location') diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 30df0b9e4..18a52c247 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -74,6 +74,29 @@ class Viewconnections extends \Zotlabs\Web\Controller { if(! intval(get_abconfig(\App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_comments'))) { $oneway = true; } + + $perminfo=[]; + $perminfo['connpermcount']=0; + $perminfo['connperms']=t('Accepts').': '; + if(intval(get_abconfig(\App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_comments'))) { + $perminfo['connpermcount']++; + $perminfo['connperms'] .= t('Comments'); + } + if(intval(get_abconfig(\App::$profile['uid'],$rr['xchan_hash'],'their_perms','send_stream'))) { + $perminfo['connpermcount']++; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] .= t('Stream items'); + } + if(intval(get_abconfig(\App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_wall'))) { + $perminfo['connpermcount']++; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] .= t('Wall posts'); + } + + if ($perminfo['connpermcount'] == 0) { + $perminfo['connperms'] .= t('Nothing'); + } + $url = chanlink_hash($rr['xchan_hash']); if($url) { @@ -88,6 +111,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '', + 'perminfo' => $perminfo, 'oneway' => $oneway ); } -- cgit v1.2.3 From b62eb665c5ad12ec7bde6bace71a0ddbb6aac28d Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 22 Nov 2019 14:11:26 +0000 Subject: sse: store the item mid plus reactions mids in data-mids and change functions accordingly --- Zotlabs/Lib/Enotify.php | 3 ++- Zotlabs/Lib/ThreadItem.php | 14 +++++++++++++- Zotlabs/Module/Display.php | 3 ++- Zotlabs/Module/Hq.php | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index de2bfba24..c1a6c9fdc 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -845,7 +845,8 @@ class Enotify { 'photo' => $item[$who]['xchan_photo_s'], 'when' => (($edit) ? datetime_convert('UTC', date_default_timezone_get(), $item['edited']) : datetime_convert('UTC', date_default_timezone_get(), $item['created'])), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), - 'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), + 'b64mid' => 'b64.' . base64url_encode($item['mid']), + //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => strip_tags(bbcode($itemem_text)), diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 174af7f0e..0f59953dc 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -78,7 +78,7 @@ class ThreadItem { */ public function get_template_data($conv_responses, $thread_level=1, $conv_flags = []) { - + $result = array(); $item = $this->get_data(); @@ -356,6 +356,17 @@ class ThreadItem { call_hooks('dropdown_extras',$dropdown_extras_arr); $dropdown_extras = $dropdown_extras_arr['dropdown_extras']; + $mids = ['b64.' . base64url_encode($item['mid'])]; + $response_mids = []; + foreach($response_verbs as $v) { + if(isset($conv_responses[$v]['mids'][$item['mid']])) { + $response_mids = array_merge($response_mids, $conv_responses[$v]['mids'][$item['mid']]); + } + } + + $mids = array_merge($mids, $response_mids); + $json_mids = json_encode($mids); + $tmp_item = array( 'template' => $this->get_template(), 'mode' => $mode, @@ -370,6 +381,7 @@ class ThreadItem { 'text' => strip_tags($body['html']), 'id' => $this->get_id(), 'mid' => 'b64.' . base64url_encode($item['mid']), + 'mids' => $json_mids, 'parent' => $item['parent'], 'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), 'isevent' => $isevent, diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 5983578b3..cf38aba1a 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -200,7 +200,8 @@ class Display extends \Zotlabs\Web\Controller { // if the target item is not a post (eg a like) we want to address its thread parent - $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); + //$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); + $mid = $target_item['mid']; // if we got a decoded hash we must encode it again before handing to javascript if($decoded) diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 848fe3e25..d8c540fb9 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -152,8 +152,8 @@ class Hq extends \Zotlabs\Web\Controller { if($target_item) { // if the target item is not a post (eg a like) we want to address its thread parent - $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); - + //$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); + $mid = $target_item['mid']; // if we got a decoded hash we must encode it again before handing to javascript if($decoded) $mid = 'b64.' . base64url_encode($mid); -- cgit v1.2.3 From 7864579b1e3d0d44f1dc25de794fcbc2211fd190 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 22 Nov 2019 19:20:02 +0100 Subject: Add space after comma in connection accepted interactions list --- Zotlabs/Module/Connections.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index f9d9c7135..029601867 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -292,12 +292,12 @@ class Connections extends \Zotlabs\Web\Controller { } if(intval(get_abconfig(local_channel(),$rr['xchan_hash'],'their_perms','send_stream'))) { $perminfo['connpermcount']++; - $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ', ' : $perminfo['connperms'] ; $perminfo['connperms'] .= t('Stream items'); } if(intval(get_abconfig(local_channel(),$rr['xchan_hash'],'their_perms','post_wall'))) { $perminfo['connpermcount']++; - $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ', ' : $perminfo['connperms'] ; $perminfo['connperms'] .= t('Wall posts'); } -- cgit v1.2.3 From e40ea62c7cf636bd00160cae27a9d99d9dbf3d40 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 22 Nov 2019 19:24:40 +0100 Subject: Add space after comma in connection accepted interactions list --- Zotlabs/Module/Viewconnections.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 18a52c247..320a331d1 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -84,12 +84,12 @@ class Viewconnections extends \Zotlabs\Web\Controller { } if(intval(get_abconfig(\App::$profile['uid'],$rr['xchan_hash'],'their_perms','send_stream'))) { $perminfo['connpermcount']++; - $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ', ' : $perminfo['connperms'] ; $perminfo['connperms'] .= t('Stream items'); } if(intval(get_abconfig(\App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_wall'))) { $perminfo['connpermcount']++; - $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ',' : $perminfo['connperms'] ; + $perminfo['connperms'] = ($perminfo['connperms']) ? $perminfo['connperms'] . ', ' : $perminfo['connperms'] ; $perminfo['connperms'] .= t('Wall posts'); } -- cgit v1.2.3 From 73a0866ac4666e615742884a9eb3464c742f787b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 22 Nov 2019 20:52:22 +0000 Subject: sse: fix a regression where not all appearances of an notification were looped through and fix format_notify() to not look for the parent item anymore --- Zotlabs/Lib/Enotify.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index c1a6c9fdc..bc2710ee1 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -872,19 +872,8 @@ class Enotify { $message = substr($message, strlen($tt['xname']) + 1); $mid = basename($tt['link']); - $mid = ((strpos($mid, 'b64.') === 0) ? @base64url_decode(substr($mid, 4)) : $mid); - if(in_array($tt['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { - // we need the thread parent - $r = q("select thr_parent from item where mid = '%s' and uid = %d limit 1", - dbesc($mid), - intval(local_channel()) - ); - $b64mid = ((strpos($r[0]['thr_parent'], 'b64.') === 0) ? $r[0]['thr_parent'] : 'b64.' . base64url_encode($r[0]['thr_parent'])); - } - else { - $b64mid = ((strpos($mid, 'b64.') === 0) ? $mid : 'b64.' . base64url_encode($mid)); - } + $b64mid = ((strpos($mid, 'b64.') === 0) ? $mid : 'b64.' . base64url_encode($mid)); $x = [ 'notify_link' => z_root() . '/notify/view/' . $tt['id'], -- cgit v1.2.3 From 0d47bb6878fc6920595b4252a54d76ba2486dabb Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 25 Nov 2019 12:59:16 +0000 Subject: remove sysmsg and sysmsg_info from session - those are now stored in xconfig (sse) --- Zotlabs/Web/WebServer.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php index 1c3ea29d0..909823ec4 100644 --- a/Zotlabs/Web/WebServer.php +++ b/Zotlabs/Web/WebServer.php @@ -82,14 +82,6 @@ class WebServer { if((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || (\App::$module === 'login')) require('include/auth.php'); - if(! x($_SESSION, 'sysmsg')) - $_SESSION['sysmsg'] = array(); - - if(! x($_SESSION, 'sysmsg_info')) - $_SESSION['sysmsg_info'] = array(); - - - if(\App::$install) { /* Allow an exception for the view module so that pcss will be interpreted during installation */ if(\App::$module != 'view') -- cgit v1.2.3 From 5c47c9ed9579dc97e0a508045fe50264bb96490b Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 25 Nov 2019 14:16:07 +0100 Subject: Add daily cached embedded content cleanup --- Zotlabs/Daemon/Cron_daily.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index b41625963..affb706a0 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -94,6 +94,12 @@ class Cron_daily { z6_discover(); call_hooks('cron_daily',datetime_convert()); + + // Clean up emdeded contect cache + q("DELETE FROM cache WHERE updated < %s - INTERVAL %s", + db_utcnow(), + db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY') + ); set_config('system','last_expire_day',intval(datetime_convert('UTC','UTC','now','d'))); -- cgit v1.2.3 From 38de059156f9a6ec63727d47a96d1b15e96e3b47 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 25 Nov 2019 14:32:58 +0100 Subject: Revert "Add daily cached embedded content cleanup" This reverts commit 5c47c9ed9579dc97e0a508045fe50264bb96490b --- Zotlabs/Daemon/Cron_daily.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index affb706a0..b41625963 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -94,12 +94,6 @@ class Cron_daily { z6_discover(); call_hooks('cron_daily',datetime_convert()); - - // Clean up emdeded contect cache - q("DELETE FROM cache WHERE updated < %s - INTERVAL %s", - db_utcnow(), - db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY') - ); set_config('system','last_expire_day',intval(datetime_convert('UTC','UTC','now','d'))); -- cgit v1.2.3 From 901785663edc7045c66d9393432a18bb376436bb Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 25 Nov 2019 21:50:02 +0100 Subject: Fix once cached embedded content is used and stored forever --- Zotlabs/Daemon/Cron_daily.php | 5 +++++ Zotlabs/Lib/Cache.php | 13 ++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index b41625963..452ef45f1 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -50,6 +50,11 @@ class Cron_daily { dbesc('sse_id.%') ); + // Clean up emdedded content cache + q("DELETE FROM cache WHERE updated < %s - INTERVAL %s", + db_utcnow(), + db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY') + ); //update statistics in config require_once('include/statistics_fns.php'); diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php index cea075659..878201a42 100644 --- a/Zotlabs/Lib/Cache.php +++ b/Zotlabs/Lib/Cache.php @@ -11,8 +11,10 @@ class Cache { $hash = hash('whirlpool',$key); - $r = q("SELECT v FROM cache WHERE k = '%s' limit 1", - dbesc($hash) + $r = q("SELECT v FROM cache WHERE k = '%s' AND updated > %s - INTERVAL %s LIMIT 1", + dbesc($hash), + db_utcnow(), + db_quoteinterval(get_config('system','object_cache_days', '30') . ' DAY') ); if ($r) @@ -40,12 +42,5 @@ class Cache { dbesc(datetime_convert())); } } - - - public static function clear() { - q("DELETE FROM cache WHERE updated < '%s'", - dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); - } - } -- cgit v1.2.3 From c86b35da701674510a97ccc21e46581bd864cc31 Mon Sep 17 00:00:00 2001 From: "DM42.Net Hubzilla Development" Date: Thu, 28 Nov 2019 00:27:12 -0500 Subject: Move auto_save_draft to header from thread comment --- Zotlabs/Lib/ThreadItem.php | 5 +---- Zotlabs/Module/Photos.php | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 0f59953dc..32cd52751 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -789,8 +789,6 @@ class ThreadItem { call_hooks('comment_buttons',$arr); $comment_buttons = $arr['comment_buttons']; - $feature_auto_save_draft = ((feature_enabled($conv->get_profile_owner(), 'auto_save_draft')) ? "true" : "false"); - $comment_box = replace_macros($template,array( '$return_path' => '', '$threaded' => $this->is_threaded(), @@ -825,8 +823,7 @@ class ThreadItem { '$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)') ], - '$auto_save_draft' => $feature_auto_save_draft + '$anonurl' => [ 'anonurl', t('Your website URL (optional)') ] )); return $comment_box; diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 13ec64ab9..43c9f86ee 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1080,7 +1080,6 @@ class Photos extends \Zotlabs\Web\Controller { $comments = ''; if(! $r) { if($observer && ($can_post || $can_comment)) { - $feature_auto_save_draft = ((feature_enabled($owner_uid, 'auto_save_draft')) ? "true" : "false"); $commentbox = replace_macros($cmnt_tpl,array( '$return_path' => '', '$mode' => 'photos', @@ -1096,8 +1095,7 @@ class Photos extends \Zotlabs\Web\Controller { '$submit' => t('Submit'), '$preview' => t('Preview'), '$ww' => '', - '$feature_encrypt' => false, - '$auto_save_draft' => $feature_auto_save_draft + '$feature_encrypt' => false )); } } -- cgit v1.2.3 From 2b08519f5ad2cf7803736b42159f92f754acb0bd Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 28 Nov 2019 08:22:53 +0000 Subject: sse: improve caching fix an issue with removing notifications and move chatpresence expiration to cron --- Zotlabs/Daemon/Cron.php | 9 +++++++++ Zotlabs/Module/Sse.php | 26 +++++++------------------- Zotlabs/Module/Sse_bs.php | 7 ++++--- 3 files changed, 20 insertions(+), 22 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index 8fa31e6ce..bd4e0b294 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -40,6 +40,15 @@ class Cron { require_once('include/sharedwithme.php'); apply_updates(); + + /** + * Chatpresence: if somebody hasn't pinged recently, they've most likely left the page + * and shouldn't count as online anymore. We allow an expection for bots. + */ + q("delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ", + db_utcnow(), + db_quoteinterval('3 MINUTE') + ); // expire any expired mail diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index b227a396d..b68fe6705 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -6,6 +6,7 @@ use App; use Zotlabs\Lib\Apps; use Zotlabs\Web\Controller; use Zotlabs\Lib\Enotify; +use Zotlabs\Lib\XConfig; class Sse extends Controller { @@ -83,30 +84,17 @@ class Sse extends Controller { } } - /** - * Chatpresence continued... if somebody hasn't pinged recently, they've most likely left the page - * and shouldn't count as online anymore. We allow an expection for bots. - */ - q("delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ", - db_utcnow(), - db_quoteinterval('3 MINUTE') - ); + XConfig::Load(self::$ob_hash); - $x = q("SELECT v FROM xconfig WHERE xchan = '%s' AND cat = 'sse' AND k = 'notifications'", - dbesc(self::$ob_hash) - ); - - if($x) { - $result = unserialize($x[0]['v']); - } + $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []); + $lock = XConfig::Get(self::$ob_hash, 'sse', 'lock'); - if($result) { + if($result && !$lock) { echo "event: notifications\n"; echo 'data: ' . json_encode($result); echo "\n\n"; - set_xconfig(self::$ob_hash, 'sse', 'notifications', []); - set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); + XConfig::Set(self::$ob_hash, 'sse', 'notifications', []); unset($result); } @@ -120,7 +108,7 @@ class Sse extends Controller { if(connection_status() != CONNECTION_NORMAL || connection_aborted()) { //TODO: this does not seem to be triggered - set_xconfig(self::$ob_hash, 'sse', 'timestamp', NULL_DATE); + XConfig::Set(self::$ob_hash, 'sse', 'timestamp', NULL_DATE); break; } diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 270e8b9b9..5e00593ef 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -40,9 +40,6 @@ class Sse_bs extends Controller { self::$offset = 0; self::$xchans = ''; - set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); - set_xconfig(self::$ob_hash, 'sse', 'language', App::$language); - if(!empty($_GET['nquery']) && $_GET['nquery'] !== '%') { $nquery = $_GET['nquery']; @@ -80,6 +77,10 @@ class Sse_bs extends Controller { default: } + set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); + set_xconfig(self::$ob_hash, 'sse', 'notifications', []); // reset the cache + set_xconfig(self::$ob_hash, 'sse', 'language', App::$language); + if(self::$offset && $f) { $result = self::$f(true); json_return_and_die($result); -- cgit v1.2.3 From f485ed174dc97b545d0a86c435d5f011ff98c953 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 1 Dec 2019 14:00:10 +0100 Subject: Add pinned items controls --- Zotlabs/Lib/ThreadItem.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 32cd52751..301ce1a18 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -95,7 +95,7 @@ class ThreadItem { $total_children = $this->count_descendants(); $unseen_comments = (($item['real_uid']) ? 0 : $this->count_unseen_descendants()); - $conv = $this->get_conversation(); + $conv = $this->get_conversation(); $observer = $conv->get_observer(); $lock = (((intval($item['item_private'])) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) @@ -356,7 +356,8 @@ class ThreadItem { call_hooks('dropdown_extras',$dropdown_extras_arr); $dropdown_extras = $dropdown_extras_arr['dropdown_extras']; - $mids = ['b64.' . base64url_encode($item['mid'])]; + $midb64 = 'b64.' . base64url_encode($item['mid']); + $mids = [ $midb64 ]; $response_mids = []; foreach($response_verbs as $v) { if(isset($conv_responses[$v]['mids'][$item['mid']])) { @@ -367,6 +368,11 @@ class ThreadItem { $mids = array_merge($mids, $response_mids); $json_mids = json_encode($mids); + // Pinned item processing + $allowed_type = (in_array($item['item_type'], get_config('system', 'pin_types', [ ITEM_TYPE_POST ])) ? true : false); + $pinned_items = ($allowed_type ? get_pconfig($item['uid'], 'pinned', $item['item_type'], []) : []); + $pinned = ((!empty($pinned_items) && in_array($midb64, $pinned_items)) ? true : false); + $tmp_item = array( 'template' => $this->get_template(), 'mode' => $mode, @@ -380,7 +386,7 @@ class ThreadItem { 'folders' => $body['folders'], 'text' => strip_tags($body['html']), 'id' => $this->get_id(), - 'mid' => 'b64.' . base64url_encode($item['mid']), + 'mid' => $midb64, 'mids' => $json_mids, 'parent' => $item['parent'], 'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), @@ -449,6 +455,9 @@ class ThreadItem { 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts') && ($item['item_type'] == ITEM_TYPE_POST)) ? $star : ''), 'tagger' => ((feature_enabled($conv->get_profile_owner(),'commtag')) ? $tagger : ''), 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing') && ($item['item_type'] == ITEM_TYPE_POST)) ? $filer : ''), + 'pinned' => ($pinned ? t('Pinned post') : ''), + 'pinnable' => (($this->is_toplevel() && local_channel() && $item['owner_xchan'] == $observer['xchan_hash'] && $allowed_type && $item['item_private'] == 0) ? '1' : ''), + 'pinme' => ($pinned ? t('Unpin from the top') : t('Pin to the top')), 'bookmark' => (($conv->get_profile_owner() == local_channel() && local_channel() && $has_bookmarks) ? t('Save Bookmarks') : ''), 'addtocal' => (($has_event) ? t('Add to Calendar') : ''), 'drop' => $drop, @@ -874,7 +883,4 @@ class ThreadItem { return $this->visiting; } - - - } -- cgit v1.2.3 From 042cc9696856a86ae37487a2db3efbd510d09150 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 1 Dec 2019 14:21:08 +0100 Subject: Add pinning processing module --- Zotlabs/Module/Pin.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Zotlabs/Module/Pin.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pin.php b/Zotlabs/Module/Pin.php new file mode 100644 index 000000000..65bb61a76 --- /dev/null +++ b/Zotlabs/Module/Pin.php @@ -0,0 +1,50 @@ + Date: Sun, 1 Dec 2019 14:26:18 +0100 Subject: Add pinned content widget --- Zotlabs/Widget/Pinned.php | 196 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 Zotlabs/Widget/Pinned.php (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php new file mode 100644 index 000000000..cee2196b5 --- /dev/null +++ b/Zotlabs/Widget/Pinned.php @@ -0,0 +1,196 @@ + EMPTY_STR, 'ids' => [] ]; + + $this->uid = intval($uid); + if(! $this->uid) + return $ret; + + $this->allowed_types = get_config('system', 'pin_types', [ ITEM_TYPE_POST ]); + + $id_list = $this->list($types); + + if(empty($id_list)) + return $ret; + + $ret['ids'] = array_column($id_list, 'id'); + + $observer = \App::get_observer(); + + foreach($id_list as $item) { + + $author = channelx_by_hash($item['author_xchan']); + $owner = channelx_by_hash($item['owner_xchan']); + + $profile_avatar = $author['xchan_photo_m']; + $profile_link = chanlink_hash($item['author_xchan']); + $profile_name = $author['xchan_name']; + + $commentable = ($item['item_commnet'] == 0 && $item['comments_closed'] == NULL_DATE ? true : false); + + $location = format_location($item); + $isevent = false; + $attend = null; + $canvote = false; + + if($item['obj_type'] === ACTIVITY_OBJ_EVENT) { + $response_verbs[] = 'attendyes'; + $response_verbs[] = 'attendno'; + $response_verbs[] = 'attendmaybe'; + if($commentable && $observer) { + $isevent = true; + $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); + } + } + + $consensus = (intval($item['item_consensus']) ? true : false); + if($consensus) { + $response_verbs[] = 'agree'; + $response_verbs[] = 'disagree'; + $response_verbs[] = 'abstain'; + if($commentable && $observer) { + $conlabels = array( t('I agree'), t('I disagree'), t('I abstain')); + $canvote = true; + } + } + + $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); + $forged = ((! intval($item['item_verified']) && $item['sig']) ? t('Message signature incorrect') : ''); + + $shareable = ((local_channel() && $item['item_private'] != 1) ? true : false); + if ($shareable) { + // This actually turns out not to be possible in some protocol stacks without opening up hundreds of new issues. + // Will allow it only for uri resolvable sources. + if(strpos($item['mid'],'http') === 0) { + $share = []; //Not yet ready for primetime + //$share = array( t('Repeat This'), t('repeat')); + } + $embed = array( t('Share This'), t('share')); + } + + if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) + $is_new = true; + + $body = prepare_body($item,true); + + $str = [ + 'item_type' => intval($item['item_type']), + 'body' => $body['html'], + 'tags' => $body['tags'], + 'categories' => $body['categories'], + 'mentions' => $body['mentions'], + 'attachments' => $body['attachments'], + 'folders' => $body['folders'], + 'text' => strip_tags($body['html']), + 'id' => $item['id'], + 'isevent' => $isevent, + 'attend' => $attend, + 'consensus' => $consensus, + 'conlabels' => $conlabels, + 'canvote' => $canvote, + 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, ($author['xchan_addr'] ? $author['xchan_addr'] : $author['xchan_url']) ), + 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $owner['xchan_name'], ($owner['xchan_addr'] ? $owner['xchan_addr'] : $owner['xchan_url']) ), + 'profile_url' => $profile_link, + 'name' => $profile_name, + 'thumb' => $profile_avatar, + 'via' => t('via'), + 'title' => $item['title'], + 'title_tosource' => get_pconfig($item['uid'],'system','title_tosource'), + 'ago' => relative_date($item['created']), + 'app' => $item['app'], + 'str_app' => sprintf( t('from %s'), $item['app'] ), + 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), + 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), + 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r') ) : ''), + 'expiretime' => ($item['expires'] > NULL_DATE ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r') ) : ''), + 'lock' => $lock, + 'verified' => $verified, + 'forged' => $forged, + 'location' => $location, + 'divider' => get_pconfig($item['uid'],'system','item_divider'), + 'attend_title' => t('Attendance Options'), + 'vote_title' => t('Voting Options'), + 'is_new' => $is_new, + 'owner_url' => ($owner['xchan_addr'] != $author['xchan_addr'] ? chanlink_hash($owner['xchan_hash']) : ''), + 'owner_photo' => $owner['xchan_photo_m'], + 'owner_name' => $owner['xchan_name'], + 'photo' => $body['photo'], + 'event' => $body['event'], + 'has_tags' => (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false), + // Item toolbar buttons + 'share' => $share, + 'embed' => $embed, + 'plink' => get_plink($item), + 'pinned' => t('Pinned post') + // end toolbar buttons + ]; + + $tpl = get_markup_template('pinned_item.tpl'); + $ret['html'] .= replace_macros($tpl, $str); + } + + return $ret; + } + + + /* + * @brief List pinned items depend on type + * + * @param $types + * @return array of pinned items + * + */ + private function list($types) { + + if(empty($types) || (! is_array($types))) + return []; + + $item_types = array_intersect($this->allowed_types, $types); + if(empty($item_types)) + return []; + + $mids_list = []; + + foreach($item_types as $type) { + + $mids = get_pconfig($this->uid, 'pinned', $type, []); + foreach($mids as $mid) { + if(! empty($mid) && strpos($mid,'b64.') === 0) + $mids_list[] = @base64url_decode(substr($mid,4)); + } + } + if(empty($mids_list)) + return []; + + $r = q("SELECT * FROM item WHERE mid IN ( '%s' ) AND uid = %d AND id = parent AND item_private = 0 ORDER BY created DESC", + dbesc(implode(",", $mids_list)), + intval($this->uid) + ); + if($r) + return $r; + + return []; + } +} -- cgit v1.2.3 From 3c1ff1fc63fc2ff86202b9e940bf8e83ad622884 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 1 Dec 2019 15:22:38 +0100 Subject: Add base64 mids array --- Zotlabs/Widget/Pinned.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index cee2196b5..33a1a59d4 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -105,6 +105,7 @@ class Pinned { 'folders' => $body['folders'], 'text' => strip_tags($body['html']), 'id' => $item['id'], + 'mids' => json_encode([ 'b64.' . base64url_encode($item['mid']) ]), 'isevent' => $isevent, 'attend' => $attend, 'consensus' => $consensus, -- cgit v1.2.3 From 5ccbcb44f7e4e2bbd3343ba48f417c98d0933f67 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 1 Dec 2019 15:52:57 +0100 Subject: Add pinned content on channel page --- Zotlabs/Module/Channel.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index d975ac1bf..20a5418c2 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -468,6 +468,13 @@ class Channel extends Controller { ); } } + + // Add pinned content + if(! $decoded && ! $search) { + $pinned = new \Zotlabs\Widget\Pinned; + $r = $pinned->widget(intval(App::$profile['profile_uid']), [ITEM_TYPE_POST]); + $o .= $r['html']; + } $mode = (($search) ? 'search' : 'channel'); -- cgit v1.2.3 From 8b00913579c2b96e0fb8e0361181d36602394b8a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 00:24:04 +0100 Subject: Show poll results in pinned items --- Zotlabs/Widget/Pinned.php | 194 +++++++++++++++++++++++++++++++++------------- 1 file changed, 140 insertions(+), 54 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 33a1a59d4..8d63d9986 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -30,16 +30,16 @@ class Pinned { $this->allowed_types = get_config('system', 'pin_types', [ ITEM_TYPE_POST ]); - $id_list = $this->list($types); + $items = $this->list($types); - if(empty($id_list)) + if(empty($items)) return $ret; - $ret['ids'] = array_column($id_list, 'id'); + $ret['ids'] = array_column($items, 'id'); $observer = \App::get_observer(); - foreach($id_list as $item) { + foreach($items as $item) { $author = channelx_by_hash($item['author_xchan']); $owner = channelx_by_hash($item['owner_xchan']); @@ -48,20 +48,22 @@ class Pinned { $profile_link = chanlink_hash($item['author_xchan']); $profile_name = $author['xchan_name']; - $commentable = ($item['item_commnet'] == 0 && $item['comments_closed'] == NULL_DATE ? true : false); + $commentable = ($item['item_nocomment'] == 0 && $item['comments_closed'] == NULL_DATE ? true : false); $location = format_location($item); $isevent = false; $attend = null; $canvote = false; - + + $response_verbs = []; + if($item['obj_type'] === ACTIVITY_OBJ_EVENT) { $response_verbs[] = 'attendyes'; $response_verbs[] = 'attendno'; $response_verbs[] = 'attendmaybe'; if($commentable && $observer) { - $isevent = true; $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); + $isevent = true; } } @@ -75,7 +77,19 @@ class Pinned { $canvote = true; } } + + $conv_responses = [ + 'agree' => [ 'title' => t('Agree','title') ], + 'disagree' => [ 'title' => t('Disagree','title') ], + 'abstain' => [ 'title' => t('Abstain','title') ], + 'attendyes' => [ 'title' => t('Attending','title') ], + 'attendno' => [ 'title' => t('Not attending','title') ], + 'attendmaybe' => [ 'title' => t('Might attend','title') ] + ]; + $this->activity($item, $conv_responses); +logger('$conv_responses: ' . print_r($conv_responses,true)); + $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); $forged = ((! intval($item['item_verified']) && $item['sig']) ? t('Message signature incorrect') : ''); @@ -96,56 +110,58 @@ class Pinned { $body = prepare_body($item,true); $str = [ - 'item_type' => intval($item['item_type']), - 'body' => $body['html'], - 'tags' => $body['tags'], - 'categories' => $body['categories'], - 'mentions' => $body['mentions'], - 'attachments' => $body['attachments'], - 'folders' => $body['folders'], - 'text' => strip_tags($body['html']), - 'id' => $item['id'], - 'mids' => json_encode([ 'b64.' . base64url_encode($item['mid']) ]), - 'isevent' => $isevent, - 'attend' => $attend, - 'consensus' => $consensus, - 'conlabels' => $conlabels, - 'canvote' => $canvote, - 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, ($author['xchan_addr'] ? $author['xchan_addr'] : $author['xchan_url']) ), - 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $owner['xchan_name'], ($owner['xchan_addr'] ? $owner['xchan_addr'] : $owner['xchan_url']) ), - 'profile_url' => $profile_link, - 'name' => $profile_name, - 'thumb' => $profile_avatar, - 'via' => t('via'), - 'title' => $item['title'], + 'item_type' => intval($item['item_type']), + 'body' => $body['html'], + 'tags' => $body['tags'], + 'categories' => $body['categories'], + 'mentions' => $body['mentions'], + 'attachments' => $body['attachments'], + 'folders' => $body['folders'], + 'text' => strip_tags($body['html']), + 'id' => $item['id'], + 'mids' => json_encode([ 'b64.' . base64url_encode($item['mid']) ]), + 'isevent' => $isevent, + 'attend' => $attend, + 'consensus' => $consensus, + 'conlabels' => $conlabels, + 'canvote' => $canvote, + 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, ($author['xchan_addr'] ? $author['xchan_addr'] : $author['xchan_url']) ), + 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $owner['xchan_name'], ($owner['xchan_addr'] ? $owner['xchan_addr'] : $owner['xchan_url']) ), + 'profile_url' => $profile_link, + 'name' => $profile_name, + 'thumb' => $profile_avatar, + 'via' => t('via'), + 'title' => $item['title'], 'title_tosource' => get_pconfig($item['uid'],'system','title_tosource'), - 'ago' => relative_date($item['created']), - 'app' => $item['app'], - 'str_app' => sprintf( t('from %s'), $item['app'] ), - 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), - 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), - 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r') ) : ''), - 'expiretime' => ($item['expires'] > NULL_DATE ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r') ) : ''), - 'lock' => $lock, - 'verified' => $verified, - 'forged' => $forged, - 'location' => $location, - 'divider' => get_pconfig($item['uid'],'system','item_divider'), - 'attend_title' => t('Attendance Options'), - 'vote_title' => t('Voting Options'), - 'is_new' => $is_new, - 'owner_url' => ($owner['xchan_addr'] != $author['xchan_addr'] ? chanlink_hash($owner['xchan_hash']) : ''), - 'owner_photo' => $owner['xchan_photo_m'], - 'owner_name' => $owner['xchan_name'], - 'photo' => $body['photo'], - 'event' => $body['event'], - 'has_tags' => (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false), + 'ago' => relative_date($item['created']), + 'app' => $item['app'], + 'str_app' => sprintf( t('from %s'), $item['app'] ), + 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), + 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), + 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r') ) : ''), + 'expiretime' => ($item['expires'] > NULL_DATE ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r') ) : ''), + 'lock' => $lock, + 'verified' => $verified, + 'forged' => $forged, + 'location' => $location, + 'divider' => get_pconfig($item['uid'],'system','item_divider'), + 'attend_title' => t('Attendance Options'), + 'vote_title' => t('Voting Options'), + 'is_new' => $is_new, + 'owner_url' => ($owner['xchan_addr'] != $author['xchan_addr'] ? chanlink_hash($owner['xchan_hash']) : ''), + 'owner_photo' => $owner['xchan_photo_m'], + 'owner_name' => $owner['xchan_name'], + 'photo' => $body['photo'], + 'event' => $body['event'], + 'has_tags' => (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false), // Item toolbar buttons - 'share' => $share, - 'embed' => $embed, - 'plink' => get_plink($item), - 'pinned' => t('Pinned post') + 'share' => $share, + 'embed' => $embed, + 'plink' => get_plink($item), + 'pinned' => t('Pinned post'), // end toolbar buttons + 'modal_dismiss' => t('Close'), + 'responses' => $conv_responses ]; $tpl = get_markup_template('pinned_item.tpl'); @@ -194,4 +210,74 @@ class Pinned { return []; } + + + /* + * @brief List activities on item + * + * @param array $item + * @param array $conv_responses + * @return array + * + */ + private function activity($item, &$conv_responses) { + + foreach(array_keys($conv_responses) as $verb) { + + switch($verb) { + case 'like': + $v = ACTIVITY_LIKE; + break; + case 'dislike': + $v = ACTIVITY_DISLIKE; + break; + case 'agree': + $v = ACTIVITY_AGREE; + break; + case 'disagree': + $v = ACTIVITY_DISAGREE; + break; + case 'abstain': + $v = ACTIVITY_ABSTAIN; + break; + case 'attendyes': + $v = ACTIVITY_ATTEND; + break; + case 'attendno': + $v = ACTIVITY_ATTENDNO; + break; + case 'attendmaybe': + $v = ACTIVITY_ATTENDMAYBE; + break; + default: + break; + } + + $r = q("SELECT * FROM item WHERE parent = %d AND id <> parent AND verb IN ( '%s' ) AND item_deleted = 0", + intval($item['id']), + dbesc($v) + ); + if(! $r) { + unset($conv_responses[$verb]); + continue; + } + + $conv_responses[$verb]['count'] = count($r); + $conv_responses[$verb]['button'] = get_response_button_text($verb, $conv_responses[$verb]['count']); + + foreach($r as $rr) { + + $author = q("SELECT * FROM xchan WHERE xchan_hash = '%s' LIMIT 1", + dbesc($rr['author_xchan']) + ); + $name = ($author[0]['xchan_name'] ? $author[0]['xchan_name'] : t('Unknown')); + $conv_responses[$verb]['list'][] = (($rr['author_xchan'] && $author[0]['xchan_photo_s']) ? + '' . '' . urlencode($name) . ' ' . $name . '' : + '' . $name . '' + ); + } + } + + $conv_responses['count'] = count($conv_responses); + } } -- cgit v1.2.3 From c17717c5dbba37ec598903706095f2c3905a843c Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 10:14:49 +0100 Subject: Remove debug logging --- Zotlabs/Widget/Pinned.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 8d63d9986..e2dc49018 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -88,7 +88,6 @@ class Pinned { ]; $this->activity($item, $conv_responses); -logger('$conv_responses: ' . print_r($conv_responses,true)); $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); $forged = ((! intval($item['item_verified']) && $item['sig']) ? t('Message signature incorrect') : ''); -- cgit v1.2.3 From 0532d639c29ad03d235fd93b5e442ec7a7a88f48 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 10:26:49 +0100 Subject: Optimize pinned item verbs based activity processing --- Zotlabs/Widget/Pinned.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index e2dc49018..f200e1378 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -55,12 +55,12 @@ class Pinned { $attend = null; $canvote = false; - $response_verbs = []; + $conv_responses = []; if($item['obj_type'] === ACTIVITY_OBJ_EVENT) { - $response_verbs[] = 'attendyes'; - $response_verbs[] = 'attendno'; - $response_verbs[] = 'attendmaybe'; + $conv_responses['attendyes'] = [ 'title' => t('Attending','title') ]; + $conv_responses['attendno'] = [ 'title' => t('Not attending','title') ]; + $conv_responses['attendmaybe'] = [ 'title' => t('Might attend','title') ]; if($commentable && $observer) { $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); $isevent = true; @@ -69,24 +69,15 @@ class Pinned { $consensus = (intval($item['item_consensus']) ? true : false); if($consensus) { - $response_verbs[] = 'agree'; - $response_verbs[] = 'disagree'; - $response_verbs[] = 'abstain'; + $conv_responses['agree'] = [ 'title' => t('Agree','title') ]; + $conv_responses['disagree'] = [ 'title' => t('Disagree','title') ]; + $conv_responses['abstain'] = [ 'title' => t('Abstain','title') ]; if($commentable && $observer) { $conlabels = array( t('I agree'), t('I disagree'), t('I abstain')); $canvote = true; } } - $conv_responses = [ - 'agree' => [ 'title' => t('Agree','title') ], - 'disagree' => [ 'title' => t('Disagree','title') ], - 'abstain' => [ 'title' => t('Abstain','title') ], - 'attendyes' => [ 'title' => t('Attending','title') ], - 'attendno' => [ 'title' => t('Not attending','title') ], - 'attendmaybe' => [ 'title' => t('Might attend','title') ] - ]; - $this->activity($item, $conv_responses); $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); -- cgit v1.2.3 From 28a316f73f1997d72f497523d7521c6bd9736d90 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 10:33:46 +0100 Subject: Normalize SQL query --- Zotlabs/Widget/Pinned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index f200e1378..bed7c4a43 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -243,7 +243,7 @@ class Pinned { break; } - $r = q("SELECT * FROM item WHERE parent = %d AND id <> parent AND verb IN ( '%s' ) AND item_deleted = 0", + $r = q("SELECT * FROM item WHERE parent = %d AND id <> parent AND verb = '%s' AND item_deleted = 0", intval($item['id']), dbesc($v) ); -- cgit v1.2.3 From 0d7548a38135c6298608785109f171243ca8a48a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 16:55:32 +0100 Subject: Add hiding pinned content --- Zotlabs/Module/Pin.php | 52 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pin.php b/Zotlabs/Module/Pin.php index 65bb61a76..74297aa7c 100644 --- a/Zotlabs/Module/Pin.php +++ b/Zotlabs/Module/Pin.php @@ -12,11 +12,8 @@ class Pin extends \Zotlabs\Web\Controller { function init() { - if(argc() !== 1) + if(argc() !== 2) http_status_exit(400, 'Bad request'); - - if(! local_channel()) - http_status_exit(403, 'Forbidden'); } @@ -27,24 +24,45 @@ class Pin extends \Zotlabs\Web\Controller { if ($item_id <= 0) http_status_exit(404, 'Not found'); - $channel = \App::get_channel(); + $observer = \App::get_observer(); + if(! $observer) + http_status_exit(403, 'Forbidden'); - $r = q("SELECT * FROM item WHERE id = %d AND id = parent AND uid = %d AND owner_xchan = '%s' AND item_private = 0 LIMIT 1", - $item_id, - intval($channel['channel_id']), - dbesc($channel['xchan_hash']) + $r = q("SELECT * FROM item WHERE id = %d AND id = parent AND item_private = 0 LIMIT 1", + $item_id ); - if(!$r) { + if(! $r) { notice(t('Unable to locate original post.')); http_status_exit(404, 'Not found'); } - else { - // Currently allow only one pinned item for each type - $midb64 = 'b64.' . base64url_encode($r[0]['mid']); - $pinned = (in_array($midb64, get_pconfig($channel['channel_id'], 'pinned', $r[0]['item_type'], [])) ? [] : [ $midb64 ]); - set_pconfig($channel['channel_id'], 'pinned', $r[0]['item_type'], $pinned); - - build_sync_packet($channel['channel_id'], [ 'config' ]); + + $midb64 = 'b64.' . base64url_encode($r[0]['mid']); + $pinned = (in_array($midb64, get_pconfig($r[0]['uid'], 'pinned', $r[0]['item_type'], [])) ? true : false); + + switch(argv(1)) { + + case 'pin': + if(! local_channel() || local_channel() != $r[0]['uid']) + http_status_exit(403, 'Forbidden'); + // Currently allow only one pinned item for each type + set_pconfig($r[0]['uid'], 'pinned', $r[0]['item_type'], ($pinned ? [] : [ $midb64 ])); + if($pinned) + del_pconfig($r[0]['uid'], 'pinned_hide', $midb64); + break; + + case 'hide': + if($pinned) { + $hidden = get_pconfig($r[0]['uid'], 'pinned_hide', $midb64, []); + if(! in_array($observer['xchan_hash'], $hidden)) { + $hidden[] = $observer['xchan_hash']; + set_pconfig($r[0]['uid'], 'pinned_hide', $midb64, $hidden); + } + } + + default: + http_status_exit(404, 'Not found'); } + + build_sync_packet($r[0]['uid'], [ 'config' ]); } } -- cgit v1.2.3 From 74aa446190c1049eeb3a77cb6f59819fc20b05fb Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 16:56:24 +0100 Subject: Add hiding pinned content --- Zotlabs/Widget/Pinned.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index bed7c4a43..271541812 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -41,6 +41,11 @@ class Pinned { foreach($items as $item) { + $midb64 = 'b64.' . base64url_encode($item['mid']); + + if(in_array($observer['xchan_hash'], get_pconfig($item['uid'], 'pinned_hide', $midb64, []))) + continue; + $author = channelx_by_hash($item['author_xchan']); $owner = channelx_by_hash($item['owner_xchan']); @@ -58,9 +63,9 @@ class Pinned { $conv_responses = []; if($item['obj_type'] === ACTIVITY_OBJ_EVENT) { - $conv_responses['attendyes'] = [ 'title' => t('Attending','title') ]; - $conv_responses['attendno'] = [ 'title' => t('Not attending','title') ]; - $conv_responses['attendmaybe'] = [ 'title' => t('Might attend','title') ]; + $conv_responses['attendyes'] = [ 'title' => t('Attending','title') ]; + $conv_responses['attendno'] = [ 'title' => t('Not attending','title') ]; + $conv_responses['attendmaybe'] = [ 'title' => t('Might attend','title') ]; if($commentable && $observer) { $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); $isevent = true; @@ -69,9 +74,9 @@ class Pinned { $consensus = (intval($item['item_consensus']) ? true : false); if($consensus) { - $conv_responses['agree'] = [ 'title' => t('Agree','title') ]; - $conv_responses['disagree'] = [ 'title' => t('Disagree','title') ]; - $conv_responses['abstain'] = [ 'title' => t('Abstain','title') ]; + $conv_responses['agree'] = [ 'title' => t('Agree','title') ]; + $conv_responses['disagree'] = [ 'title' => t('Disagree','title') ]; + $conv_responses['abstain'] = [ 'title' => t('Abstain','title') ]; if($commentable && $observer) { $conlabels = array( t('I agree'), t('I disagree'), t('I abstain')); $canvote = true; @@ -109,7 +114,7 @@ class Pinned { 'folders' => $body['folders'], 'text' => strip_tags($body['html']), 'id' => $item['id'], - 'mids' => json_encode([ 'b64.' . base64url_encode($item['mid']) ]), + 'mids' => json_encode([ $midb64 ]), 'isevent' => $isevent, 'attend' => $attend, 'consensus' => $consensus, @@ -135,12 +140,12 @@ class Pinned { 'forged' => $forged, 'location' => $location, 'divider' => get_pconfig($item['uid'],'system','item_divider'), - 'attend_title' => t('Attendance Options'), - 'vote_title' => t('Voting Options'), + 'attend_title' => t('Attendance Options'), + 'vote_title' => t('Voting Options'), 'is_new' => $is_new, 'owner_url' => ($owner['xchan_addr'] != $author['xchan_addr'] ? chanlink_hash($owner['xchan_hash']) : ''), - 'owner_photo' => $owner['xchan_photo_m'], - 'owner_name' => $owner['xchan_name'], + 'owner_photo'=> $owner['xchan_photo_m'], + 'owner_name' => $owner['xchan_name'], 'photo' => $body['photo'], 'event' => $body['event'], 'has_tags' => (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false), @@ -149,6 +154,7 @@ class Pinned { 'embed' => $embed, 'plink' => get_plink($item), 'pinned' => t('Pinned post'), + 'hide' => (! $is_new && ($observer['xchan_hash'] != $owner['xchan_hash']) ? t("Don't show") : ''), // end toolbar buttons 'modal_dismiss' => t('Close'), 'responses' => $conv_responses -- cgit v1.2.3 From 135b3cf1ef077051f78a26520ab143407f5d4577 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 17:17:06 +0100 Subject: Fix hide pinned post button for unauthenticated viewer --- Zotlabs/Widget/Pinned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 271541812..7fbda0d5f 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -154,7 +154,7 @@ class Pinned { 'embed' => $embed, 'plink' => get_plink($item), 'pinned' => t('Pinned post'), - 'hide' => (! $is_new && ($observer['xchan_hash'] != $owner['xchan_hash']) ? t("Don't show") : ''), + 'hide' => (! $is_new && $observer && ($observer['xchan_hash'] != $owner['xchan_hash']) ? t("Don't show") : ''), // end toolbar buttons 'modal_dismiss' => t('Close'), 'responses' => $conv_responses -- cgit v1.2.3 From 80e03268fd8086eca65f79ac3674fd3e2e23cdf6 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 3 Dec 2019 23:35:19 +0100 Subject: Fix show share menu option for pinned post --- Zotlabs/Widget/Pinned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 7fbda0d5f..0ef724102 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -88,7 +88,7 @@ class Pinned { $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); $forged = ((! intval($item['item_verified']) && $item['sig']) ? t('Message signature incorrect') : ''); - $shareable = ((local_channel() && $item['item_private'] != 1) ? true : false); + $shareable = ((local_channel() && \App::$profile_uid == local_channel() && $item['item_private'] != 1) ? true : false); if ($shareable) { // This actually turns out not to be possible in some protocol stacks without opening up hundreds of new issues. // Will allow it only for uri resolvable sources. -- cgit v1.2.3 From b894380f86d84599a1c0bfec0e32125e6cc3e20e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 4 Dec 2019 09:49:05 +0100 Subject: Add unpin button for pinned item --- Zotlabs/Widget/Pinned.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 0ef724102..ec2c7f4e8 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -154,6 +154,7 @@ class Pinned { 'embed' => $embed, 'plink' => get_plink($item), 'pinned' => t('Pinned post'), + 'pinme' => t('Unpin from the top'), 'hide' => (! $is_new && $observer && ($observer['xchan_hash'] != $owner['xchan_hash']) ? t("Don't show") : ''), // end toolbar buttons 'modal_dismiss' => t('Close'), -- cgit v1.2.3 From a6516341c50fb54b0d40b12fe76230f07e499fb2 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 4 Dec 2019 15:35:46 +0100 Subject: Show unpin button for pinned post for owner only --- Zotlabs/Widget/Pinned.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index ec2c7f4e8..3324206f4 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -154,7 +154,7 @@ class Pinned { 'embed' => $embed, 'plink' => get_plink($item), 'pinned' => t('Pinned post'), - 'pinme' => t('Unpin from the top'), + 'pinme' => (($observer['xchan_hash'] == $owner['xchan_hash']) ? t('Unpin from the top') : ''), 'hide' => (! $is_new && $observer && ($observer['xchan_hash'] != $owner['xchan_hash']) ? t("Don't show") : ''), // end toolbar buttons 'modal_dismiss' => t('Close'), -- cgit v1.2.3 From 475a39ff90345fabd21d36070c083812d3832562 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 4 Dec 2019 20:57:35 +0100 Subject: Add missed break --- Zotlabs/Module/Pin.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pin.php b/Zotlabs/Module/Pin.php index 74297aa7c..352a056ed 100644 --- a/Zotlabs/Module/Pin.php +++ b/Zotlabs/Module/Pin.php @@ -58,6 +58,7 @@ class Pin extends \Zotlabs\Web\Controller { set_pconfig($r[0]['uid'], 'pinned_hide', $midb64, $hidden); } } + break; default: http_status_exit(404, 'Not found'); -- cgit v1.2.3 From cde706748a3bdda1af77251febadb5610a55d6e7 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 5 Dec 2019 12:37:54 +0100 Subject: Unpin pinned item on site admin deletion --- Zotlabs/Module/Pin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pin.php b/Zotlabs/Module/Pin.php index 352a056ed..63b28754b 100644 --- a/Zotlabs/Module/Pin.php +++ b/Zotlabs/Module/Pin.php @@ -42,7 +42,7 @@ class Pin extends \Zotlabs\Web\Controller { switch(argv(1)) { case 'pin': - if(! local_channel() || local_channel() != $r[0]['uid']) + if(! local_channel() || (local_channel() != $r[0]['uid'] && local_channel() != is_site_admin())) http_status_exit(403, 'Forbidden'); // Currently allow only one pinned item for each type set_pconfig($r[0]['uid'], 'pinned', $r[0]['item_type'], ($pinned ? [] : [ $midb64 ])); -- cgit v1.2.3 From 161ea6d51fea95be8071bea8e8f0999a25241801 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 7 Dec 2019 13:05:07 +0000 Subject: sse: initial commit to deal with forum notifications --- Zotlabs/Module/Sse_bs.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 5e00593ef..4340876ea 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -77,10 +77,6 @@ class Sse_bs extends Controller { default: } - set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); - set_xconfig(self::$ob_hash, 'sse', 'notifications', []); // reset the cache - set_xconfig(self::$ob_hash, 'sse', 'language', App::$language); - if(self::$offset && $f) { $result = self::$f(true); json_return_and_die($result); @@ -99,6 +95,10 @@ class Sse_bs extends Controller { self::bs_register() ); + set_xconfig(self::$ob_hash, 'sse', 'timestamp', datetime_convert()); + set_xconfig(self::$ob_hash, 'sse', 'notifications', []); // reset the cache + set_xconfig(self::$ob_hash, 'sse', 'language', App::$language); + json_return_and_die($result); } @@ -390,22 +390,29 @@ class Sse_bs extends Controller { $p_str = ids_to_querystr($p, 'parent'); $p_sql = (($p_str) ? "OR parent IN ( $p_str )" : ''); - $r = q("select count(id) as unseen from item + $r = q("select mid from item where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $sql_extra $item_normal", intval(self::$uid), dbesc($forums[$x]['xchan_hash']), dbesc($forums[$x]['xchan_hash']) ); - if($r[0]['unseen']) { + if($r) { + $mids = flatten_array_recursive($r); + + + foreach($mids as $mid) + $b64mids[] = 'b64.' . base64url_encode($mid); + $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']); $forums[$x]['name'] = $forums[$x]['xchan_name']; $forums[$x]['addr'] = $forums[$x]['xchan_addr']; $forums[$x]['url'] = $forums[$x]['xchan_url']; $forums[$x]['photo'] = $forums[$x]['xchan_photo_s']; - $forums[$x]['unseen'] = $r[0]['unseen']; + $forums[$x]['unseen'] = count($b64mids); $forums[$x]['private_forum'] = (($forums[$x]['private_forum']) ? 'lock' : ''); $forums[$x]['message'] = (($forums[$x]['private_forum']) ? t('Private forum') : t('Public forum')); + $forums[$x]['mids'] = json_encode($b64mids); unset($forums[$x]['abook_id']); unset($forums[$x]['xchan_hash']); @@ -413,7 +420,7 @@ class Sse_bs extends Controller { unset($forums[$x]['xchan_url']); unset($forums[$x]['xchan_photo_s']); - $i = $i + $r[0]['unseen']; + $i = $i + count($mids); } else { -- cgit v1.2.3 From aed682305173a67b2af1a56b8595445bec690e2b Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 7 Dec 2019 20:14:17 +0100 Subject: Add .webp image format support --- Zotlabs/Module/Embedphotos.php | 2 ++ Zotlabs/Module/Help.php | 5 ++++- Zotlabs/Photo/PhotoGd.php | 18 ++++++++++++++++-- Zotlabs/Photo/PhotoImagick.php | 30 +++++++++++++++++++----------- Zotlabs/Storage/File.php | 2 +- 5 files changed, 42 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php index 6a88513dc..9b0884197 100644 --- a/Zotlabs/Module/Embedphotos.php +++ b/Zotlabs/Module/Embedphotos.php @@ -68,6 +68,8 @@ class Embedphotos extends \Zotlabs\Web\Controller { $ext = '.png'; elseif($r[0]['mimetype'] === 'image/gif') $ext = '.gif'; + elseif($r[0]['mimetype'] === 'image/webp') + $exp = '.webp'; else $ext = EMPTY_STR; diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php index f1b1acaef..ce05035b3 100644 --- a/Zotlabs/Module/Help.php +++ b/Zotlabs/Module/Help.php @@ -66,7 +66,10 @@ class Help extends \Zotlabs\Web\Controller { case IMAGETYPE_PNG: header("Content-Type: image/png"); break; - default: + case IMAGETYPE_WEBP: + header("Content-Type: image/webp"); + break; + default: break; } header("Content-Length: " . filesize($realpath)); diff --git a/Zotlabs/Photo/PhotoGd.php b/Zotlabs/Photo/PhotoGd.php index 4054e1866..c54fa6a7d 100644 --- a/Zotlabs/Photo/PhotoGd.php +++ b/Zotlabs/Photo/PhotoGd.php @@ -13,12 +13,16 @@ class PhotoGd extends PhotoDriver { * @see \Zotlabs\Photo\PhotoDriver::supportedTypes() */ public function supportedTypes() { + $t = []; + $t['image/jpeg'] = 'jpg'; if(imagetypes() & IMG_PNG) $t['image/png'] = 'png'; if(imagetypes() & IMG_GIF) $t['image/gif'] = 'gif'; + if(imagetypes() & IMG_WEBP) + $t['image/webp'] = 'webp'; return $t; } @@ -142,6 +146,7 @@ class PhotoGd extends PhotoDriver { * @see \Zotlabs\Photo\PhotoDriver::imageString() */ public function imageString() { + if(! $this->is_valid()) return false; @@ -150,23 +155,32 @@ class PhotoGd extends PhotoDriver { ob_start(); switch($this->getType()){ + case 'image/png': $quality = get_config('system', 'png_quality'); if((! $quality) || ($quality > 9)) $quality = PNG_QUALITY; - \imagepng($this->image, NULL, $quality); break; + + case 'image/webp': + $quality = get_config('system', 'webp_quality'); + if((! $quality) || ($quality > 100)) + $quality = WEBP_QUALITY; + \imagewebp($this->image, NULL, $quality); + break; + case 'image/jpeg': // gd can lack imagejpeg(), but we verify during installation it is available + default: $quality = get_config('system', 'jpeg_quality'); if((! $quality) || ($quality > 100)) $quality = JPEG_QUALITY; - \imagejpeg($this->image, NULL, $quality); break; } + $string = ob_get_contents(); ob_end_clean(); diff --git a/Zotlabs/Photo/PhotoImagick.php b/Zotlabs/Photo/PhotoImagick.php index a7026e8ca..0a08d19e6 100644 --- a/Zotlabs/Photo/PhotoImagick.php +++ b/Zotlabs/Photo/PhotoImagick.php @@ -8,19 +8,16 @@ namespace Zotlabs\Photo; class PhotoImagick extends PhotoDriver { public function supportedTypes() { - return [ + + $ret = [ 'image/jpeg' => 'jpg', 'image/png' => 'png', - 'image/gif' => 'gif', + 'image/gif' => 'gif' ]; - } + if(\Imagick::queryFormats("WEBP")) + $ret['image/webp'] = 'webp'; - private function get_FormatsMap() { - return [ - 'image/jpeg' => 'JPG', - 'image/png' => 'PNG', - 'image/gif' => 'GIF', - ]; + return $ret; } @@ -42,8 +39,8 @@ class PhotoImagick extends PhotoDriver { * Setup the image to the format it will be saved to */ - $map = $this->get_FormatsMap(); - $format = $map[$type]; + $map = $this->supportedTypes(); + $format = strtoupper($map[$type]); if($this->image) { $this->image->setFormat($format); @@ -58,6 +55,7 @@ class PhotoImagick extends PhotoDriver { * setup the compression here, so we'll do it only once */ switch($this->getType()) { + case 'image/png': $quality = get_config('system', 'png_quality'); if((! $quality) || ($quality > 9)) @@ -73,11 +71,21 @@ class PhotoImagick extends PhotoDriver { $quality = $quality * 10; $this->image->setCompressionQuality($quality); break; + case 'image/jpeg': $quality = get_config('system', 'jpeg_quality'); if((! $quality) || ($quality > 100)) $quality = JPEG_QUALITY; $this->image->setCompressionQuality($quality); + break; + + case 'image/webp': + $quality = get_config('system', 'webp_quality'); + if((! $quality) || ($quality > 100)) + $quality = WEBP_QUALITY; + $this->image->setCompressionQuality($quality); + break; + default: break; } diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 4610aceb7..36aff1e05 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -169,7 +169,7 @@ class File extends DAV\Node implements DAV\IFile { } $gis = @getimagesize($f); logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA); - if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) { + if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG || $gis[2] === IMAGETYPE_WEBP)) { $is_photo = 1; } -- cgit v1.2.3 From e1400e5745d154b365aeab11b971a6c7d201f3a9 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 8 Dec 2019 00:18:51 +0100 Subject: Don't show pinned post on single post displaying --- Zotlabs/Module/Channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 20a5418c2..5529db70e 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -470,7 +470,7 @@ class Channel extends Controller { } // Add pinned content - if(! $decoded && ! $search) { + if(! x($_REQUEST,'mid') && ! $search) { $pinned = new \Zotlabs\Widget\Pinned; $r = $pinned->widget(intval(App::$profile['profile_uid']), [ITEM_TYPE_POST]); $o .= $r['html']; -- cgit v1.2.3 From c4f4edd743b79ec3f3bebecf786cbb6da8921ce9 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 9 Dec 2019 10:44:44 +0000 Subject: directory: port censoring from zap and disable oembed in profile about --- Zotlabs/Module/Dircensor.php | 52 ++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Directory.php | 43 +++++++++++++++++++++++------------ Zotlabs/Module/Dirsearch.php | 54 ++++++++++++++++++++++++-------------------- 3 files changed, 110 insertions(+), 39 deletions(-) create mode 100644 Zotlabs/Module/Dircensor.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php new file mode 100644 index 000000000..0fa65e948 --- /dev/null +++ b/Zotlabs/Module/Dircensor.php @@ -0,0 +1,52 @@ + false])) : False); + if ($about && $safe_mode) { + $about = html2plain($about); + } + $keywords = ((x($profile,'keywords')) ? $profile['keywords'] : ''); @@ -343,9 +356,11 @@ class Directory extends \Zotlabs\Web\Controller { 'canrate' => (($rating_enabled && local_channel()) ? true : false), 'pdesc' => $pdesc, 'pdesc_label' => t('Description:'), + 'censor' => (($directory_admin) ? 'dircensor/' . $rr['hash'] : ''), + 'censor_label' => (($rr['censored']) ? t('Uncensor') : t('Censor')), 'marital' => $marital, 'homepage' => $homepage, - 'homepageurl' => linkify($homepageurl, true), + 'homepageurl' => (($safe_mode) ? $homepageurl : linkify($homepageurl)), 'hometown' => $hometown, 'hometown_label' => t('Hometown:'), 'about' => $about, @@ -387,7 +402,7 @@ class Directory extends \Zotlabs\Web\Controller { ksort($entries); // Sort array by key so that foreach-constructs work as expected if($j['keywords']) { - \App::$data['directory_keywords'] = $j['keywords']; + App::$data['directory_keywords'] = $j['keywords']; } logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA); @@ -438,7 +453,7 @@ class Directory extends \Zotlabs\Web\Controller { echo $o; killme(); } - if(\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) { + if(App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) { goaway(z_root() . '/chanview/?f=&address=' . $search); } info( t("No entries (some entries may be hidden).") . EOL); diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php index 92b33df0c..62af75f4c 100644 --- a/Zotlabs/Module/Dirsearch.php +++ b/Zotlabs/Module/Dirsearch.php @@ -1,14 +1,17 @@ Date: Mon, 9 Dec 2019 19:43:01 -0800 Subject: missing translation "%d unseen" --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 301ce1a18..caceac7ef 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -346,7 +346,7 @@ class ThreadItem { $viewthread = z_root() . '/channel/' . $owner_address . '?f=&mid=' . urlencode(gen_link_id($item['mid'])); $comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children ); - $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : ''); + $list_unseen_txt = (($unseen_comments) ? sprintf( t('%d unseen'),$unseen_comments) : ''); $children = $this->get_children(); -- cgit v1.2.3 From d71dd21abc49b7a5f912b0842eb5a14a4cc3d172 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 16 Dec 2019 10:23:33 +0100 Subject: Fix possibly unknown author --- Zotlabs/Widget/Pinned.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 3324206f4..0a7806908 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -267,8 +267,8 @@ class Pinned { $author = q("SELECT * FROM xchan WHERE xchan_hash = '%s' LIMIT 1", dbesc($rr['author_xchan']) ); - $name = ($author[0]['xchan_name'] ? $author[0]['xchan_name'] : t('Unknown')); - $conv_responses[$verb]['list'][] = (($rr['author_xchan'] && $author[0]['xchan_photo_s']) ? + $name = (($author && $author[0]['xchan_name']) ? $author[0]['xchan_name'] : t('Unknown')); + $conv_responses[$verb]['list'][] = (($rr['author_xchan'] && $author && $author[0]['xchan_photo_s']) ? '' . '' . urlencode($name) . ' ' . $name . '' : '' . $name . '' ); -- cgit v1.2.3 From ff63132a32ed7bcfe52e51847dbd7efec64a3f43 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 28 Dec 2019 14:37:52 +0000 Subject: pubstream: use search mode for tag filter view and add a title --- Zotlabs/Module/Pubstream.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 84ac42f72..282c10989 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -62,6 +62,11 @@ class Pubstream extends \Zotlabs\Web\Controller { $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); $net = ((array_key_exists('net',$_REQUEST)) ? escape_tags($_REQUEST['net']) : ''); + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => (($hashtags) ? '#' . htmlspecialchars($hashtags, ENT_COMPAT,'UTF-8') : '') + )); + + $o = (($hashtags) ? $title : ''); if(local_channel() && (! $update)) { @@ -94,7 +99,7 @@ class Pubstream extends \Zotlabs\Web\Controller { 'reset' => t('Reset form') ); - $o = '
'; + $o .= '
'; $o .= status_editor($a,$x,false,'Pubstream'); $o .= '
'; } @@ -285,7 +290,7 @@ class Pubstream extends \Zotlabs\Web\Controller { } // fake it - $mode = ('pubstream'); + $mode = (($hashtags) ? 'search' : 'pubstream'); $o .= conversation($items,$mode,$update,$page_mode); -- cgit v1.2.3 From 41ce2da080d72dbfd2c47a3973fe3c43672adb4d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 5 Jan 2020 11:49:36 +0100 Subject: Add age choice on cached item retrieve --- Zotlabs/Lib/Cache.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php index 878201a42..bb7bbbff0 100644 --- a/Zotlabs/Lib/Cache.php +++ b/Zotlabs/Lib/Cache.php @@ -7,14 +7,23 @@ namespace Zotlabs\Lib; */ class Cache { - public static function get($key) { + + /** + * @brief Returns cached content + * + * @param string $key + * @param string $age in SQL format, default is '30 DAY' + * @return string + * / + + public static function get($key, $age = '') { $hash = hash('whirlpool',$key); $r = q("SELECT v FROM cache WHERE k = '%s' AND updated > %s - INTERVAL %s LIMIT 1", dbesc($hash), db_utcnow(), - db_quoteinterval(get_config('system','object_cache_days', '30') . ' DAY') + db_quoteinterval(($age ? $age : get_config('system','object_cache_days', '30') . ' DAY')) ); if ($r) -- cgit v1.2.3 From 908875a052ac76e24af74fc714b350c217de42b4 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 6 Jan 2020 20:40:18 +0100 Subject: Update Cache.php --- Zotlabs/Lib/Cache.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php index bb7bbbff0..a5052a183 100644 --- a/Zotlabs/Lib/Cache.php +++ b/Zotlabs/Lib/Cache.php @@ -14,7 +14,7 @@ class Cache { * @param string $key * @param string $age in SQL format, default is '30 DAY' * @return string - * / + */ public static function get($key, $age = '') { @@ -52,4 +52,3 @@ class Cache { } } } - -- cgit v1.2.3 From d3cbbe029c1f19a77ac0c278f735d81b9dd3a3ec Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Jan 2020 22:41:28 -0800 Subject: rework activitystreams events - send invite/event activities instead of create/event. Also a first pass at creating a Zap export file from Hubzilla. Much more work is needed before this is functional. --- Zotlabs/Lib/Activity.php | 35 +++++++++++++++++++++++------------ Zotlabs/Lib/ActivityStreams.php | 6 ++++++ 2 files changed, 29 insertions(+), 12 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 08a8b8d03..a0956c501 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -611,10 +611,10 @@ class Activity { if($i['id'] != $i['parent']) { $reply = true; - // inReplyTo needs to be set in the activity for followup actiions (Like, Dislike, Attend, Announce, etc.), - // but *not* for comments, where it should only be present in the object - - if (! in_array($ret['type'],[ 'Create','Update' ])) { + // inReplyTo needs to be set in the activity for followup actions (Like, Dislike, Announce, etc.), + // but *not* for comments and RSVPs, where it should only be present in the object + + if (! in_array($ret['type'],[ 'Create','Update','Accept','Reject','TentativeAccept','TentativeReject' ])) { $ret['inReplyTo'] = ((strpos($i['thr_parent'],'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent'])); } @@ -672,6 +672,9 @@ class Activity { return []; } + if(array_path_exists('object/type',$ret) && $ret['object']['type'] === 'Event' && $ret['type'] === 'Create') { + $ret['type'] = 'Invite'; + } if($i['target']) { if(! is_array($i['target'])) { @@ -1664,15 +1667,23 @@ class Activity { if($act->type === 'Dislike') { $content['content'] = sprintf( t('Doesn\'t like %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; } - if($act->type === 'Accept' && $act->obj['type'] === 'Event' ) { - $content['content'] = sprintf( t('Will attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; - } - if($act->type === 'Reject' && $act->obj['type'] === 'Event' ) { - $content['content'] = sprintf( t('Will not attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; - } - if($act->type === 'TentativeAccept' && $act->obj['type'] === 'Event' ) { - $content['content'] = sprintf( t('May attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content']; + + // handle event RSVPs + if (($act->obj['type'] === 'Event') || ($act->obj['type'] === 'Invite' && array_path_exists('object/type',$act->obj) && $act->obj['object']['type'] === 'Event')) { + if ($act->type === 'Accept') { + $content['content'] = sprintf( t('Will attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } + if ($act->type === 'Reject') { + $content['content'] = sprintf( t('Will not attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } + if ($act->type === 'TentativeAccept') { + $content['content'] = sprintf( t('May attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } + if ($act->type === 'TentativeReject') { + $content['content'] = sprintf( t('May not attend %s\'s event'),$mention) . EOL . EOL . $content['content']; + } } + if($act->type === 'Announce') { $content['content'] = sprintf( t('🔁 Repeated %1$s\'s %2$s'), $mention, $act->obj['type']); } diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 006744aff..d8bd72943 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -101,7 +101,13 @@ class ActivityStreams { $this->actor = $this->get_actor('attributedTo',$this->obj); } } + + // fetch recursive or embedded activities + if ($this->obj && is_array($this->obj) && array_key_exists('object',$this->obj)) { + $this->obj['object'] = $this->get_compound_property($this->obj['object']); + } + if($this->obj && is_array($this->obj) && $this->obj['actor']) $this->obj['actor'] = $this->get_actor('actor',$this->obj); if($this->tgt && is_array($this->tgt) && $this->tgt['actor']) -- cgit v1.2.3 From 2a287e6def5ab54037222c963ab0875faf62fc1a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Jan 2020 13:29:45 -0800 Subject: event compatibility work --- Zotlabs/Lib/Activity.php | 45 +++++++++--- Zotlabs/Module/Activity.php | 175 ++++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Event.php | 76 +++++++++++++++++++ Zotlabs/Module/Item.php | 2 - Zotlabs/Module/Like.php | 9 ++- 5 files changed, 291 insertions(+), 16 deletions(-) create mode 100644 Zotlabs/Module/Activity.php create mode 100644 Zotlabs/Module/Event.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index a0956c501..a99bb36e4 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -168,6 +168,10 @@ class Activity { if($r) { xchan_query($r,true); $r = fetch_post_tags($r,true); + if ($r[0]['verb'] === 'Create' && $r[0]['obj_type'] === ACTIVITY_OBJ_EVENT) { + $r[0]['verb'] = 'Invite'; + return self::encode_activity($r[0]); + } return self::encode_item($r[0]); } } @@ -220,7 +224,7 @@ class Activity { 'startTime' => (($ev['adjust']) ? datetime_convert($ev['timezone'],'UTC',$ev['dtstart'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtstart'],'Y-m-d\\TH:i:s-00:00')), 'content' => bbcode($ev['description'], [ 'cache' => true ]), 'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location'], [ 'cache' => true ]) ], - 'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ], + 'source' => [ 'content' => format_event_bbcode($ev,true), 'mediaType' => 'text/bbcode' ], 'actor' => $actor, ]; if(! $ev['nofinish']) { @@ -825,7 +829,8 @@ class Activity { 'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow', 'http://purl.org/zot/activity/attendyes' => 'Accept', 'http://purl.org/zot/activity/attendno' => 'Reject', - 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept' + 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept', + 'Invite' => 'Invite', ]; call_hooks('activity_mapper',$acts); @@ -871,7 +876,8 @@ class Activity { 'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow', 'http://purl.org/zot/activity/attendyes' => 'Accept', 'http://purl.org/zot/activity/attendno' => 'Reject', - 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept' + 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept', + 'Invite' => 'Invite', ]; call_hooks('activity_decode_mapper',$acts); @@ -905,6 +911,7 @@ class Activity { 'http://purl.org/zot/activity/thing' => 'Object', 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', + 'Invite' => 'Invite', ]; @@ -944,7 +951,7 @@ class Activity { 'http://purl.org/zot/activity/thing' => 'Object', 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', - + 'Invite' => 'Invite', ]; call_hooks('activity_obj_mapper',$objs); @@ -1714,28 +1721,42 @@ class Activity { $s['obj_type'] = ACTIVITY_OBJ_COMMENT; } + $eventptr = null; + + if ($act->obj['type'] === 'Invite' && array_path_exists('object/type',$act->obj) && $act->obj['object']['type'] === 'Event') { + $eventptr = $act->obj['object']; + $s['mid'] = $s['parent_mid'] = $act->obj['id']; + } + if($act->obj['type'] === 'Event') { + if ($act->type === 'Invite') { + $s['mid'] = $s['parent_mid'] = $act->id; + } + $eventptr = $act->obj; + } + + if ($eventptr) { $s['obj'] = []; - $s['obj']['asld'] = $act->obj; + $s['obj']['asld'] = $eventptr; $s['obj']['type'] = ACTIVITY_OBJ_EVENT; - $s['obj']['id'] = $act->obj['id']; - $s['obj']['title'] = $act->obj['name']; + $s['obj']['id'] = $eventptr['id']; + $s['obj']['title'] = $eventptr['name']; if(strpos($act->obj['startTime'],'Z')) $s['obj']['adjust'] = true; else $s['obj']['adjust'] = false; - $s['obj']['dtstart'] = datetime_convert('UTC','UTC',$act->obj['startTime']); + $s['obj']['dtstart'] = datetime_convert('UTC','UTC',$eventptr['startTime']); if($act->obj['endTime']) - $s['obj']['dtend'] = datetime_convert('UTC','UTC',$act->obj['endTime']); + $s['obj']['dtend'] = datetime_convert('UTC','UTC',$eventptr['endTime']); else $s['obj']['nofinish'] = true; - $s['obj']['description'] = $act->obj['content']; + $s['obj']['description'] = $eventptr['content']; - if(array_path_exists('location/content',$act->obj)) - $s['obj']['location'] = $act->obj['location']['content']; + if(array_path_exists('location/content',$eventptr)) + $s['obj']['location'] = $eventptr['location']['content']; } else { diff --git a/Zotlabs/Module/Activity.php b/Zotlabs/Module/Activity.php new file mode 100644 index 000000000..93b5a15fc --- /dev/null +++ b/Zotlabs/Module/Activity.php @@ -0,0 +1,175 @@ + [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + z_root() . ZOT_APSCHEMA_REV + ]], $i); + + $headers = []; + $headers['Content-Type'] = 'application/x-zot+json' ; + $x['signature'] = LDSignatures::sign($x,$chan); + $ret = json_encode($x, JSON_UNESCAPED_SLASHES); + $headers['Digest'] = HTTPSig::generate_digest_header($ret); + $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; + $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],channel_url($chan)); + HTTPSig::set_headers($h); + echo $ret; + killme(); + + } + + } + +} diff --git a/Zotlabs/Module/Event.php b/Zotlabs/Module/Event.php new file mode 100644 index 000000000..22a1341cc --- /dev/null +++ b/Zotlabs/Module/Event.php @@ -0,0 +1,76 @@ + [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + z_root() . ZOT_APSCHEMA_REV + ]], $obj ); + + $headers = []; + $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ; + $x['signature'] = LDSignatures::sign($x,$channel); + $ret = json_encode($x, JSON_UNESCAPED_SLASHES); + $headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T'); + $headers['Digest'] = HTTPSig::generate_digest_header($ret); + $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; + + $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel)); + HTTPSig::set_headers($h); + + echo $ret; + killme(); + + } + + } + +} \ No newline at end of file diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 14881844d..1a25e54df 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -42,8 +42,6 @@ class Item extends Controller { if (Libzot::is_zot_request()) { - $conversation = false; - $item_id = argv(1); if (! $item_id) diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 052d51d43..ff7554b7e 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -75,7 +75,12 @@ class Like extends \Zotlabs\Web\Controller { return EMPTY_STR; } - + $is_rsvp = false; + if (in_array($activity, [ ACTVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ])) { + $is_rsvp = true; + } + + $extended_like = false; $object = $target = null; $post_type = EMPTY_STR; @@ -381,7 +386,7 @@ class Like extends \Zotlabs\Web\Controller { $arr = array(); $arr['uuid'] = $uuid; - $arr['mid'] = z_root() . '/item/' . $uuid; + $arr['mid'] = z_root() . (($is_rsvp) ? '/activity/' : '/item/') . $uuid; if($extended_like) { $arr['item_thread_top'] = 1; -- cgit v1.2.3 From ccaa93655a6b44834d04c536d809c4b2c69c354b Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Jan 2020 09:48:10 +0000 Subject: fix typo --- Zotlabs/Module/Like.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index ff7554b7e..e4636a4a6 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -76,7 +76,7 @@ class Like extends \Zotlabs\Web\Controller { } $is_rsvp = false; - if (in_array($activity, [ ACTVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ])) { + if (in_array($activity, [ ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ])) { $is_rsvp = true; } -- cgit v1.2.3 From 2a0a06d74aa1e51b0e50459f90167ab35ba1411b Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Jan 2020 21:43:47 +0000 Subject: some work on zot6 DMs --- Zotlabs/Lib/Activity.php | 8 +++++++- Zotlabs/Lib/Libzot.php | 4 ++-- Zotlabs/Module/Channel.php | 1 + Zotlabs/Module/Display.php | 1 + Zotlabs/Module/Hq.php | 1 + Zotlabs/Module/Network.php | 6 ++++++ Zotlabs/Module/Pubstream.php | 1 + Zotlabs/Module/Search.php | 1 + Zotlabs/Widget/Activity_filter.php | 14 +++++++++++++- 9 files changed, 33 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index a99bb36e4..43315a87f 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1989,9 +1989,15 @@ class Activity { $s['plink'] = $s['mid']; } - if($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips))) + if ($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips))) $s['item_private'] = 1; + if (is_array($act->obj)) { + if (array_key_exists('directMessage',$act->obj) && intval($act->obj['directMessage'])) { + $s['item_private'] = 2; + } + } + set_iconfig($s,'activitypub','recips',$act->raw_recips); $parent = (($s['parent_mid'] && $s['parent_mid'] === $s['mid']) ? true : false); diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 100d45c05..ad00aa97a 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1220,8 +1220,8 @@ class Libzot { $arr['owner_xchan'] = $env['sender']; } - if($private) { - $arr['item_private'] = true; + if ($private && (! intval($arr['item_private']))) { + $arr['item_private'] = 1; } if ($arr['mid'] === $arr['parent_mid']) { diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 5529db70e..170b81787 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -419,6 +419,7 @@ class Channel extends Controller { '$nouveau' => '0', '$wall' => '1', '$fh' => '0', + '$dm' => '0', '$static' => $static, '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1), '$search' => $search, diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index cf38aba1a..777d183e1 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -224,6 +224,7 @@ class Display extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index d8c540fb9..5b331f4c1 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -179,6 +179,7 @@ class Hq extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 1c16e34ef..a8efd0d9e 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -69,6 +69,7 @@ class Network extends \Zotlabs\Web\Controller { $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); + $dm = ((x($_REQUEST,'dm')) ? $_REQUEST['dm'] : 0); $order = get_pconfig(local_channel(), 'mod_network', 'order', 0); @@ -363,6 +364,7 @@ class Network extends \Zotlabs\Web\Controller { '$conv' => (($conv) ? $conv : '0'), '$spam' => (($spam) ? $spam : '0'), '$fh' => '0', + '$dm' => (($dm) ? $dm : '0'), '$nouveau' => (($nouveau) ? $nouveau : '0'), '$wall' => '0', '$static' => $static, @@ -418,6 +420,10 @@ class Network extends \Zotlabs\Web\Controller { if(strlen($file)) { $sql_extra .= term_query('item',$file,TERM_FILE); } + + if ($dm) { + $sql_extra .= " AND item_private = 2 "; + } if($conv) { $item_thread_top = ''; diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 282c10989..92ef44696 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -144,6 +144,7 @@ class Pubstream extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '1', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$list' => '0', diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 214ece9a3..686afb2d2 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -128,6 +128,7 @@ class Search extends \Zotlabs\Web\Controller { '$conv' => '0', '$spam' => '0', '$fh' => '0', + '$dm' => '0', '$nouveau' => '0', '$wall' => '0', '$static' => $static, diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 32ab10c77..84b9ec24a 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -15,8 +15,20 @@ class Activity_filter { $filter_active = false; $tabs = []; +/* leave this commented out until ready for primetime + if(x($_GET,'dm')) { + $dm_active = (($_GET['dm'] == 1) ? 'active' : ''); + $filter_active = 'dm'; + } - + $tabs[] = [ + 'label' => t('Direct Messages'), + 'icon' => 'envelope-o', + 'url' => z_root() . '/' . $cmd . '/?f=&dm=1', + 'sel' => $dm_active, + 'title' => t('Show direct (private) messages') + ]; +*/ if(Apps::system_app_installed(local_channel(), 'Privacy Groups')) { $groups = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval(local_channel()) -- cgit v1.2.3 From bfae86bdb6d18f4238fe114485e24947ad7c7d75 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 13:17:37 +0000 Subject: more bdi tags --- Zotlabs/Lib/Enotify.php | 10 +++++----- Zotlabs/Lib/ThreadItem.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index bc2710ee1..8834eedca 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -803,18 +803,18 @@ class Enotify { localize_item($item); if($item['shortlocalize']) { - $itemem_text = $item['shortlocalize']; + $itemem_text = strip_tags($item['shortlocalize']); } elseif($item['localize']) { - $itemem_text = $item['localize']; + $itemem_text = strip_tags($item['localize']); } else { $itemem_text = (($item['item_thread_top']) ? t('created a new post') - : sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name'])); + : sprintf( t('commented on %s\'s post'), '' . strip_tags($item['owner']['xchan_name']) . '')); if($item['verb'] === ACTIVITY_SHARE) { - $itemem_text = sprintf( t('repeated %s\'s post'), $item['author']['xchan_name']); + $itemem_text = sprintf( t('repeated %s\'s post'), '' . strip_tags($item['author']['xchan_name']) . ''); } } @@ -849,7 +849,7 @@ class Enotify { //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), - 'message' => strip_tags(bbcode($itemem_text)), + 'message' => $itemem_text, // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index caceac7ef..ef7b4dbf2 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -377,7 +377,7 @@ class ThreadItem { 'template' => $this->get_template(), 'mode' => $mode, 'item_type' => intval($item['item_type']), - 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), + //'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'body' => $body['html'], 'tags' => $body['tags'], 'categories' => $body['categories'], @@ -414,7 +414,7 @@ class ThreadItem { 'sparkle' => $sparkle, 'title' => $item['title'], 'title_tosource' => get_pconfig($conv->get_profile_owner(),'system','title_tosource'), - 'ago' => relative_date($item['created']), + //'ago' => relative_date($item['created']), 'app' => $item['app'], 'str_app' => sprintf( t('from %s'), $item['app']), 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), -- cgit v1.2.3 From 7404a8ec1a0980fa3448ca6b05e410ea36c6a5f2 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 14:19:31 +0000 Subject: implement bdi tags via bbcode where possible --- Zotlabs/Lib/Enotify.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 8834eedca..db80e9edd 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -803,18 +803,18 @@ class Enotify { localize_item($item); if($item['shortlocalize']) { - $itemem_text = strip_tags($item['shortlocalize']); + $itemem_text = $item['shortlocalize']; } elseif($item['localize']) { - $itemem_text = strip_tags($item['localize']); + $itemem_text = $item['localize']; } else { $itemem_text = (($item['item_thread_top']) ? t('created a new post') - : sprintf( t('commented on %s\'s post'), '' . strip_tags($item['owner']['xchan_name']) . '')); + : sprintf( t('commented on %s\'s post'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]')); if($item['verb'] === ACTIVITY_SHARE) { - $itemem_text = sprintf( t('repeated %s\'s post'), '' . strip_tags($item['author']['xchan_name']) . ''); + $itemem_text = sprintf( t('repeated %s\'s post'), '[bdi]' . $item['author']['xchan_name'] . '[/bdi]'); } } @@ -849,7 +849,7 @@ class Enotify { //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), - 'message' => $itemem_text, + 'message' => bbcode(strip_tags($itemem_text)), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], -- cgit v1.2.3 From 9eeccc087dbba93d5d67c242666fe257cc35f3ee Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 14:23:23 +0000 Subject: move mail frontend to addons and remove mail app from system apps --- Zotlabs/Lib/Apps.php | 1 - Zotlabs/Module/Acl.php | 3 +- Zotlabs/Module/Mail.php | 449 ------------------------------------- Zotlabs/Widget/Activity_filter.php | 4 +- 4 files changed, 4 insertions(+), 453 deletions(-) delete mode 100644 Zotlabs/Module/Mail.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 69996b49d..9d60e9eae 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -74,7 +74,6 @@ class Apps { 'Directory', 'Search', 'Help', - 'Mail', 'Profile Photo' ]); diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index 82c156a9c..b4c1ab124 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -42,7 +42,7 @@ class Acl extends \Zotlabs\Web\Controller { // $type = - // 'm' => autocomplete private mail recipient (checks post_mail permission) + // 'm' => autocomplete private mail recipient (checks post_mail permission and displays only zot, diaspora, friendica-over-diaspora xchan_network xchan's) // 'a' => autocomplete connections (mod_connections, mod_poke, mod_sources, mod_photos) // 'x' => nav search bar autocomplete (match any xchan) // $_REQUEST['query'] contains autocomplete search text. @@ -286,6 +286,7 @@ class Acl extends \Zotlabs\Web\Controller { FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and xchan_deleted = 0 + and xchan_network IN ('zot', 'diapora', 'friendica-over-diaspora') $sql_extra3 ORDER BY xchan_name ASC ", intval(local_channel()) diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php deleted file mode 100644 index 636fc4e33..000000000 --- a/Zotlabs/Module/Mail.php +++ /dev/null @@ -1,449 +0,0 @@ - 'M0']); - echo json_encode(['preview' => $body]); - } - else { - $body = cleanup_bbcode($body); - $results = linkify_tags($body, local_channel()); - - if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { - $attachments = array(); - foreach($match[2] as $mtch) { - $hash = substr($mtch,0,strpos($mtch,',')); - $rev = intval(substr($mtch,strpos($mtch,','))); - $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); - if($r['success']) { - $attachments[] = array( - 'href' => z_root() . '/attach/' . $r['data']['hash'], - 'length' => $r['data']['filesize'], - 'type' => $r['data']['filetype'], - 'title' => urlencode($r['data']['filename']), - 'revision' => $r['data']['revision'] - ); - } - $body = trim(str_replace($match[1],'',$body)); - } - } - echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); - } - killme(); - } - - // If we have a raw string for a recipient which hasn't been auto-filled, - // it means they probably aren't in our address book, hence we don't know - // if we have permission to send them private messages. - // finger them and find out before we try and send it. - - if(! $recipient) { - $channel = \App::get_channel(); - - $j = \Zotlabs\Zot\Finger::run(punify($rstr),$channel); - - if(! $j['success']) { - notice( t('Unable to lookup recipient.') . EOL); - return; - } - - logger('message_post: lookup: ' . $rstr . ' ' . print_r($j,true)); - - if(! $j['guid']) { - notice( t('Unable to communicate with requested channel.')); - return; - } - - $x = import_xchan($j); - - if(! $x['success']) { - notice( t('Cannot verify requested channel.')); - return; - } - - $recipient = $x['hash']; - - $their_perms = 0; - - if($j['permissions']['data']) { - $permissions = crypto_unencapsulate($j['permissions'],$channel['channel_prvkey']); - if($permissions) - $permissions = json_decode($permissions, true); - logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA); - } - else - $permissions = $j['permissions']; - - if(! ($permissions['post_mail'])) { - notice( t('Selected channel has private message restrictions. Send failed.')); - // reported issue: let's still save the message and continue. We'll just tell them - // that nothing useful is likely to happen. They might have spent hours on it. - // return; - - } - } - - require_once('include/text.php'); - linkify_tags($body, local_channel()); - - - if(! $recipient) { - notice('No recipient found.'); - \App::$argc = 2; - \App::$argv[1] = 'new'; - return; - } - - // We have a local_channel, let send_message use the session channel and save a lookup - - $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw, $sig); - - if($ret['success']) { - xchan_mail_query($ret['mail']); - build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true)))); - } - else { - notice($ret['message']); - } - - goaway(z_root() . '/mail/combined'); - - } - - function get() { - - $o = ''; - nav_set_selected('Mail'); - - if(! local_channel()) { - notice( t('Permission denied.') . EOL); - return login(); - } - - $channel = \App::get_channel(); - - head_set_icon($channel['xchan_photo_s']); - - $cipher = get_pconfig(local_channel(),'system','default_cipher'); - if(! $cipher) - $cipher = 'aes256'; - - $tpl = get_markup_template('mail_head.tpl'); - $header = replace_macros($tpl, array( - '$header' => t('Messages'), - )); - - if(argc() == 3 && intval(argv(1)) && argv(2) === 'download') { - - $r = q("select * from mail where id = %d and channel_id = %d", - intval(argv(1)), - intval(local_channel()) - ); - - if($r) { - - header('Content-type: ' . $r[0]['mail_mimetype']); - header('Content-disposition: attachment; filename="' . t('message') . '-' . $r[0]['id'] . '"' ); - $body = (($r[0]['mail_obscured']) ? base64url_decode(str_rot47($r[0]['body'])) : $r[0]['body']); - echo $body; - killme(); - } - - } - - - if((argc() == 4) && (argv(2) === 'drop')) { - if(! intval(argv(3))) - return; - $cmd = argv(2); - $mailbox = argv(1); - $r = private_messages_drop(local_channel(), argv(3)); - if($r) { - //info( t('Message deleted.') . EOL ); - } - goaway(z_root() . '/mail/' . $mailbox); - } - - if((argc() == 4) && (argv(2) === 'recall')) { - if(! intval(argv(3))) - return; - $cmd = argv(2); - $mailbox = argv(1); - $r = q("update mail set mail_recalled = 1 where id = %d and channel_id = %d", - intval(argv(3)), - intval(local_channel()) - ); - $x = q("select * from mail where id = %d and channel_id = %d", - intval(argv(3)), - intval(local_channel()) - ); - if($x) { - build_sync_packet(local_channel(),array('mail' => encode_mail($x[0],true))); - } - - \Zotlabs\Daemon\Master::Summon(array('Notifier','mail',intval(argv(3)))); - - if($r) { - info( t('Message recalled.') . EOL ); - } - goaway(z_root() . '/mail/' . $mailbox . '/' . argv(3)); - - } - - if((argc() == 4) && (argv(2) === 'dropconv')) { - if(! intval(argv(3))) - return; - $cmd = argv(2); - $mailbox = argv(1); - $r = private_messages_drop(local_channel(), argv(3), true); - if($r) - info( t('Conversation removed.') . EOL ); - goaway(z_root() . '/mail/' . $mailbox); - } - - if((argc() > 1) && (argv(1) === 'new')) { - - $plaintext = true; - - $tpl = get_markup_template('msg-header.tpl'); - - $header = replace_macros($tpl, array( - '$baseurl' => z_root(), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$nickname' => $channel['channel_address'], - '$linkurl' => t('Please enter a link URL:'), - '$expireswhen' => t('Expires YYYY-MM-DD HH:MM') - )); - - \App::$page['htmlhead'] .= $header; - - $prename = ''; - $preid = ''; - - if(x($_REQUEST,'hash')) { - - $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash - where abook_channel = %d and abook_xchan = '%s' limit 1", - intval(local_channel()), - dbesc($_REQUEST['hash']) - ); - - if(!$r) { - $r = q("select * from xchan where xchan_hash = '%s' and xchan_network = 'zot' limit 1", - dbesc($_REQUEST['hash']) - ); - } - - if($r) { - $prename = (($r[0]['abook_id']) ? $r[0]['xchan_name'] : $r[0]['xchan_addr']); - $preurl = $r[0]['xchan_url']; - $preid = (($r[0]['abook_id']) ? ($r[0]['xchan_hash']) : ''); - } - else { - notice( t('Requested channel is not in this network') . EOL ); - } - - } - - $tpl = get_markup_template('prv_message.tpl'); - $o .= replace_macros($tpl,array( - '$new' => true, - '$header' => t('Send Private Message'), - '$to' => t('To:'), - '$prefill' => $prename, - '$preid' => $preid, - '$subject' => t('Subject:'), - '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''), - '$text' => ((x($_REQUEST,'body')) ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : ''), - '$yourmessage' => t('Your message:'), - '$parent' => '', - '$attach' => t('Attach file'), - '$insert' => t('Insert web link'), - '$submit' => t('Send'), - '$defexpire' => '', - '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false), - '$expires' => t('Set expiration date'), - '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false), - '$encrypt' => t('Encrypt text'), - '$cipher' => $cipher, - )); - - return $o; - } - - $direct_mid = 0; - - switch(argv(1)) { - case 'combined': - $mailbox = 'combined'; - break; - case 'inbox': - $mailbox = 'inbox'; - break; - case 'outbox': - $mailbox = 'outbox'; - break; - default: - $mailbox = 'combined'; - - // notifications direct to mail/nn - - if(intval(argv(1))) - $direct_mid = intval(argv(1)); - break; - } - - - $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); - - $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id']; - - if($direct_mid) - $mid = $direct_mid; - - - $plaintext = true; - - // if( local_channel() && feature_enabled(local_channel(),'richtext') ) - // $plaintext = false; - - - - if($mailbox == 'combined') { - $messages = private_messages_fetch_conversation(local_channel(), $mid, true); - } - else { - $messages = private_messages_fetch_message(local_channel(), $mid, true); - } - - if(! $messages) { - //info( t('Message not found.') . EOL); - return; - } - - if($messages[0]['to_xchan'] === $channel['channel_hash']) - \App::$poi = $messages[0]['from']; - else - \App::$poi = $messages[0]['to']; - - $tpl = get_markup_template('msg-header.tpl'); - - \App::$page['htmlhead'] .= replace_macros($tpl, array( - '$nickname' => $channel['channel_address'], - '$baseurl' => z_root(), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$linkurl' => t('Please enter a link URL:'), - '$expireswhen' => t('Expires YYYY-MM-DD HH:MM') - )); - - $mails = array(); - - $seen = 0; - $unknown = false; - - foreach($messages as $message) { - - $s = theme_attachments($message); - - if($message['mail_raw']) - $message['body'] = mail_prepare_binary([ 'id' => $message['id'] ]); - else - $message['body'] = zidify_links(smilies(bbcode($message['body']))); - - $mails[] = array( - 'mailbox' => $mailbox, - 'id' => $message['id'], - 'mid' => $message['mid'], - 'from_name' => $message['from']['xchan_name'], - 'from_url' => chanlink_hash($message['from_xchan']), - 'from_photo' => $message['from']['xchan_photo_s'], - 'to_name' => $message['to']['xchan_name'], - 'to_url' => chanlink_hash($message['to_xchan']), - 'to_photo' => $message['to']['xchan_photo_s'], - 'subject' => $message['title'], - 'body' => $message['body'], - 'attachments' => $s, - 'delete' => t('Delete message'), - 'dreport' => t('Delivery report'), - 'recall' => t('Recall message'), - 'can_recall' => ($channel['channel_hash'] == $message['from_xchan']), - 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''), - 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'), - 'sig' => base64_encode($message['sig']) - ); - - $seen = $message['seen']; - - } - - $recp = (($message['from_xchan'] === $channel['channel_hash']) ? 'to' : 'from'); - - $tpl = get_markup_template('mail_display.tpl'); - $o = replace_macros($tpl, array( - '$mailbox' => $mailbox, - '$prvmsg_header' => $message['title'], - '$thread_id' => $mid, - '$thread_subject' => $message['title'], - '$thread_seen' => $seen, - '$delete' => t('Delete Conversation'), - '$canreply' => (($unknown) ? false : '1'), - '$unknown_text' => t("No secure communications available. You may be able to respond from the sender's profile page."), - '$mails' => $mails, - - // reply - '$header' => t('Send Reply'), - '$to' => t('To:'), - '$reply' => true, - '$subject' => t('Subject:'), - '$subjtxt' => $message['title'], - '$yourmessage' => sprintf(t('Your message for %s (%s):'), $message[$recp]['xchan_name'], $message[$recp]['xchan_addr']), - '$text' => '', - '$parent' => $message['parent_mid'], - '$recphash' => $message[$recp]['xchan_hash'], - '$attach' => t('Attach file'), - '$insert' => t('Insert web link'), - '$submit' => t('Submit'), - '$defexpire' => '', - '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false), - '$expires' => t('Set expiration date'), - '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false), - '$encrypt' => t('Encrypt text'), - '$cipher' => $cipher, - )); - - return $o; - - } - -} diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 84b9ec24a..ae5c0af6e 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -15,7 +15,7 @@ class Activity_filter { $filter_active = false; $tabs = []; -/* leave this commented out until ready for primetime + if(x($_GET,'dm')) { $dm_active = (($_GET['dm'] == 1) ? 'active' : ''); $filter_active = 'dm'; @@ -28,7 +28,7 @@ class Activity_filter { 'sel' => $dm_active, 'title' => t('Show direct (private) messages') ]; -*/ + if(Apps::system_app_installed(local_channel(), 'Privacy Groups')) { $groups = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval(local_channel()) -- cgit v1.2.3 From 570d84c031d9cdf0e16aa79bc4a7a111345cc3f3 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 16:04:40 +0000 Subject: fix shortlocalize --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index db80e9edd..f6f8ad0cb 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -849,7 +849,7 @@ class Enotify { //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), - 'message' => bbcode(strip_tags($itemem_text)), + 'message' => bbcode(escape_tags($itemem_text)), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], -- cgit v1.2.3 From 74041838300ee2e20843f68fdaccb2a33b3fa3cb Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 20:13:09 +0000 Subject: missing update file --- Zotlabs/Update/_1235.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Zotlabs/Update/_1235.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1235.php b/Zotlabs/Update/_1235.php new file mode 100644 index 000000000..e457a35d2 --- /dev/null +++ b/Zotlabs/Update/_1235.php @@ -0,0 +1,25 @@ + Date: Sat, 18 Jan 2020 20:46:52 +0000 Subject: the address or URL as linktitle should be sufficient --- Zotlabs/Lib/ThreadItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index ef7b4dbf2..2386a1f0d 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -395,8 +395,8 @@ class ThreadItem { 'consensus' => $consensus, 'conlabels' => $conlabels, 'canvote' => $canvote, - 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url'])), - 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url'])), + 'linktitle' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), + 'olinktitle' => (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url']), 'llink' => $item['llink'], 'viewthread' => $viewthread, 'to' => t('to'), -- cgit v1.2.3 From 51f00cda92c38a0a700bb5144a5b88718ef0f3a3 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Jan 2020 08:55:11 +0000 Subject: fix typo --- Zotlabs/Module/Acl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index b4c1ab124..e0206bd43 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -286,7 +286,7 @@ class Acl extends \Zotlabs\Web\Controller { FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and xchan_deleted = 0 - and xchan_network IN ('zot', 'diapora', 'friendica-over-diaspora') + and xchan_network IN ('zot', 'diaspora', 'friendica-over-diaspora') $sql_extra3 ORDER BY xchan_name ASC ", intval(local_channel()) -- cgit v1.2.3 From 7abcdd34af8796571a0145d16a71a9009b995032 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 25 Jan 2020 14:32:35 +0000 Subject: minor private forum notifications fixes --- Zotlabs/Module/Sse_bs.php | 2 +- Zotlabs/Widget/Activity_filter.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 4340876ea..90e870330 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -404,7 +404,7 @@ class Sse_bs extends Controller { foreach($mids as $mid) $b64mids[] = 'b64.' . base64url_encode($mid); - $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']); + $forums[$x]['notify_link'] = z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']; $forums[$x]['name'] = $forums[$x]['xchan_name']; $forums[$x]['addr'] = $forums[$x]['xchan_addr']; $forums[$x]['url'] = $forums[$x]['xchan_url']; diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index ae5c0af6e..0fc60ca9b 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -2,6 +2,7 @@ namespace Zotlabs\Widget; +use App; use Zotlabs\Lib\Apps; class Activity_filter { @@ -63,6 +64,7 @@ class Activity_filter { if(feature_enabled(local_channel(),'forums_tab')) { $forums = get_forum_channels(local_channel()); + $channel = App::get_channel(); if($forums) { foreach($forums as $f) { @@ -73,7 +75,7 @@ class Activity_filter { $fsub[] = [ 'label' => $f['xchan_name'], 'img' => $f['xchan_photo_s'], - 'url' => (($f['private_forum']) ? $f['xchan_url'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), + 'url' => (($f['private_forum']) ? $f['xchan_url'] . '/?f=&zid=' . $channel['xchan_addr'] : z_root() . '/' . $cmd . '/?f=&pf=1&cid=' . $f['abook_id']), 'sel' => $forum_active, 'title' => t('Show posts to this forum'), 'lock' => (($f['private_forum']) ? 'lock' : '') -- cgit v1.2.3 From 1712eceaf95e5e57d8f5866cb1f6100a0acd28b6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 26 Jan 2020 15:08:55 +0000 Subject: port Lib/Connect and Module/Follow from zap. Connect with new connections via zot6 --- Zotlabs/Access/Permissions.php | 13 +- Zotlabs/Lib/AccessList.php | 411 +++++++++++++++++++++++++++++++++++++++++ Zotlabs/Lib/Connect.php | 315 +++++++++++++++++++++++++++++++ Zotlabs/Module/Follow.php | 102 +++++++--- 4 files changed, 818 insertions(+), 23 deletions(-) create mode 100644 Zotlabs/Lib/AccessList.php create mode 100644 Zotlabs/Lib/Connect.php (limited to 'Zotlabs') diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php index 20dc22a72..35016ed57 100644 --- a/Zotlabs/Access/Permissions.php +++ b/Zotlabs/Access/Permissions.php @@ -283,4 +283,15 @@ class Permissions { return ( [ 'perms' => $my_perms, 'automatic' => $automatic ] ); } -} \ No newline at end of file + static public function serialise($p) { + $n = []; + if($p) { + foreach($p as $k => $v) { + if(intval($v)) { + $n[] = $k; + } + } + } + return implode(',',$n); + } +} diff --git a/Zotlabs/Lib/AccessList.php b/Zotlabs/Lib/AccessList.php new file mode 100644 index 000000000..3c008f8c7 --- /dev/null +++ b/Zotlabs/Lib/AccessList.php @@ -0,0 +1,411 @@ +may apply to this list and any future members. If this is not what you intended, please create another list with a different name.') . EOL); + } + return true; + } + + $hash = new_uuid(); + + $r = q("INSERT INTO pgrp ( hash, uid, visible, gname ) + VALUES( '%s', %d, %d, '%s' ) ", + dbesc($hash), + intval($uid), + intval($public), + dbesc($name) + ); + $ret = $r; + } + + Libsync::build_sync_packet($uid,null,true); + return $ret; + } + + + static function remove($uid,$name) { + $ret = false; + if ($uid && $name) { + $r = q("SELECT id, hash FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1", + intval($uid), + dbesc($name) + ); + if ($r) { + $group_id = $r[0]['id']; + $group_hash = $r[0]['hash']; + } + else { + return false; + } + + // remove group from default posting lists + $r = q("SELECT channel_default_group, channel_allow_gid, channel_deny_gid FROM channel WHERE channel_id = %d LIMIT 1", + intval($uid) + ); + if ($r) { + $user_info = array_shift($r); + $change = false; + + if ($user_info['channel_default_group'] == $group_hash) { + $user_info['channel_default_group'] = ''; + $change = true; + } + if (strpos($user_info['channel_allow_gid'], '<' . $group_hash . '>') !== false) { + $user_info['channel_allow_gid'] = str_replace('<' . $group_hash . '>', '', $user_info['channel_allow_gid']); + $change = true; + } + if (strpos($user_info['channel_deny_gid'], '<' . $group_hash . '>') !== false) { + $user_info['channel_deny_gid'] = str_replace('<' . $group_hash . '>', '', $user_info['channel_deny_gid']); + $change = true; + } + + if ($change) { + q("UPDATE channel SET channel_default_group = '%s', channel_allow_gid = '%s', channel_deny_gid = '%s' + WHERE channel_id = %d", + intval($user_info['channel_default_group']), + dbesc($user_info['channel_allow_gid']), + dbesc($user_info['channel_deny_gid']), + intval($uid) + ); + } + } + + // remove all members + $r = q("DELETE FROM pgrp_member WHERE uid = %d AND gid = %d ", + intval($uid), + intval($group_id) + ); + + // remove group + $r = q("UPDATE pgrp SET deleted = 1 WHERE uid = %d AND gname = '%s'", + intval($uid), + dbesc($name) + ); + + $ret = $r; + + } + + Libsync::build_sync_packet($uid,null,true); + + return $ret; + } + + // returns the integer id of an access group owned by $uid and named $name + // or false. + + static function byname($uid,$name) { + if (! ($uid && $name)) { + return false; + } + $r = q("SELECT id FROM pgrp WHERE uid = %d AND gname = '%s' LIMIT 1", + intval($uid), + dbesc($name) + ); + if ($r) { + return $r[0]['id']; + } + return false; + } + + static function by_id($uid,$id) { + if (! ($uid && $id)) { + return false; + } + + $r = q("SELECT * FROM pgrp WHERE uid = %d AND id = %d and deleted = 0", + intval($uid), + intval($id) + ); + if ($r) { + return array_shift($r); + } + return false; + } + + + + static function rec_byhash($uid,$hash) { + if (! ( $uid && $hash)) { + return false; + } + $r = q("SELECT * FROM pgrp WHERE uid = %d AND hash = '%s' LIMIT 1", + intval($uid), + dbesc($hash) + ); + if ($r) { + return array_shift($r); + } + return false; + } + + + static function member_remove($uid,$name,$member) { + $gid = self::byname($uid,$name); + if (! $gid) { + return false; + } + if (! ($uid && $gid && $member)) { + return false; + } + $r = q("DELETE FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' ", + intval($uid), + intval($gid), + dbesc($member) + ); + + Libsync::build_sync_packet($uid,null,true); + + return $r; + } + + + static function member_add($uid,$name,$member,$gid = 0) { + if (! $gid) { + $gid = self::byname($uid,$name); + } + if (! ($gid && $uid && $member)) { + return false; + } + + $r = q("SELECT * FROM pgrp_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1", + intval($uid), + intval($gid), + dbesc($member) + ); + if ($r) { + return true; // You might question this, but + // we indicate success because the group member was in fact created + // -- It was just created at another time + } + else { + $r = q("INSERT INTO pgrp_member (uid, gid, xchan) + VALUES( %d, %d, '%s' ) ", + intval($uid), + intval($gid), + dbesc($member) + ); + } + Libsync::build_sync_packet($uid,null,true); + return $r; + } + + + static function members($uid, $gid) { + $ret = []; + if (intval($gid)) { + $r = q("SELECT * FROM pgrp_member + LEFT JOIN abook ON abook_xchan = pgrp_member.xchan left join xchan on xchan_hash = abook_xchan + WHERE gid = %d AND abook_channel = %d and pgrp_member.uid = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ", + intval($gid), + intval($uid), + intval($uid) + ); + if ($r) { + $ret = $r; + } + } + return $ret; + } + + static function members_xchan($uid,$gid) { + $ret = []; + if (intval($gid)) { + $r = q("SELECT xchan FROM pgrp_member WHERE gid = %d AND uid = %d", + intval($gid), + intval($uid) + ); + if ($r) { + foreach ($r as $rv) { + $ret[] = $rv['xchan']; + } + } + } + return $ret; + } + + static function members_profile_xchan($uid,$gid) { + $ret = []; + if (intval($gid)) { + $r = q("SELECT abook_xchan as xchan from abook left join profile on abook_profile = profile_guid where profile.id = %d and profile.uid = %d", + intval($gid), + intval($uid) + ); + if ($r) { + foreach($r as $rv) { + $ret[] = $rv['xchan']; + } + } + } + return $ret; + } + + + + + static function select($uid,$group = '') { + + $grps = []; + + $r = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + intval($uid) + ); + $grps[] = [ 'name' => '', 'hash' => '0', 'selected' => '' ]; + if ($r) { + foreach ($r as $rr) { + $grps[] = [ 'name' => $rr['gname'], 'id' => $rr['hash'], 'selected' => (($group == $rr['hash']) ? 'true' : '') ]; + } + + } + + return replace_macros(get_markup_template('group_selection.tpl'), [ + '$label' => t('Add new connections to this access list'), + '$groups' => $grps + ]); + } + + + static function widget($every="connections",$each="lists",$edit = false, $group_id = 0, $cid = '',$mode = 1) { + + $o = ''; + + $groups = []; + + $r = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + intval($_SESSION['uid']) + ); + $member_of = []; + if ($cid) { + $member_of = self::containing(local_channel(),$cid); + } + + if ($r) { + foreach ($r as $rr) { + $selected = (($group_id == $rr['id']) ? ' group-selected' : ''); + + if ($edit) { + $groupedit = [ 'href' => "lists/".$rr['id'], 'title' => t('edit') ]; + } + else { + $groupedit = null; + } + + $groups[] = [ + 'id' => $rr['id'], + 'enc_cid' => base64url_encode($cid), + 'cid' => $cid, + 'text' => $rr['gname'], + 'selected' => $selected, + 'href' => (($mode == 0) ? $each.'?f=&gid='.$rr['id'] : $each."/".$rr['id']) . ((x($_GET,'new')) ? '&new=' . $_GET['new'] : '') . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : ''), + 'edit' => $groupedit, + 'ismember' => in_array($rr['id'],$member_of), + ]; + } + } + + return replace_macros(get_markup_template('group_side.tpl'), [ + '$title' => t('Lists'), + '$edittext' => t('Edit list'), + '$createtext' => t('Create new list'), + '$ungrouped' => (($every === 'contacts') ? t('Channels not in any access list') : ''), + '$groups' => $groups, + '$add' => t('add'), + ]); + + } + + + static function expand($g) { + if (! (is_array($g) && count($g))) { + return []; + } + + $ret = []; + $x = []; + + // private profile linked virtual groups + + foreach ($g as $gv) { + if (substr($gv,0,3) === 'vp.') { + $profile_hash = substr($gv,3); + if ($profile_hash) { + $r = q("select abook_xchan from abook where abook_profile = '%s'", + dbesc($profile_hash) + ); + if ($r) { + foreach ($r as $rv) { + $ret[] = $rv['abook_xchan']; + } + } + } + } + else { + $x[] = $gv; + } + } + + if ($x) { + stringify_array_elms($x,true); + $groups = implode(',', $x); + if ($groups) { + $r = q("SELECT xchan FROM pgrp_member WHERE gid IN ( select id from pgrp where hash in ( $groups ))"); + if ($r) { + foreach ($r as $rv) { + $ret[] = $rv['xchan']; + } + } + } + } + return $ret; + } + + + static function member_of($c) { + $r = q("SELECT pgrp.gname, pgrp.id FROM pgrp LEFT JOIN pgrp_member ON pgrp_member.gid = pgrp.id + WHERE pgrp_member.xchan = '%s' AND pgrp.deleted = 0 ORDER BY pgrp.gname ASC ", + dbesc($c) + ); + + return $r; + } + + static function containing($uid,$c) { + + $r = q("SELECT gid FROM pgrp_member WHERE uid = %d AND pgrp_member.xchan = '%s' ", + intval($uid), + dbesc($c) + ); + + $ret = []; + if ($r) { + foreach ($r as $rv) + $ret[] = $rv['gid']; + } + + return $ret; + } +} \ No newline at end of file diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php new file mode 100644 index 000000000..978a4ce39 --- /dev/null +++ b/Zotlabs/Lib/Connect.php @@ -0,0 +1,315 @@ + false, 'message' => '' ]; + + $my_perms = false; + $protocol = ''; + + if (substr($url,0,1) === '[') { + $x = strpos($url,']'); + if ($x) { + $protocol = substr($url,1,$x-1); + $url = substr($url,$x+1); + } + } + + if (! check_siteallowed($url)) { + $result['message'] = t('Channel is blocked on this site.'); + return $result; + } + + if (! $url) { + $result['message'] = t('Channel location missing.'); + return $result; + } + + // check service class limits + + $r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ", + intval($uid) + ); + if ($r) { + $total_channels = $r[0]['total']; + } + + if (! service_class_allows($uid,'total_channels',$total_channels)) { + $result['message'] = upgrade_message(); + return $result; + } + + $xchan_hash = ''; + $sql_options = (($protocol) ? " and xchan_network = '" . dbesc($protocol) . "' " : ''); + + $r = q("select * from xchan where ( xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s') $sql_options ", + dbesc($url), + dbesc($url), + dbesc($url) + ); + + if ($r) { + + // reset results to the best record or the first if we don't have the best + // note: this is a single record and not an array of results + + $r = Libzot::zot_record_preferred($r,'xchan_network'); + + } + + $singleton = false; + $d = false; + + if (! $r) { + + // not in cache - try discovery + + $wf = discover_by_webbie($url,$protocol); + + if (! $wf) { + $feeds = get_config('system','feed_contacts'); + + if (($feeds) && (in_array($protocol, [ '', 'feed', 'rss' ]))) { + $d = discover_feed($url); + } + else { + $result['message'] = t('Remote channel or protocol unavailable.'); + return $result; + } + } + } + + if ($wf || $d) { + + // something was discovered - find the record which was just created. + + $r = q("select * from xchan where ( xchan_hash = '%s' or xchan_url = '%s' or xchan_addr = '%s' ) $sql_options", + dbesc(($wf) ? $wf : $url), + dbesc($url), + dbesc($url) + ); + + // convert to a single record (once again preferring a zot solution in the case of multiples) + + if ($r) { + $r = Libzot::zot_record_preferred($r,'xchan_network'); + } + } + + // if discovery was a success or the channel was already cached we should have an xchan record in $r + + if ($r) { + $xchan = $r; + $xchan_hash = $r['xchan_hash']; + $their_perms = EMPTY_STR; + } + + // failure case + + if (! $xchan_hash) { + $result['message'] = t('Channel discovery failed.'); + logger('follow: ' . $result['message']); + return $result; + } + + if (! check_channelallowed($xchan_hash)) { + $result['message'] = t('Channel is blocked on this site.'); + logger('follow: ' . $result['message']); + return $result; + + } + + $allowed = ((in_array($xchan['xchan_network'],['rss','zot','zot6'])) ? 1 : 0); + + $hookdata = ['channel_id' => $uid, 'follow_address' => $url, 'xchan' => $xchan, 'allowed' => $allowed, 'singleton' => 0]; + call_hooks('follow_allow',$hookdata); + + if(! $hookdata['allowed']) { + hz_syslog('zesz'); + $result['message'] = t('Protocol disabled.'); + return $result; + } + + $singleton = intval($hookdata['singleton']); + + // Now start processing the new connection + + $aid = $channel['channel_account_id']; + $default_group = $channel['channel_default_group']; + + if (in_array($xchan_hash, [$channel['channel_hash'], $channel['channel_portable_id']])) { + $result['message'] = t('Cannot connect to yourself.'); + return $result; + } + + if ($xchan['xchan_network'] === 'rss') { + + // check service class feed limits + + $t = q("select count(*) as total from abook where abook_account = %d and abook_feed = 1 ", + intval($aid) + ); + if ($t) { + $total_feeds = $t[0]['total']; + } + + if (! service_class_allows($uid,'total_feeds',$total_feeds)) { + $result['message'] = upgrade_message(); + return $result; + } + + // Always set these "remote" permissions for feeds since we cannot interact with them + // to negotiate a suitable permission response + + $p = get_abconfig($uid,$xchan_hash,'system','their_perms',EMPTY_STR); + if ($p) { + $p .= ','; + } + $p .= 'view_stream,republish'; + set_abconfig($uid,$xchan_hash,'system','their_perms',$p); + + } + + + $p = Permissions::connect_perms($uid); + + // parent channels have unencumbered write permission + + if ($sub_channel) { + $p['perms']['post_wall'] = 1; + $p['perms']['post_comments'] = 1; + $p['perms']['write_storage'] = 1; + $p['perms']['post_like'] = 1; + $p['perms']['delegate'] = 0; + $p['perms']['moderated'] = 0; + } + + $my_perms = Permissions::serialise($p['perms']); + + $profile_assign = get_pconfig($uid,'system','profile_assign',''); + + + // See if we are already connected by virtue of having an abook record + + $r = q("select abook_id, abook_xchan, abook_pending, abook_instance from abook + where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($xchan_hash), + intval($uid) + ); + + if ($r) { + + $abook_instance = $r[0]['abook_instance']; + + // If they are on a non-nomadic network, add them to this location + + if (($singleton) && strpos($abook_instance,z_root()) === false) { + if ($abook_instance) { + $abook_instance .= ','; + } + $abook_instance .= z_root(); + + $x = q("update abook set abook_instance = '%s', abook_not_here = 0 where abook_id = %d", + dbesc($abook_instance), + intval($r[0]['abook_id']) + ); + } + + // if they have a pending connection, we just followed them so approve the connection request + + if (intval($r[0]['abook_pending'])) { + $x = q("update abook set abook_pending = 0 where abook_id = %d", + intval($r[0]['abook_id']) + ); + } + } + else { + + // create a new abook record + + $closeness = get_pconfig($uid,'system','new_abook_closeness',80); + + $r = abook_store_lowlevel( + [ + 'abook_account' => intval($aid), + 'abook_channel' => intval($uid), + 'abook_closeness' => intval($closeness), + 'abook_xchan' => $xchan_hash, + 'abook_profile' => $profile_assign, + 'abook_feed' => intval(($xchan['xchan_network'] === 'rss') ? 1 : 0), + 'abook_created' => datetime_convert(), + 'abook_updated' => datetime_convert(), + 'abook_instance' => (($singleton) ? z_root() : '') + ] + ); + } + + if (! $r) { + logger('abook creation failed'); + $result['message'] = t('error saving data'); + return $result; + } + + // Set suitable permissions to the connection + + if ($my_perms) { + set_abconfig($uid,$xchan_hash,'system','my_perms',$my_perms); + } + + // fetch the entire record + + $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash + where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($xchan_hash), + intval($uid) + ); + + if ($r) { + $result['abook'] = array_shift($r); + Master::Summon([ 'Notifier', 'permission_create', $result['abook']['abook_id'] ]); + } + + $arr = [ 'channel_id' => $uid, 'channel' => $channel, 'abook' => $result['abook'] ]; + + call_hooks('follow', $arr); + + /** If there is a default group for this channel, add this connection to it */ + + if ($default_group) { + $g = AccessList::rec_byhash($uid,$default_group); + if ($g) { + AccessList::member_add($uid,'',$xchan_hash,$g['id']); + } + } + + $result['success'] = true; + return $result; + } +} diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php index cbf9d62c5..11febd8fc 100644 --- a/Zotlabs/Module/Follow.php +++ b/Zotlabs/Module/Follow.php @@ -1,31 +1,88 @@ [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + z_root() . ZOT_APSCHEMA_REV + ]], + [ + 'id' => z_root() . '/follow/' . $r[0]['abook_id'], + 'type' => 'Follow', + 'actor' => $actor, + 'object' => $r[0]['xchan_url'] + ]); + + $headers = []; + $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ; + $x['signature'] = LDSignatures::sign($x,$chan); + $ret = json_encode($x, JSON_UNESCAPED_SLASHES); + $headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T'); + $headers['Digest'] = HTTPSig::generate_digest_header($ret); + $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']; + $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],channel_url($chan)); + HTTPSig::set_headers($h); + echo $ret; + killme(); + + } + + if (! local_channel()) { return; } - + $uid = local_channel(); $url = notags(trim(punify($_REQUEST['url']))); $return_url = $_SESSION['return_url']; $confirm = intval($_REQUEST['confirm']); $interactive = (($_REQUEST['interactive']) ? intval($_REQUEST['interactive']) : 1); - $channel = \App::get_channel(); + $channel = App::get_channel(); - $result = new_contact($uid,$url,$channel,$interactive,$confirm); + $result = Connect::connect($channel,$url); - if($result['success'] == false) { - if($result['message']) + if ($result['success'] == false) { + if ($result['message']) { notice($result['message']); - if($interactive) { + } + if ($interactive) { goaway($return_url); } else { @@ -36,8 +93,8 @@ class Follow extends \Zotlabs\Web\Controller { info( t('Connection added.') . EOL); $clone = array(); - foreach($result['abook'] as $k => $v) { - if(strpos($k,'abook_') === 0) { + foreach ($result['abook'] as $k => $v) { + if (strpos($k,'abook_') === 0) { $clone[$k] = $v; } } @@ -46,20 +103,21 @@ class Follow extends \Zotlabs\Web\Controller { unset($clone['abook_channel']); $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']); - if($abconfig) + if ($abconfig) { $clone['abconfig'] = $abconfig; + } + Libsync::build_sync_packet(0, [ 'abook' => [ $clone ] ], true); - build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)), true); - - $can_view_stream = intval(get_abconfig($channel['channel_id'],$clone['abook_xchan'],'their_perms','view_stream')); + $can_view_stream = their_perms_contains($channel['channel_id'],$clone['abook_xchan'],'view_stream'); // If we can view their stream, pull in some posts - if(($can_view_stream) || ($result['abook']['xchan_network'] === 'rss')) - \Zotlabs\Daemon\Master::Summon(array('Onepoll',$result['abook']['abook_id'])); + if (($can_view_stream) || ($result['abook']['xchan_network'] === 'rss')) { + Master::Summon([ 'Onepoll', $result['abook']['abook_id'] ]); + } - if($interactive) { - goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?f=&follow=1'); + if ($interactive) { + goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?follow=1'); } else { json_return_and_die([ 'success' => true ]); @@ -68,7 +126,7 @@ class Follow extends \Zotlabs\Web\Controller { } function get() { - if(! local_channel()) { + if (! local_channel()) { return login(); } } -- cgit v1.2.3 From 3df5d854b8935b11c67893bbbd24cdf8829eda00 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 29 Jan 2020 14:29:06 -0800 Subject: z6 transition work - prevent z6 sync packets from being unpacked into an incompatible schema --- Zotlabs/Lib/Libsync.php | 4 ++-- Zotlabs/Lib/Libzot.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index d93270bc5..b9e9bb38a 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -83,7 +83,7 @@ class Libsync { $info = (($packet) ? $packet : array()); $info['type'] = 'sync'; - $info['encoding'] = 'red'; // note: not zot, this packet is very platform specific + $info['encoding'] = 'hz'; // note: not zot, this packet is very platform specific $info['relocate'] = ['channel_address' => $channel['channel_address'], 'url' => z_root() ]; if(array_key_exists($uid,\App::$config) && array_key_exists('transient',\App::$config[$uid])) { @@ -144,7 +144,7 @@ class Libsync { foreach($synchubs as $hub) { $hash = random_string(); - $n = Libzot::build_packet($channel,'sync',$env_recips,json_encode($info),'red',$hub['hubloc_sitekey'],$hub['site_crypto']); + $n = Libzot::build_packet($channel,'sync',$env_recips,json_encode($info),'hz',$hub['hubloc_sitekey'],$hub['site_crypto']); Queue::insert(array( 'hash' => $hash, 'account_id' => $channel['channel_account_id'], diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index ad00aa97a..bb70dfbf2 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1277,7 +1277,12 @@ class Libzot { logger('Channel sync received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG); logger('Channel sync recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG); - $result = Libsync::process_channel_sync_delivery($env['sender'],$arr,$deliveries); + if ($env['encoding'] === 'hz') { + $result = Libsync::process_channel_sync_delivery($env['sender'],$arr,$deliveries); + } + else { + logger('sync packet type not supported.'); + } } } if ($result) { -- cgit v1.2.3 From 19bb9e018152ce528846fb955b58d76f1bb6bdec Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 30 Jan 2020 10:12:45 +0000 Subject: zap is storing perms different from hubzilla - revert Lib/Connect to use the hubzilla way. Eventually we might want to streamline this with zap. This will require a DB update to upgrade permissions in abconfig. --- Zotlabs/Lib/Connect.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php index 978a4ce39..5fc0e3fe1 100644 --- a/Zotlabs/Lib/Connect.php +++ b/Zotlabs/Lib/Connect.php @@ -152,7 +152,6 @@ class Connect { call_hooks('follow_allow',$hookdata); if(! $hookdata['allowed']) { - hz_syslog('zesz'); $result['message'] = t('Protocol disabled.'); return $result; } @@ -211,7 +210,7 @@ class Connect { $p['perms']['moderated'] = 0; } - $my_perms = Permissions::serialise($p['perms']); + $my_perms = $p['perms']; $profile_assign = get_pconfig($uid,'system','profile_assign',''); @@ -279,8 +278,10 @@ class Connect { // Set suitable permissions to the connection - if ($my_perms) { - set_abconfig($uid,$xchan_hash,'system','my_perms',$my_perms); + if($my_perms) { + foreach($my_perms as $k => $v) { + set_abconfig($uid,$xchan_hash,'my_perms',$k,$v); + } } // fetch the entire record -- cgit v1.2.3 From 2c42daf6090ba8d0e3a50b8350ea5a3750891b68 Mon Sep 17 00:00:00 2001 From: Zot Date: Thu, 30 Jan 2020 20:06:15 +0100 Subject: z6 compat work --- Zotlabs/Lib/Libsync.php | 4 ++-- Zotlabs/Lib/Libzot.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index d93270bc5..b9e9bb38a 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -83,7 +83,7 @@ class Libsync { $info = (($packet) ? $packet : array()); $info['type'] = 'sync'; - $info['encoding'] = 'red'; // note: not zot, this packet is very platform specific + $info['encoding'] = 'hz'; // note: not zot, this packet is very platform specific $info['relocate'] = ['channel_address' => $channel['channel_address'], 'url' => z_root() ]; if(array_key_exists($uid,\App::$config) && array_key_exists('transient',\App::$config[$uid])) { @@ -144,7 +144,7 @@ class Libsync { foreach($synchubs as $hub) { $hash = random_string(); - $n = Libzot::build_packet($channel,'sync',$env_recips,json_encode($info),'red',$hub['hubloc_sitekey'],$hub['site_crypto']); + $n = Libzot::build_packet($channel,'sync',$env_recips,json_encode($info),'hz',$hub['hubloc_sitekey'],$hub['site_crypto']); Queue::insert(array( 'hash' => $hash, 'account_id' => $channel['channel_account_id'], diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index ad00aa97a..bb70dfbf2 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1277,7 +1277,12 @@ class Libzot { logger('Channel sync received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG); logger('Channel sync recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG); - $result = Libsync::process_channel_sync_delivery($env['sender'],$arr,$deliveries); + if ($env['encoding'] === 'hz') { + $result = Libsync::process_channel_sync_delivery($env['sender'],$arr,$deliveries); + } + else { + logger('sync packet type not supported.'); + } } } if ($result) { -- cgit v1.2.3 From 8ed3971ef05be4015b65c9a5b721954c7767ba22 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 30 Jan 2020 20:18:25 +0100 Subject: Prevent multiple database requests on name platform check --- Zotlabs/Lib/System.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 7bf1343bb..3f500486c 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -5,9 +5,14 @@ namespace Zotlabs\Lib; class System { static public function get_platform_name() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('platform_name',\App::$config['system'])) - return \App::$config['system']['platform_name']; - return PLATFORM_NAME; + + if(! isset($platform_name)) { + if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('platform_name',\App::$config['system'])) + static $platform_name = \App::$config['system']['platform_name']; + else + static $platform_name = PLATFORM_NAME; + } + return $platform_name; } static public function get_site_name() { -- cgit v1.2.3 From 5e76318e44d682ce631aa575550ce666eff2ea79 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 30 Jan 2020 20:28:55 +0100 Subject: Update System.php --- Zotlabs/Lib/System.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 3f500486c..b66f66bce 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -6,11 +6,12 @@ class System { static public function get_platform_name() { - if(! isset($platform_name)) { + static $platform_name = ''; + if(empty($platform_name)) { if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('platform_name',\App::$config['system'])) - static $platform_name = \App::$config['system']['platform_name']; + $platform_name = \App::$config['system']['platform_name']; else - static $platform_name = PLATFORM_NAME; + $platform_name = PLATFORM_NAME; } return $platform_name; } -- cgit v1.2.3 From b37e5a426abee519f20a9cec557538bde3841ad8 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 30 Jan 2020 20:36:00 +0100 Subject: Update System.php --- Zotlabs/Lib/System.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index b66f66bce..3cc46fbda 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -5,8 +5,7 @@ namespace Zotlabs\Lib; class System { static public function get_platform_name() { - - static $platform_name = ''; + static $platform_name = ''; if(empty($platform_name)) { if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('platform_name',\App::$config['system'])) $platform_name = \App::$config['system']['platform_name']; -- cgit v1.2.3 From 989443a5698adf5e7a93f874048699526aa103a7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Jan 2020 15:56:33 -0800 Subject: basic poll support and patch to not call System::get_platform_name() within t() unless needed. Polls probably need refining and have not yet been fully tested after porting --- Zotlabs/Lib/Activity.php | 45 +++++++++++++++-- Zotlabs/Module/Item.php | 63 ++++++++++++++++++++++- Zotlabs/Module/Vote.php | 129 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 231 insertions(+), 6 deletions(-) create mode 100644 Zotlabs/Module/Vote.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 43315a87f..66b1ee4b8 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -813,6 +813,10 @@ class Activity { static function activity_mapper($verb) { + if ($verb === 'Answer') { + return 'Note'; + } + if(strpos($verb,'/') === false) { return $verb; } @@ -932,10 +936,6 @@ class Activity { static function activity_obj_mapper($obj) { - if(strpos($obj,'/') === false) { - return $obj; - } - $objs = [ 'http://activitystrea.ms/schema/1.0/note' => 'Note', 'http://activitystrea.ms/schema/1.0/comment' => 'Note', @@ -956,6 +956,15 @@ class Activity { call_hooks('activity_obj_mapper',$objs); + if ($obj === 'Answer') { + return 'Note'; + } + + if (strpos($obj,'/') === false) { + return $obj; + } + + if(array_key_exists($obj,$objs)) { return $objs[$obj]; } @@ -1644,6 +1653,13 @@ class Activity { $s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']); } + if ($act->type === 'Note' && $act->obj['type'] === 'Question' && $act->data['name']) { + $s['mid'] = $act->id; + $s['parent_mid'] = $act->obj['id']; + $s['replyto'] = $act->replyto; + $s['verb'] = 'Answer'; + $content['content'] = EMPTY_STR; + } if(in_array($act->type, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'emojiReaction' ])) { @@ -1711,6 +1727,15 @@ class Activity { $s['verb'] = self::activity_decode_mapper($act->type); + if ($act->type === 'Note' && $act->obj['type'] === 'Question' && $act->data['name'] && ! $content['content']) { + $s['verb'] = 'Answer'; + $s['title'] = purify_html($act->data['name']); + } + + // Mastodon does not provide update timestamps when updating poll tallies which means race conditions may occur here. + if ($act->type === 'Update' && $act->obj['type'] === 'Question' && $s['edited'] === $s['created']) { + $s['edited'] = datetime_convert(); + } if($act->type === 'Tombstone' || $act->type === 'Delete' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) { $s['item_deleted'] = 1; @@ -1798,6 +1823,18 @@ class Activity { } + if ($act->obj['type'] === 'Question' && in_array($act->type,['Create','Update'])) { + if ($act->obj['endTime']) { + $s['comments_closed'] = datetime_convert('UTC','UTC', $act->obj['endTime']); + } + } + + if ($act->obj['closed']) { + $s['comments_closed'] = datetime_convert('UTC','UTC', $act->obj['closed']); + } + + + // we will need a hook here to extract magnet links e.g. peertube // right now just link to the largest mp4 we find that will fit in our // standard content region diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 1a25e54df..8b4bbae91 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -718,7 +718,14 @@ class Item extends Controller { // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - + + $obj = $this->extract_poll_data($body); + if ($obj) { + $datarray['obj'] = $obj; + $obj_type = 'Question'; + } + + if(strpos($body,'[/summary]') !== false) { $match = ''; @@ -1387,5 +1394,57 @@ class Item extends Controller { return $ret; } - + function extract_poll_data(&$body) { + + $multiple = false; + + if (strpos($body,'[/question]') === false && strpos($body,'[/answer]') === false) { + return false; + } + if (strpos($body,'[nobb]') !== false) { + return false; + } + + + $obj = []; + $ptr = []; + $matches = null; + $obj['type'] = 'Question'; + + if (preg_match_all('/\[answer\](.*?)\[\/answer\]/',$body,$matches,PREG_SET_ORDER)) { + foreach ($matches as $match) { + $ptr[] = [ 'name' => $match[1], 'type' => 'Note', 'replies' => [ 'type' => 'Collection', 'totalItems' => 0 ]]; + $body = str_replace('[answer]' . $match[1] . '[/answer]', EMPTY_STR, $body); + } + } + + $matches = null; + + if (preg_match('/\[question\](.*?)\[\/question\]/',$body,$matches)) { + $obj['content'] = bbcode($matches[1]); + $body = str_replace('[question]' . $matches[1] . '[/question]', $matches[1], $body); + $obj['oneOf'] = $ptr; + } + + $matches = null; + + if (preg_match('/\[question=multiple\](.*?)\[\/question\]/',$body,$matches)) { + $obj['content'] = bbcode($matches[1]); + $body = str_replace('[question=multiple]' . $matches[1] . '[/question]', $matches[1], $body); + $obj['anyOf'] = $ptr; + } + + $matches = null; + + if (preg_match('/\[ends\](.*?)\[\/ends\]',$body,$matches)) { + $obj['endTime'] = datetime_convert(date_default_timezone_get(),'UTC', $matches[1],ATOM_TIME); + $body = str_replace('[ends]' . $match[1] . '[/ends]', EMPTY_STR, $body); + } + + return $obj; + + } + + + } diff --git a/Zotlabs/Module/Vote.php b/Zotlabs/Module/Vote.php new file mode 100644 index 000000000..52d6a4bea --- /dev/null +++ b/Zotlabs/Module/Vote.php @@ -0,0 +1,129 @@ + false, 'message' => EMPTY_STR ]; + + $channel = App::get_channel(); + + if (! $channel) { + $ret['message'] = t('Permission denied.'); + json_return_and_die($ret); + } + + + $fetch = null; + $id = argv(1); + $response = $_REQUEST['answer']; + + if ($id) { + $fetch = q("select * from item where id = %d limit 1", + intval($id) + ); + } + + + if ($fetch && $fetch[0]['obj_type'] === 'Question') { + $obj = json_decode($fetch[0]['obj'],true); + + } + else { + $ret['message'] = t('Poll not found.'); + json_return_and_die($ret); + } + + $valid = false; + + if ($obj['oneOf']) { + foreach($obj['oneOf'] as $selection) { + // logger('selection: ' . $selection); + // logger('response: ' . $response); + if($selection['name'] && $selection['name'] === $response) { + $valid = true; + } + } + } + + $choices = []; + if ($obj['anyOf']) { + foreach ($obj['anyOf'] as $selection) { + $choices[] = $selection['name']; + } + foreach ($response as $res) { + if (! in_array($res,$choices)) { + $valid = false; + break; + } + $valid = true; + } + } + + if (! $valid) { + $ret['message'] = t('Invalid response.'); + json_return_and_die($ret); + } + + if (! is_array($response)) { + $response = [ $response ]; + } + + foreach ($response as $res) { + + $item = []; + + + $item['aid'] = $channel['channel_account_id']; + $item['uid'] = $channel['channel_id']; + $item['item_origin'] = true; + $item['parent'] = $fetch[0]['id']; + $item['parent_mid'] = $fetch[0]['mid']; + $item['uuid'] = new_uuid(); + $item['mid'] = z_root() . '/item/' . $item['uuid']; + $item['verb'] = 'Answer'; + $item['title'] = $res; + $item['author_xchan'] = $channel['channel_hash']; + $item['owner_xchan'] = $fetch[0]['author_xchan']; + + $item['obj'] = $obj; + $item['obj_type'] = 'Question'; + + $x = item_store($item); + + retain_item($fetch[0]['id']); + + if($x['success']) { + $itemid = $x['item_id']; + Master::Summon( [ 'Notifier', 'like', $itemid ] ); + } + + $r = q("select * from item where id = %d", + intval($itemid) + ); + if ($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + Libsync::build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]); + } + } + $ret['success'] = true; + $ret['message'] = t('Response submitted. Updates may not appear instantly.'); + json_return_and_die($ret); + } +} + + + + + + + + -- cgit v1.2.3 From 6838342d625236a05695d73efd99f1afdab67d96 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 31 Jan 2020 10:29:20 +0000 Subject: =?UTF-8?q?fix=20php=20warning=C3=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zotlabs/Module/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 8b4bbae91..21d59fbc1 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1436,7 +1436,7 @@ class Item extends Controller { $matches = null; - if (preg_match('/\[ends\](.*?)\[\/ends\]',$body,$matches)) { + if (preg_match('/\[ends\](.*?)\[\/ends\]/',$body,$matches)) { $obj['endTime'] = datetime_convert(date_default_timezone_get(),'UTC', $matches[1],ATOM_TIME); $body = str_replace('[ends]' . $match[1] . '[/ends]', EMPTY_STR, $body); } -- cgit v1.2.3 From fc9e6d289acf30f89da0051a90cbf16f0bc006fb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 31 Jan 2020 12:51:23 -0800 Subject: missing piece of poll code --- Zotlabs/Lib/Activity.php | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 66b1ee4b8..edc65d8e9 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1615,6 +1615,73 @@ class Activity { } + + static function update_poll($item,$mid,$content) { + $multi = false; + if (! $item) { + return false; + } + + $o = json_decode($item['obj'],true); + if ($o && array_key_exists('anyOf',$o)) { + $multi = true; + } + $answer_found = false; + $found = false; + if ($multi) { + for ($c = 0; $c < count($o['anyOf']); $c ++) { + if ($o['anyOf'][$c]['name'] === $content) { + $answer_found = true; + if (is_array($o['anyOf'][$c]['replies'])) { + foreach($o['anyOf'][$c]['replies'] as $reply) { + if(array_key_exists('id',$reply) && $reply['id'] === $mid) { + $found = true; + } + } + } + + if (! $found) { + $o['anyOf'][$c]['replies']['totalItems'] ++; + $o['anyOf'][$c]['replies']['items'][] = [ 'id' => $mid, 'type' => 'Note' ]; + } + } + } + } + else { + for ($c = 0; $c < count($o['oneOf']); $c ++) { + if ($o['oneOf'][$c]['name'] === $content) { + $answer_found = true; + if (is_array($o['oneOf'][$c]['replies'])) { + foreach($o['oneOf'][$c]['replies'] as $reply) { + if(array_key_exists('id',$reply) && $reply['id'] === $mid) { + $found = true; + } + } + } + + if (! $found) { + $o['oneOf'][$c]['replies']['totalItems'] ++; + $o['oneOf'][$c]['replies']['items'][] = [ 'id' => $mid, 'type' => 'Note' ]; + } + } + } + } + logger('updated_poll: ' . print_r($o,true),LOGGER_DATA); + if ($answer_found && ! $found) { + $x = q("update item set obj = '%s', edited = '%s' where id = %d", + dbesc(json_encode($o)), + dbesc(datetime_convert()), + intval($item['id']) + ); + Master::Summon( [ 'Notifier', 'wall-new', $item['id'] ] ); + return true; + } + + return false; + } + + + static function decode_note($act) { $response_activity = false; -- cgit v1.2.3 From bbcb237f5b996e94af37611152105b2e965ea493 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 9 Feb 2020 16:32:18 -0800 Subject: poll updates --- Zotlabs/Lib/Activity.php | 44 +++++++++++++++++++++++++------------------- Zotlabs/Lib/Libzot.php | 12 +++++++++++- Zotlabs/Module/Item.php | 27 +++++++++++++++++---------- Zotlabs/Module/Vote.php | 18 ++++++++++++++---- 4 files changed, 67 insertions(+), 34 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index edc65d8e9..06aa3b931 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -325,6 +325,22 @@ class Activity { $ret['type'] = $objtype; + if ($objtype === 'Question') { + if ($i['obj']) { + if (is_array($i['obj'])) { + $ret = $i['obj']; + } + else { + $ret = json_decode($i['obj'],true); + } + + if(array_path_exists('actor/id',$ret)) { + $ret['actor'] = $ret['actor']['id']; + } + } + } + + $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid'])); if($i['title']) @@ -813,10 +829,6 @@ class Activity { static function activity_mapper($verb) { - if ($verb === 'Answer') { - return 'Note'; - } - if(strpos($verb,'/') === false) { return $verb; } @@ -916,7 +928,6 @@ class Activity { 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', 'Invite' => 'Invite', - ]; call_hooks('activity_obj_decode_mapper',$objs); @@ -1720,14 +1731,6 @@ class Activity { $s['expires'] = datetime_convert('UTC','UTC',$act->obj['expires']); } - if ($act->type === 'Note' && $act->obj['type'] === 'Question' && $act->data['name']) { - $s['mid'] = $act->id; - $s['parent_mid'] = $act->obj['id']; - $s['replyto'] = $act->replyto; - $s['verb'] = 'Answer'; - $content['content'] = EMPTY_STR; - } - if(in_array($act->type, [ 'Like', 'Dislike', 'Flag', 'Block', 'Announce', 'Accept', 'Reject', 'TentativeAccept', 'emojiReaction' ])) { $response_activity = true; @@ -1794,11 +1797,6 @@ class Activity { $s['verb'] = self::activity_decode_mapper($act->type); - if ($act->type === 'Note' && $act->obj['type'] === 'Question' && $act->data['name'] && ! $content['content']) { - $s['verb'] = 'Answer'; - $s['title'] = purify_html($act->data['name']); - } - // Mastodon does not provide update timestamps when updating poll tallies which means race conditions may occur here. if ($act->type === 'Update' && $act->obj['type'] === 'Question' && $s['edited'] === $s['created']) { $s['edited'] = datetime_convert(); @@ -2190,7 +2188,7 @@ class Activity { set_iconfig($item,'activitypub','recips',$act->raw_recips); if(! $is_parent) { - $p = q("select parent_mid from item where mid = '%s' and uid = %d limit 1", + $p = q("select parent_mid, id, obj_type from item where mid = '%s' and uid = %d limit 1", dbesc($item['parent_mid']), intval($item['uid']) ); @@ -2220,6 +2218,14 @@ class Activity { // $s['thr_parent'] = $s['mid']; } } + + if ($p[0]['obj_type'] === 'Question') { + if ($item['obj_type'] === ACTIVITY_OBJ_NOTE && $item['title'] && (! $item['content'])) { + $item['obj_type'] = 'Answer'; + } + } + + if($p[0]['parent_mid'] !== $item['parent_mid']) { $item['thr_parent'] = $item['parent_mid']; } diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index bb70dfbf2..2776a681e 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1613,7 +1613,7 @@ class Libzot { // As a side effect we will also do a preliminary check that we have the top-level-post, otherwise // processing it is pointless. - $r = q("select route, id, owner_xchan, item_private from item where mid = '%s' and uid = %d limit 1", + $r = q("select route, id, parent_mid, mid, owner_xchan, item_private, obj_type from item where mid = '%s' and uid = %d limit 1", dbesc($arr['parent_mid']), intval($channel['channel_id']) ); @@ -1639,6 +1639,16 @@ class Libzot { continue; } + if ($r[0]['obj_type'] === 'Question') { + // route checking doesn't work correctly here because we've changed the privacy + $r[0]['route'] = EMPTY_STR; + // If this is a poll response, convert the obj_type to our (internal-only) "Answer" type + if ($arr['obj_type'] === ACTIVITY_OBJ_NOTE && $arr['title'] && (! $arr['content'])) { + $arr['obj_type'] = 'Answer'; + } + } + + if($relay || $friendofriend || (intval($r[0]['item_private']) === 0 && intval($arr['item_private']) === 0)) { // reset the route in case it travelled a great distance upstream // use our parent's route so when we go back downstream we'll match diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 21d59fbc1..e55192c7f 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -719,14 +719,6 @@ class Item extends Controller { // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - $obj = $this->extract_poll_data($body); - if ($obj) { - $datarray['obj'] = $obj; - $obj_type = 'Question'; - } - - - if(strpos($body,'[/summary]') !== false) { $match = ''; $cnt = preg_match("/\[summary\](.*?)\[\/summary\]/ism",$body,$match); @@ -928,6 +920,13 @@ class Item extends Controller { $mid = z_root() . '/item/' . $uuid; } + $obj = $this->extract_poll_data($body,[ 'item_private' => $private, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_contact_deny ]); + if ($obj) { + $obj['url'] = $mid; + $obj['attributedTo'] = channel_url($channel); + $datarray['obj'] = $obj; + $obj_type = 'Question'; + } if(! $parent_mid) { $parent_mid = $mid; @@ -1394,7 +1393,7 @@ class Item extends Controller { return $ret; } - function extract_poll_data(&$body) { + function extract_poll_data(&$body,$item) { $multiple = false; @@ -1438,7 +1437,15 @@ class Item extends Controller { if (preg_match('/\[ends\](.*?)\[\/ends\]/',$body,$matches)) { $obj['endTime'] = datetime_convert(date_default_timezone_get(),'UTC', $matches[1],ATOM_TIME); - $body = str_replace('[ends]' . $match[1] . '[/ends]', EMPTY_STR, $body); + $body = str_replace('[ends]' . $matches[1] . '[/ends]', EMPTY_STR, $body); + } + + + if ($item['item_private']) { + $obj['to'] = Activity::map_acl($item); + } + else { + $obj['to'] = [ ACTIVITY_PUBLIC_INBOX ]; } return $obj; diff --git a/Zotlabs/Module/Vote.php b/Zotlabs/Module/Vote.php index 52d6a4bea..2c31d84dc 100644 --- a/Zotlabs/Module/Vote.php +++ b/Zotlabs/Module/Vote.php @@ -88,15 +88,25 @@ class Vote extends Controller { $item['parent_mid'] = $fetch[0]['mid']; $item['uuid'] = new_uuid(); $item['mid'] = z_root() . '/item/' . $item['uuid']; - $item['verb'] = 'Answer'; + $item['verb'] = 'Create'; $item['title'] = $res; $item['author_xchan'] = $channel['channel_hash']; $item['owner_xchan'] = $fetch[0]['author_xchan']; - $item['obj'] = $obj; - $item['obj_type'] = 'Question'; + $item['obj_type'] = 'Note'; + $item['author'] = channelx_by_n($channel['channel_id']); + + $item['obj'] = Activity::encode_item($item,true); + + // now reset the placeholders + + $item['obj_type'] = 'Answer'; + unset($item['author']); + + + $x = item_store($item); + - $x = item_store($item); retain_item($fetch[0]['id']); -- cgit v1.2.3 From a39d436f9f46138db623ee3c9ddef2c501ea8bd2 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 10 Feb 2020 20:37:35 +0000 Subject: poll fixes --- Zotlabs/Lib/Activity.php | 7 ++++++- Zotlabs/Lib/Libzot.php | 2 +- Zotlabs/Module/Vote.php | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 06aa3b931..5a406beb7 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -928,6 +928,7 @@ class Activity { 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', 'Invite' => 'Invite', + 'Question' => 'Question' ]; call_hooks('activity_obj_decode_mapper',$objs); @@ -962,7 +963,8 @@ class Activity { 'http://purl.org/zot/activity/thing' => 'Object', 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', - 'Invite' => 'Invite', + 'Invite' => 'Invite', + 'Question' => 'Question' ]; call_hooks('activity_obj_mapper',$objs); @@ -1806,6 +1808,8 @@ class Activity { $s['item_deleted'] = 1; } + + $s['obj_type'] = self::activity_obj_decode_mapper($act->obj['type']); if($s['obj_type'] === ACTIVITY_OBJ_NOTE && $s['mid'] !== $s['parent_mid']) { $s['obj_type'] = ACTIVITY_OBJ_COMMENT; @@ -2219,6 +2223,7 @@ class Activity { } } + if ($p[0]['obj_type'] === 'Question') { if ($item['obj_type'] === ACTIVITY_OBJ_NOTE && $item['title'] && (! $item['content'])) { $item['obj_type'] = 'Answer'; diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 2776a681e..d64421926 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1643,7 +1643,7 @@ class Libzot { // route checking doesn't work correctly here because we've changed the privacy $r[0]['route'] = EMPTY_STR; // If this is a poll response, convert the obj_type to our (internal-only) "Answer" type - if ($arr['obj_type'] === ACTIVITY_OBJ_NOTE && $arr['title'] && (! $arr['content'])) { + if ($arr['obj_type'] === ACTIVITY_OBJ_COMMENT && $arr['title'] && (! $arr['body'])) { $arr['obj_type'] = 'Answer'; } } diff --git a/Zotlabs/Module/Vote.php b/Zotlabs/Module/Vote.php index 2c31d84dc..e1932da23 100644 --- a/Zotlabs/Module/Vote.php +++ b/Zotlabs/Module/Vote.php @@ -86,6 +86,7 @@ class Vote extends Controller { $item['item_origin'] = true; $item['parent'] = $fetch[0]['id']; $item['parent_mid'] = $fetch[0]['mid']; + $item['thr_parent'] = $fetch[0]['mid']; $item['uuid'] = new_uuid(); $item['mid'] = z_root() . '/item/' . $item['uuid']; $item['verb'] = 'Create'; @@ -96,10 +97,11 @@ class Vote extends Controller { $item['obj_type'] = 'Note'; $item['author'] = channelx_by_n($channel['channel_id']); - $item['obj'] = Activity::encode_item($item,true); + $item['obj'] = Activity::encode_item($item); // now reset the placeholders + $item['verb'] = ACTIVITY_POST; $item['obj_type'] = 'Answer'; unset($item['author']); @@ -107,7 +109,6 @@ class Vote extends Controller { $x = item_store($item); - retain_item($fetch[0]['id']); if($x['success']) { -- cgit v1.2.3 From d4a6aa7801d7bad862436990418a7aba34ddef1f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 10 Feb 2020 15:34:33 -0800 Subject: this allows polls to federate from hubzilla to zap, though still a remaining issue with voting --- Zotlabs/Lib/Activity.php | 11 +++++++++-- Zotlabs/Module/Item.php | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 5a406beb7..1ac3135db 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -592,8 +592,15 @@ class Activity { } } - - $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid'])); + if (strpos($i['mid'],z_root() . '/item/') !== false) { + $ret['id'] = str_replace('/item/','/activity/',$i['mid']); + } + elseif (strpos($i['mid'],z_root() . '/event/') !== false) { + $ret['id'] = str_replace('/event/','/activity/',$i['mid']); + } + else { + $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid'])); + } if($i['title']) $ret['name'] = html2plain(bbcode($i['title'], [ 'cache' => true ])); diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index e55192c7f..dbcbe5d22 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -976,7 +976,11 @@ class Item extends Controller { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . gen_link_id($mid); $plink = substr($plink,0,190); } - + + if ($datarray['obj']) { + $datarray['obj']['id'] = $mid; + } + $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; $datarray['uuid'] = $uuid; -- cgit v1.2.3 From bf7c96807a50433b7241ddf6df9e01d4ef11f43d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 10 Feb 2020 18:17:41 -0800 Subject: fix poll responses --- Zotlabs/Daemon/Notifier.php | 12 +++++++++++- Zotlabs/Lib/Libzot.php | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 1d0be10d9..00c6fb077 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -3,6 +3,7 @@ namespace Zotlabs\Daemon; use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Activity; require_once('include/queue_fn.php'); require_once('include/html2plain.php'); @@ -366,9 +367,18 @@ class Notifier { $activity = json_decode($m,true); } else { - $activity = \Zotlabs\Lib\Activity::encode_activity($target_item); + $activity = array_merge(['@context' => [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + z_root() . ZOT_APSCHEMA_REV + ]], Activity::encode_activity($target_item) + ); } + logger('target_item: ' . print_r($target_item,true), LOGGER_DEBUG); + logger('encoded: ' . print_r($activity,true), LOGGER_DEBUG); + + // Send comments to the owner to re-deliver to everybody in the conversation // We only do this if the item in question originated on this site. This prevents looping. // To clarify, a site accepting a new comment is responsible for sending it to the owner for relay. diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index d64421926..42e706754 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1617,6 +1617,7 @@ class Libzot { dbesc($arr['parent_mid']), intval($channel['channel_id']) ); + if(! $r) { $DR->update('comment parent not found'); $result[] = $DR->get(); -- cgit v1.2.3 From 9f029336cab322e04d29af842ba0a666189c8683 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 11 Feb 2020 09:20:32 +0000 Subject: fix notifications for polls --- Zotlabs/Lib/Enotify.php | 5 +++-- Zotlabs/Lib/ThreadItem.php | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index f6f8ad0cb..85e90d67c 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -810,8 +810,9 @@ class Enotify { } else { $itemem_text = (($item['item_thread_top']) - ? t('created a new post') - : sprintf( t('commented on %s\'s post'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]')); + ? (($item['obj_type'] === 'Question') ? t('created a new poll') : t('created a new post')) + : (($item['obj_type'] === 'Answer') ? sprintf( t('voted on %s\'s poll'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]') : sprintf( t('commented on %s\'s post'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]')) + ); if($item['verb'] === ACTIVITY_SHARE) { $itemem_text = sprintf( t('repeated %s\'s post'), '[bdi]' . $item['author']['xchan_name'] . '[/bdi]'); diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 2386a1f0d..dee7cda56 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -204,6 +204,10 @@ class ThreadItem { } } + if($item['obj_type'] === 'Question') { + $response_verbs[] = 'answer'; + } + $consensus = (intval($item['item_consensus']) ? true : false); if($consensus) { $response_verbs[] = 'agree'; -- cgit v1.2.3 From 83256c9ccd2cf3cff74ac10c0ea8e46cb9f77aca Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 12 Feb 2020 14:17:28 -0800 Subject: issue with multi-line poll elements --- Zotlabs/Module/Item.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index dbcbe5d22..4b866eace 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1414,7 +1414,7 @@ class Item extends Controller { $matches = null; $obj['type'] = 'Question'; - if (preg_match_all('/\[answer\](.*?)\[\/answer\]/',$body,$matches,PREG_SET_ORDER)) { + if (preg_match_all('/\[answer\](.*?)\[\/answer\]/ism',$body,$matches,PREG_SET_ORDER)) { foreach ($matches as $match) { $ptr[] = [ 'name' => $match[1], 'type' => 'Note', 'replies' => [ 'type' => 'Collection', 'totalItems' => 0 ]]; $body = str_replace('[answer]' . $match[1] . '[/answer]', EMPTY_STR, $body); @@ -1423,7 +1423,7 @@ class Item extends Controller { $matches = null; - if (preg_match('/\[question\](.*?)\[\/question\]/',$body,$matches)) { + if (preg_match('/\[question\](.*?)\[\/question\]/ism',$body,$matches)) { $obj['content'] = bbcode($matches[1]); $body = str_replace('[question]' . $matches[1] . '[/question]', $matches[1], $body); $obj['oneOf'] = $ptr; @@ -1431,7 +1431,7 @@ class Item extends Controller { $matches = null; - if (preg_match('/\[question=multiple\](.*?)\[\/question\]/',$body,$matches)) { + if (preg_match('/\[question=multiple\](.*?)\[\/question\]/ism',$body,$matches)) { $obj['content'] = bbcode($matches[1]); $body = str_replace('[question=multiple]' . $matches[1] . '[/question]', $matches[1], $body); $obj['anyOf'] = $ptr; @@ -1439,7 +1439,7 @@ class Item extends Controller { $matches = null; - if (preg_match('/\[ends\](.*?)\[\/ends\]/',$body,$matches)) { + if (preg_match('/\[ends\](.*?)\[\/ends\]/ism',$body,$matches)) { $obj['endTime'] = datetime_convert(date_default_timezone_get(),'UTC', $matches[1],ATOM_TIME); $body = str_replace('[ends]' . $matches[1] . '[/ends]', EMPTY_STR, $body); } -- cgit v1.2.3 From 7d05b8e5fdcf628f6badaff60c73811dcc19e45c Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 20 Feb 2020 17:16:14 +0000 Subject: vote issue --- Zotlabs/Module/Vote.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Vote.php b/Zotlabs/Module/Vote.php index e1932da23..d67a6f176 100644 --- a/Zotlabs/Module/Vote.php +++ b/Zotlabs/Module/Vote.php @@ -83,7 +83,7 @@ class Vote extends Controller { $item['aid'] = $channel['channel_account_id']; $item['uid'] = $channel['channel_id']; - $item['item_origin'] = true; + $item['item_origin'] = 1; $item['parent'] = $fetch[0]['id']; $item['parent_mid'] = $fetch[0]['mid']; $item['thr_parent'] = $fetch[0]['mid']; @@ -93,6 +93,9 @@ class Vote extends Controller { $item['title'] = $res; $item['author_xchan'] = $channel['channel_hash']; $item['owner_xchan'] = $fetch[0]['author_xchan']; + $item['allow_cid'] = '<' . $fetch[0]['author_xchan'] . '>'; + $item['item_private'] = 1; + $item['obj_type'] = 'Note'; $item['author'] = channelx_by_n($channel['channel_id']); -- cgit v1.2.3 From b7bac45427a400275597faa9b51c4d277fe1f5c7 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 20 Feb 2020 20:03:50 +0100 Subject: Revert "Use argv() instead URI parsing" This reverts commit bcfb69eeeef6a0506a0ec0574a03b673df84a55a --- Zotlabs/Lib/Libsync.php | 5 +- Zotlabs/Module/Cdav.php | 417 +++++++++++++++++++++--------------------------- 2 files changed, 187 insertions(+), 235 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index b9e9bb38a..d1756cf47 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -244,7 +244,10 @@ class Libsync { if(array_key_exists('app',$arr) && $arr['app']) sync_apps($channel,$arr['app']); - + + if(array_key_exists('addressbook',$arr) && $arr['addressbook']) + sync_addressbook($channel,$arr['addressbook']); + if(array_key_exists('chatroom',$arr) && $arr['chatroom']) sync_chatrooms($channel,$arr['chatroom']); diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index af40689c1..593a78a53 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -10,6 +10,7 @@ require_once('include/event.php'); require_once('include/auth.php'); require_once('include/security.php'); +require_once('include/cdav.php'); class Cdav extends Controller { @@ -156,6 +157,69 @@ class Cdav extends Controller { } } + + // Track CDAV updates from remote clients + + $httpmethod = $_SERVER['REQUEST_METHOD']; + + if($httpmethod === 'PUT' || $httpmethod === 'DELETE') { + + $httpuri = $_SERVER['REQUEST_URI']; + + logger("debug: method: " . $httpmethod, LOGGER_DEBUG); + logger("debug: uri: " . $httpuri, LOGGER_DEBUG); + + // currently we process CardDAV requests only + if(strpos($httpuri, 'cdav/addressbooks')) { + + $uri = basename($httpuri); + $httpbody = file_get_contents('php://input'); + + logger("debug: body: " . $httpbody, LOGGER_DEBUG); + + if($id = get_cdav_id($principalUri, explode("/", $httpuri)[4], 'addressbooks')) { + + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + + $etag = (isset($_SERVER['HTTP_IF_MATCH']) ? $_SERVER['HTTP_IF_MATCH'] : false); + + // delete + if($httpmethod === 'DELETE' && $cdavdata['etag'] == $etag) + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'delete_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri + ] + ]); + else { + if($etag) { + // update + if($cdavdata['etag'] !== $etag) + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'update_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri, + 'card' => $httpbody + ] + ]); + } + else { + // new + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'import', + 'uri' => $cdavdata['uri'], + 'ids' => [ $uri ], + 'card' => $httpbody + ] + ]); + } + } + } + } + } $principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($pdo); @@ -523,6 +587,14 @@ class Cdav extends Controller { $properties = ['{DAV:}displayname' => $_REQUEST['{DAV:}displayname']]; $carddavBackend->createAddressBook($principalUri, $addressbookUri, $properties); + + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'create', + 'uri' => $addressbookUri, + 'properties' => $properties + ] + ]); } //edit addressbook @@ -530,6 +602,8 @@ class Cdav extends Controller { $id = $_REQUEST['id']; + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + if(! cdav_perms($id,$addressbooks)) return; @@ -538,16 +612,24 @@ class Cdav extends Controller { ]; $patch = new \Sabre\DAV\PropPatch($mutations); - $carddavBackend->updateAddressBook($id, $patch); - $patch->commit(); + + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'edit', + 'uri' => $cdavdata['uri'], + 'mutations' => $mutations, + ] + ]); } //create addressbook card if($_REQUEST['create'] && $_REQUEST['target'] && $_REQUEST['fn']) { $id = $_REQUEST['target']; + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + do { $duplicate = false; $uri = random_string(40) . '.vcf'; @@ -569,86 +651,22 @@ class Cdav extends Controller { 'N' => array_reverse(explode(' ', $fn)) ]); - $org = $_REQUEST['org']; - if($org) { - $vcard->ORG = $org; - } + $fields = $this->request_to_array($_REQUEST); - $title = $_REQUEST['title']; - if($title) { - $vcard->TITLE = $title; - } - - $tel = $_REQUEST['tel']; - $tel_type = $_REQUEST['tel_type']; - if($tel) { - $i = 0; - foreach($tel as $item) { - if($item) { - $vcard->add('TEL', $item, ['type' => $tel_type[$i]]); - } - $i++; - } - } - - $email = $_REQUEST['email']; - $email_type = $_REQUEST['email_type']; - if($email) { - $i = 0; - foreach($email as $item) { - if($item) { - $vcard->add('EMAIL', $item, ['type' => $email_type[$i]]); - } - $i++; - } - } - - $impp = $_REQUEST['impp']; - $impp_type = $_REQUEST['impp_type']; - if($impp) { - $i = 0; - foreach($impp as $item) { - if($item) { - $vcard->add('IMPP', $item, ['type' => $impp_type[$i]]); - } - $i++; - } - } - - $url = $_REQUEST['url']; - $url_type = $_REQUEST['url_type']; - if($url) { - $i = 0; - foreach($url as $item) { - if($item) { - $vcard->add('URL', $item, ['type' => $url_type[$i]]); - } - $i++; - } - } - - $adr = $_REQUEST['adr']; - $adr_type = $_REQUEST['adr_type']; - - if($adr) { - $i = 0; - foreach($adr as $item) { - if($item) { - $vcard->add('ADR', $item, ['type' => $adr_type[$i]]); - } - $i++; - } - } - - $note = $_REQUEST['note']; - if($note) { - $vcard->NOTE = $note; - } + process_cdav_card($fields, $vcard); $cardData = $vcard->serialize(); $carddavBackend->createCard($id, $uri, $cardData); + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'import', + 'uri' => $cdavdata['uri'], + 'ids' => [ $uri ], + 'card' => $cardData + ] + ]); } //edit addressbook card @@ -656,6 +674,8 @@ class Cdav extends Controller { $id = $_REQUEST['target']; + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + if(!cdav_perms($id,$addressbooks)) return; @@ -670,113 +690,23 @@ class Cdav extends Controller { $vcard->N = array_reverse(explode(' ', $fn)); } - $org = $_REQUEST['org']; - if($org) { - $vcard->ORG = $org; - } - else { - unset($vcard->ORG); - } + $fields = $this->request_to_array($_REQUEST); - $title = $_REQUEST['title']; - if($title) { - $vcard->TITLE = $title; - } - else { - unset($vcard->TITLE); - } - - $tel = $_REQUEST['tel']; - $tel_type = $_REQUEST['tel_type']; - if($tel) { - $i = 0; - unset($vcard->TEL); - foreach($tel as $item) { - if($item) { - $vcard->add('TEL', $item, ['type' => $tel_type[$i]]); - } - $i++; - } - } - else { - unset($vcard->TEL); - } - - $email = $_REQUEST['email']; - $email_type = $_REQUEST['email_type']; - if($email) { - $i = 0; - unset($vcard->EMAIL); - foreach($email as $item) { - if($item) { - $vcard->add('EMAIL', $item, ['type' => $email_type[$i]]); - } - $i++; - } - } - else { - unset($vcard->EMAIL); - } - - $impp = $_REQUEST['impp']; - $impp_type = $_REQUEST['impp_type']; - if($impp) { - $i = 0; - unset($vcard->IMPP); - foreach($impp as $item) { - if($item) { - $vcard->add('IMPP', $item, ['type' => $impp_type[$i]]); - } - $i++; - } - } - else { - unset($vcard->IMPP); - } - - $url = $_REQUEST['url']; - $url_type = $_REQUEST['url_type']; - if($url) { - $i = 0; - unset($vcard->URL); - foreach($url as $item) { - if($item) { - $vcard->add('URL', $item, ['type' => $url_type[$i]]); - } - $i++; - } - } - else { - unset($vcard->URL); - } - - $adr = $_REQUEST['adr']; - $adr_type = $_REQUEST['adr_type']; - if($adr) { - $i = 0; - unset($vcard->ADR); - foreach($adr as $item) { - if($item) { - $vcard->add('ADR', $item, ['type' => $adr_type[$i]]); - } - $i++; - } - } - else { - unset($vcard->ADR); - } - - $note = $_REQUEST['note']; - if($note) { - $vcard->NOTE = $note; - } - else { - unset($vcard->NOTE); - } + process_cdav_card($fields, $vcard, true); $cardData = $vcard->serialize(); $carddavBackend->updateCard($id, $uri, $cardData); + + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'update_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri, + 'card' => $cardData + ] + ]); + } //delete addressbook card @@ -784,12 +714,22 @@ class Cdav extends Controller { $id = $_REQUEST['target']; + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + if(!cdav_perms($id,$addressbooks)) return; $uri = $_REQUEST['uri']; $carddavBackend->deleteCard($id, $uri); + + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'delete_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri + ] + ]); } } @@ -799,6 +739,8 @@ class Cdav extends Controller { $src = $_FILES['userfile']['tmp_name']; if($src) { + + $carddata = @file_get_contents($src); if($_REQUEST['c_upload']) { if($_REQUEST['target'] == 'channel_calendar') { @@ -812,76 +754,39 @@ class Cdav extends Controller { return; } - $id = explode(':', $_REQUEST['target']); + $id = explode(':', $_REQUEST['target'])[0]; $ext = 'ics'; $table = 'calendarobjects'; $column = 'calendarid'; - $objects = new \Sabre\VObject\Splitter\ICalendar(@file_get_contents($src)); + $objects = new \Sabre\VObject\Splitter\ICalendar($carddata); $profile = \Sabre\VObject\Node::PROFILE_CALDAV; $backend = new \Sabre\CalDAV\Backend\PDO($pdo); } if($_REQUEST['a_upload']) { - $id[] = intval($_REQUEST['target']); + $id = intval($_REQUEST['target']); $ext = 'vcf'; $table = 'cards'; $column = 'addressbookid'; - $objects = new \Sabre\VObject\Splitter\VCard(@file_get_contents($src)); + $objects = new \Sabre\VObject\Splitter\VCard($carddata); $profile = \Sabre\VObject\Node::PROFILE_CARDDAV; $backend = new \Sabre\CardDAV\Backend\PDO($pdo); + + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); } - - while ($object = $objects->getNext()) { - - if($_REQUEST['a_upload']) { - $object = $object->convert(\Sabre\VObject\Document::VCARD40); - } - - $ret = $object->validate($profile & \Sabre\VObject\Node::REPAIR); - - //level 3 Means that the document is invalid, - //level 2 means a warning. A warning means it's valid but it could cause interopability issues, - //level 1 means that there was a problem earlier, but the problem was automatically repaired. - - if($ret[0]['level'] < 3) { - do { - $duplicate = false; - $objectUri = random_string(40) . '.' . $ext; - - $r = q("SELECT uri FROM $table WHERE $column = %d AND uri = '%s' LIMIT 1", - dbesc($id[0]), - dbesc($objectUri) - ); - - if (count($r)) - $duplicate = true; - } while ($duplicate == true); - - if($_REQUEST['c_upload']) { - $backend->createCalendarObject($id, $objectUri, $object->serialize()); - } - - if($_REQUEST['a_upload']) { - $backend->createCard($id[0], $objectUri, $object->serialize()); - } - } - else { - if($_REQUEST['c_upload']) { - notice( '' . t('INVALID EVENT DISMISSED!') . '' . EOL . - '' . t('Summary: ') . '' . (($object->VEVENT->SUMMARY) ? $object->VEVENT->SUMMARY : t('Unknown')) . EOL . - '' . t('Date: ') . '' . (($object->VEVENT->DTSTART) ? $object->VEVENT->DTSTART : t('Unknown')) . EOL . - '' . t('Reason: ') . '' . $ret[0]['message'] . EOL - ); - } - - if($_REQUEST['a_upload']) { - notice( '' . t('INVALID CARD DISMISSED!') . '' . EOL . - '' . t('Name: ') . '' . (($object->FN) ? $object->FN : t('Unknown')) . EOL . - '' . t('Reason: ') . '' . $ret[0]['message'] . EOL - ); - } - } - } + + $ids = []; + import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backend, $ids, true); + + if(isset($cdavdata)) + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'import', + 'uri' => $cdavdata['uri'], + 'ids' => $ids, + 'card' => $carddata + ] + ]); } @unlink($src); } @@ -1408,7 +1313,19 @@ class Cdav extends Controller { if(! cdav_perms($id,$addressbooks)) return; + // get metadata before we delete it + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + $carddavBackend->deleteAddressBook($id); + + if($cdavdata) + build_sync_packet($channel['channel_id'], [ + 'addressbook' => [ + 'action' => 'drop', + 'uri' => $cdavdata['uri'] + ] + ]); + killme(); } @@ -1460,4 +1377,36 @@ class Cdav extends Controller { } + function get_cdav_data($id, $table) { + + $r = q("SELECT * FROM $table WHERE id = %d LIMIT 1", + intval($id) + ); + + if(! $r) + return false; + + return $r[0]; + } + + function request_to_array($req) { + + $f = []; + + $f['org'] = $req['org']; + $f['title'] = $req['title']; + $f['tel'] = $req['tel']; + $f['tel_type'] = $req['tel_type']; + $f['email'] = $req['email']; + $f['email_type'] = $req['email_type']; + $f['impp'] = $req['impp']; + $f['impp_type'] = $req['impp_type']; + $f['url'] = $req['url']; + $f['url_type'] = $req['url_type']; + $f['adr'] = $req['adr']; + $f['adr_type'] = $req['adr_type']; + $f['note'] = $req['note']; + + return $f; + } } -- cgit v1.2.3 From 60311eb04bc0fa564b9fbe179eb907989ff09d8f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 20 Feb 2020 21:25:41 +0000 Subject: fix warning --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1ac3135db..5cb111381 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1654,7 +1654,7 @@ class Activity { $answer_found = true; if (is_array($o['anyOf'][$c]['replies'])) { foreach($o['anyOf'][$c]['replies'] as $reply) { - if(array_key_exists('id',$reply) && $reply['id'] === $mid) { + if(is_array($reply) && array_key_exists('id',$reply) && $reply['id'] === $mid) { $found = true; } } @@ -1673,7 +1673,7 @@ class Activity { $answer_found = true; if (is_array($o['oneOf'][$c]['replies'])) { foreach($o['oneOf'][$c]['replies'] as $reply) { - if(array_key_exists('id',$reply) && $reply['id'] === $mid) { + if(is_array($reply) && array_key_exists('id',$reply) && $reply['id'] === $mid) { $found = true; } } -- cgit v1.2.3 From 9d97cc2a1d28cd201912870a5342e7eaf9285491 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 21 Feb 2020 10:44:26 +0000 Subject: implement optional events and polls filter --- Zotlabs/Module/Network.php | 24 +++++++++++++++++++----- Zotlabs/Widget/Activity_filter.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index a8efd0d9e..adfdc011b 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -340,7 +340,7 @@ class Network extends \Zotlabs\Web\Controller { // The special div is needed for liveUpdate to kick in for this page. // We only launch liveUpdate if you aren't filtering in some incompatible // way and also you aren't writing a comment (discovered in javascript). - + $maxheight = get_pconfig(local_channel(),'system','network_divmore_height'); if(! $maxheight) $maxheight = 400; @@ -411,10 +411,24 @@ class Network extends \Zotlabs\Web\Controller { } } - if($verb) { - $sql_extra .= sprintf(" AND item.verb like '%s' ", - dbesc(protect_sprintf('%' . $verb . '%')) - ); + if ($verb) { + + // the presence of a leading dot in the verb determines + // whether to match the type of activity or the child object. + // The name 'verb' is a holdover from the earlier XML + // ActivityStreams specification. + + if (substr($verb,0,1) === '.') { + $verb = substr($verb,1); + $sql_extra .= sprintf(" AND item.obj_type like '%s' ", + dbesc(protect_sprintf('%' . $verb . '%')) + ); + } + else { + $sql_extra .= sprintf(" AND item.verb like '%s' ", + dbesc(protect_sprintf('%' . $verb . '%')) + ); + } } if(strlen($file)) { diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php index 0fc60ca9b..002a642cb 100644 --- a/Zotlabs/Widget/Activity_filter.php +++ b/Zotlabs/Widget/Activity_filter.php @@ -22,6 +22,13 @@ class Activity_filter { $filter_active = 'dm'; } + if(x($_GET,'verb')) { + $events_active = (($_GET['verb'] == '.Event') ? 'active' : ''); + $polls_active = (($_GET['verb'] == '.Question') ? 'active' : ''); + $filter_active = (($events_active) ? 'events' : 'polls'); + } + + $tabs[] = [ 'label' => t('Direct Messages'), 'icon' => 'envelope-o', @@ -30,6 +37,27 @@ class Activity_filter { 'title' => t('Show direct (private) messages') ]; + if(feature_enabled(local_channel(),'events_tab')) { + $tabs[] = [ + 'label' => t('Events'), + 'icon' => 'calendar', + 'url' => z_root() . '/' . $cmd . '/?verb=%2EEvent', + 'sel' => $events_active, + 'title' => t('Show posts that include events') + ]; + } + + if(feature_enabled(local_channel(),'polls_tab')) { + $tabs[] = [ + 'label' => t('Polls'), + 'icon' => 'bar-chart', + 'url' => z_root() . '/' . $cmd . '/?verb=%2EQuestion', + 'sel' => $polls_active, + 'title' => t('Show posts that include polls') + ]; + } + + if(Apps::system_app_installed(local_channel(), 'Privacy Groups')) { $groups = q("SELECT * FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval(local_channel()) -- cgit v1.2.3 From 85cf25a2a8bfbbfe10de485d4affd54626fbbfa4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 23 Feb 2020 15:28:16 -0800 Subject: add iconfig to zot6 objects --- Zotlabs/Lib/Activity.php | 52 ++++++++++++++++++++++++++++++++++++++++----- Zotlabs/Module/Apschema.php | 5 ++++- 2 files changed, 51 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1ac3135db..0d8dab95c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -504,10 +504,47 @@ class Activity { } } } + if ($item['iconfig']) { + foreach ($item['iconfig'] as $att) { + if ($att['sharing']) { + $value = ((preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']); + $ret[] = [ 'type' => 'PropertyValue', 'name' => 'zot.' . $att['cat'] . '.' . $att['k'], 'value' => $value ]; + } + } + } return $ret; } + static function decode_iconfig($item) { + + $ret = []; + + if (is_array($item['attachment']) && $item['attachment']) { + $ptr = $item['attachment']; + if (! array_key_exists(0,$ptr)) { + $ptr = [ $ptr ]; + } + foreach ($ptr as $att) { + $entry = []; + if ($att['type'] === 'PropertyValue') { + if (array_key_exists('name',$att) && $att['name']) { + $key = explode('.',$att['name']); + if (count($key) === 3 && $key[0] === 'zot') { + $entry['cat'] = $key[1]; + $entry['k'] = $key[2]; + $entry['v'] = $att['value']; + $entry['sharing'] = '1'; + $ret[] = $entry; + } + } + } + } + } + return $ret; + } + + static function decode_attachment($item) { @@ -1888,17 +1925,22 @@ class Activity { } } - $a = self::decode_attachment($act->obj); - if($a) { - $s['attach'] = $a; - } + } + + $a = self::decode_attachment($act->obj); + if ($a) { + $s['attach'] = $a; + } + + $a = self::decode_iconfig($act->obj); + if ($a) { + $s['iconfig'] = $a; } if($act->obj['type'] === 'Note' && $s['attach']) { $s['body'] .= self::bb_attach($s['attach'],$s['body']); } - if ($act->obj['type'] === 'Question' && in_array($act->type,['Create','Update'])) { if ($act->obj['endTime']) { $s['comments_closed'] = datetime_convert('UTC','UTC', $act->obj['endTime']); diff --git a/Zotlabs/Module/Apschema.php b/Zotlabs/Module/Apschema.php index 756057a8a..6b0325d44 100644 --- a/Zotlabs/Module/Apschema.php +++ b/Zotlabs/Module/Apschema.php @@ -29,7 +29,10 @@ class Apschema extends \Zotlabs\Web\Controller { 'emojiReaction' => 'zot:emojiReaction', 'expires' => 'zot:expires', 'directMessage' => 'zot:directMessage', - + 'schema' => 'http://schema.org#', + 'PropertyValue' => 'schema:PropertyValue', + 'value' => 'schema:value', + 'magicEnv' => [ '@id' => 'zot:magicEnv', '@type' => '@id' -- cgit v1.2.3 From 989fbe70cd566da4c5757527aa77022036af6274 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 24 Feb 2020 10:02:09 +0100 Subject: Implement DAV calendars sync with clones --- Zotlabs/Lib/Libsync.php | 5 +- Zotlabs/Module/Cdav.php | 156 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 127 insertions(+), 34 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index d1756cf47..c39720735 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -246,7 +246,10 @@ class Libsync { sync_apps($channel,$arr['app']); if(array_key_exists('addressbook',$arr) && $arr['addressbook']) - sync_addressbook($channel,$arr['addressbook']); + sync_addressbook($channel,$arr['addressbook']); + + if(array_key_exists('calendar',$arr) && $arr['calendar']) + sync_calendar($channel,$arr['calendar']); if(array_key_exists('chatroom',$arr) && $arr['chatroom']) sync_chatrooms($channel,$arr['chatroom']); diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index 593a78a53..ac73b8a5b 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -169,24 +169,34 @@ class Cdav extends Controller { logger("debug: method: " . $httpmethod, LOGGER_DEBUG); logger("debug: uri: " . $httpuri, LOGGER_DEBUG); - // currently we process CardDAV requests only if(strpos($httpuri, 'cdav/addressbooks')) { + $sync = 'addressbook'; + $cdavtable = 'addressbooks'; + } + elseif(strpos($httpuri, 'cdav/calendars')) { + $sync = 'calendar'; + $cdavtable = 'calendarinstances'; + } + else + $sync = false; + + if($sync) { $uri = basename($httpuri); $httpbody = file_get_contents('php://input'); logger("debug: body: " . $httpbody, LOGGER_DEBUG); - if($id = get_cdav_id($principalUri, explode("/", $httpuri)[4], 'addressbooks')) { + if($x = get_cdav_id($principalUri, explode("/", $httpuri)[4], $cdavtable)) { - $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + $cdavdata = $this->get_cdav_data($x['id'], $cdavtable); $etag = (isset($_SERVER['HTTP_IF_MATCH']) ? $_SERVER['HTTP_IF_MATCH'] : false); // delete if($httpmethod === 'DELETE' && $cdavdata['etag'] == $etag) build_sync_packet($channel['channel_id'], [ - 'addressbook' => [ + $sync => [ 'action' => 'delete_card', 'uri' => $cdavdata['uri'], 'carduri' => $uri @@ -197,7 +207,7 @@ class Cdav extends Controller { // update if($cdavdata['etag'] !== $etag) build_sync_packet($channel['channel_id'], [ - 'addressbook' => [ + $sync => [ 'action' => 'update_card', 'uri' => $cdavdata['uri'], 'carduri' => $uri, @@ -208,7 +218,7 @@ class Cdav extends Controller { else { // new build_sync_packet($channel['channel_id'], [ - 'addressbook' => [ + $sync => [ 'action' => 'import', 'uri' => $cdavdata['uri'], 'ids' => [ $uri ], @@ -326,6 +336,14 @@ class Cdav extends Controller { // set new calendar to be visible set_pconfig(local_channel(), 'cdav_calendar' , $id[0], 1); + + build_sync_packet($channel['channel_id'], [ + 'calendar' => [ + 'action' => 'create', + 'uri' => $calendarUri, + 'properties' => $properties + ] + ]); } //create new calendar object via ajax request @@ -336,6 +354,8 @@ class Cdav extends Controller { if(!cdav_perms($id[0],$calendars,true)) return; + $cdavdata = $this->get_cdav_data($id[0], 'calendarinstances'); + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); $tz = (($timezone) ? $timezone : date_default_timezone_get()); @@ -391,9 +411,17 @@ class Cdav extends Controller { $vcalendar->VEVENT->DTSTART['TZID'] = $tz; $calendarData = $vcalendar->serialize(); - $caldavBackend->createCalendarObject($id, $objectUri, $calendarData); + build_sync_packet($channel['channel_id'], [ + 'calendar' => [ + 'action' => 'import', + 'uri' => $cdavdata['uri'], + 'ids' => [ $objectUri ], + 'card' => $calendarData + ] + ]); + killme(); } @@ -405,17 +433,24 @@ class Cdav extends Controller { if(! cdav_perms($id[0],$calendars)) return; + $cdavdata = $this->get_cdav_data($id[0], 'calendarinstances'); + $mutations = [ '{DAV:}displayname' => $_REQUEST['{DAV:}displayname'], '{http://apple.com/ns/ical/}calendar-color' => $_REQUEST['color'] ]; $patch = new \Sabre\DAV\PropPatch($mutations); - $caldavBackend->updateCalendar($id, $patch); - $patch->commit(); + build_sync_packet($channel['channel_id'], [ + 'calendar' => [ + 'action' => 'edit', + 'uri' => $cdavdata['uri'], + 'mutations' => $mutations, + ] + ]); } //edit calendar object via ajax request @@ -423,9 +458,11 @@ class Cdav extends Controller { $id = explode(':', $_REQUEST['target']); - if(!cdav_perms($id[0],$calendars,true)) + if(! cdav_perms($id[0],$calendars,true)) return; + $cdavdata = $this->get_cdav_data($id[0], 'calendarinstances'); + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); $tz = (($timezone) ? $timezone : date_default_timezone_get()); @@ -471,9 +508,17 @@ class Cdav extends Controller { $vcalendar->VEVENT->LOCATION = $location; $calendarData = $vcalendar->serialize(); - $caldavBackend->updateCalendarObject($id, $uri, $calendarData); + build_sync_packet($channel['channel_id'], [ + 'calendar' => [ + 'action' => 'update_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri, + 'card' => $calendarData + ] + ]); + killme(); } @@ -482,13 +527,23 @@ class Cdav extends Controller { $id = explode(':', $_REQUEST['target']); - if(!cdav_perms($id[0],$calendars,true)) + if(! cdav_perms($id[0],$calendars,true)) return; + $cdavdata = $this->get_cdav_data($id[0], 'calendarinstances'); + $uri = $_REQUEST['uri']; $caldavBackend->deleteCalendarObject($id, $uri); + build_sync_packet($channel['channel_id'], [ + 'calendar' => [ + 'action' => 'delete_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri + ] + ]); + killme(); } @@ -497,9 +552,11 @@ class Cdav extends Controller { $id = [$_REQUEST['id'][0], $_REQUEST['id'][1]]; - if(!cdav_perms($id[0],$calendars,true)) + if(! cdav_perms($id[0],$calendars,true)) return; + $cdavdata = $this->get_cdav_data($id[0], 'calendarinstances'); + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); $tz = (($timezone) ? $timezone : date_default_timezone_get()); @@ -535,9 +592,17 @@ class Cdav extends Controller { unset($vcalendar->VEVENT->DTEND); $calendarData = $vcalendar->serialize(); - $caldavBackend->updateCalendarObject($id, $uri, $calendarData); + build_sync_packet($channel['channel_id'], [ + 'calendar' => [ + 'action' => 'update_card', + 'uri' => $cdavdata['uri'], + 'carduri' => $uri, + 'card' => $calendarData + ] + ]); + killme(); } @@ -602,11 +667,11 @@ class Cdav extends Controller { $id = $_REQUEST['id']; - $cdavdata = $this->get_cdav_data($id, 'addressbooks'); - if(! cdav_perms($id,$addressbooks)) return; + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + $mutations = [ '{DAV:}displayname' => $_REQUEST['{DAV:}displayname'] ]; @@ -626,6 +691,7 @@ class Cdav extends Controller { //create addressbook card if($_REQUEST['create'] && $_REQUEST['target'] && $_REQUEST['fn']) { + $id = $_REQUEST['target']; $cdavdata = $this->get_cdav_data($id, 'addressbooks'); @@ -656,7 +722,6 @@ class Cdav extends Controller { process_cdav_card($fields, $vcard); $cardData = $vcard->serialize(); - $carddavBackend->createCard($id, $uri, $cardData); build_sync_packet($channel['channel_id'], [ @@ -674,11 +739,11 @@ class Cdav extends Controller { $id = $_REQUEST['target']; - $cdavdata = $this->get_cdav_data($id, 'addressbooks'); - - if(!cdav_perms($id,$addressbooks)) + if(! cdav_perms($id,$addressbooks)) return; + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + $uri = $_REQUEST['uri']; $object = $carddavBackend->getCard($id, $uri); @@ -714,11 +779,11 @@ class Cdav extends Controller { $id = $_REQUEST['target']; - $cdavdata = $this->get_cdav_data($id, 'addressbooks'); - - if(!cdav_perms($id,$addressbooks)) + if(! cdav_perms($id,$addressbooks)) return; + $cdavdata = $this->get_cdav_data($id, 'addressbooks'); + $uri = $_REQUEST['uri']; $carddavBackend->deleteCard($id, $uri); @@ -758,9 +823,12 @@ class Cdav extends Controller { $ext = 'ics'; $table = 'calendarobjects'; $column = 'calendarid'; + $sync = 'calendar'; $objects = new \Sabre\VObject\Splitter\ICalendar($carddata); $profile = \Sabre\VObject\Node::PROFILE_CALDAV; $backend = new \Sabre\CalDAV\Backend\PDO($pdo); + + $cdavdata = $this->get_cdav_data($id, 'calendarinstances'); } if($_REQUEST['a_upload']) { @@ -768,6 +836,7 @@ class Cdav extends Controller { $ext = 'vcf'; $table = 'cards'; $column = 'addressbookid'; + $sync = 'addressbook'; $objects = new \Sabre\VObject\Splitter\VCard($carddata); $profile = \Sabre\VObject\Node::PROFILE_CARDDAV; $backend = new \Sabre\CardDAV\Backend\PDO($pdo); @@ -778,15 +847,14 @@ class Cdav extends Controller { $ids = []; import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backend, $ids, true); - if(isset($cdavdata)) - build_sync_packet($channel['channel_id'], [ - 'addressbook' => [ - 'action' => 'import', - 'uri' => $cdavdata['uri'], - 'ids' => $ids, - 'card' => $carddata - ] - ]); + build_sync_packet($channel['channel_id'], [ + $sync => [ + 'action' => 'import', + 'uri' => $cdavdata['uri'], + 'ids' => $ids, + 'card' => $carddata + ] + ]); } @unlink($src); } @@ -1095,7 +1163,18 @@ class Cdav extends Controller { if(! cdav_perms($id,$calendars)) killme(); - set_pconfig(local_channel(), 'cdav_calendar' , argv(3), argv(4)); + $cdavdata = $this->get_cdav_data($id, 'calendarinstances'); + + set_pconfig(local_channel(), 'cdav_calendar', $id, argv(4)); + + build_sync_packet(local_channel(), [ + 'calendar' => [ + 'action' => 'switch', + 'uri' => $cdavdata['uri'], + 'switch' => intval(argv(4)) + ] + ]); + killme(); } @@ -1106,7 +1185,18 @@ class Cdav extends Controller { if(! cdav_perms($id[0],$calendars)) killme(); + // get metadata before we delete it + $cdavdata = $this->get_cdav_data($id[0], 'calendarinstances'); + $caldavBackend->deleteCalendar($id); + + build_sync_packet($channel['channel_id'], [ + 'calendar' => [ + 'action' => 'drop', + 'uri' => $cdavdata['uri'] + ] + ]); + killme(); } -- cgit v1.2.3 From 8bcdc24fcbb308f052d996291f5ef0b8f4b606f1 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 24 Feb 2020 11:38:23 +0100 Subject: Code reuse --- Zotlabs/Module/Well_known.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Well_known.php b/Zotlabs/Module/Well_known.php index 140ab260d..0d7b222b8 100644 --- a/Zotlabs/Module/Well_known.php +++ b/Zotlabs/Module/Well_known.php @@ -65,11 +65,6 @@ class Well_known extends \Zotlabs\Web\Controller { killme(); case 'caldav': - if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') { - http_status('301', 'moved permanently'); - goaway(z_root() . '/cdav'); - }; - case 'carddav': if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') { http_status('301', 'moved permanently'); -- cgit v1.2.3 From e7f25b84664c158343621c391b8653042d5be53c Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 Feb 2020 09:51:40 +0000 Subject: implement poll UI in jot --- Zotlabs/Module/Item.php | 61 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 4b866eace..86b5c1c7a 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -271,7 +271,9 @@ class Item extends Controller { $consensus = intval($_REQUEST['consensus']); $nocomment = intval($_REQUEST['nocomment']); - + + $is_poll = ((trim($_REQUEST['poll_answers'][0]) != '' && trim($_REQUEST['poll_answers'][1]) != '') ? true : false); + // 'origin' (if non-zero) indicates that this network is where the message originated, // for the purpose of relaying comments to other conversation members. // If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset. @@ -920,7 +922,21 @@ class Item extends Controller { $mid = z_root() . '/item/' . $uuid; } - $obj = $this->extract_poll_data($body,[ 'item_private' => $private, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_contact_deny ]); + + if($is_poll) { + $poll = [ + 'question' => $body, + 'answers' => $_REQUEST['poll_answers'], + 'multiple_answers' => $_REQUEST['poll_multiple_answers'], + 'expire_value' => $_REQUEST['poll_expire_value'], + 'expire_unit' => $_REQUEST['poll_expire_unit'] + ]; + $obj = $this->extract_poll_data($poll, [ 'item_private' => $private, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_contact_deny ]); + } + else { + $obj = $this->extract_bb_poll_data($body,[ 'item_private' => $private, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_contact_deny ]); + } + if ($obj) { $obj['url'] = $mid; $obj['attributedTo'] = channel_url($channel); @@ -1397,7 +1413,7 @@ class Item extends Controller { return $ret; } - function extract_poll_data(&$body,$item) { + function extract_bb_poll_data(&$body,$item) { $multiple = false; @@ -1457,5 +1473,44 @@ class Item extends Controller { } + function extract_poll_data($poll, $item) { + + $multiple = intval($poll['multiple_answers']); + $expire_value = intval($poll['expire_value']); + $expire_unit = $poll['expire_unit']; + $question = $poll['question']; + $answers = $poll['answers']; + + $obj = []; + $ptr = []; + $obj['type'] = 'Question'; + $obj['content'] = bbcode($question); + + foreach($answers as $answer) { + if(trim($answer)) + $ptr[] = [ 'name' => escape_tags($answer), 'type' => 'Note', 'replies' => [ 'type' => 'Collection', 'totalItems' => 0 ]]; + } + + if($multiple) { + $obj['anyOf'] = $ptr; + } + else { + $obj['oneOf'] = $ptr; + } + + $obj['endTime'] = datetime_convert(date_default_timezone_get(), 'UTC', 'now + ' . $expire_value . ' ' . $expire_unit, ATOM_TIME); + + if ($item['item_private']) { + $obj['to'] = Activity::map_acl($item); + } + else { + $obj['to'] = [ ACTIVITY_PUBLIC_INBOX ]; + } + + return $obj; + + } + + } -- cgit v1.2.3 From c74c41c3b88669802c96c565f04b2682a54d43e9 Mon Sep 17 00:00:00 2001 From: BattleMage Date: Thu, 27 Feb 2020 11:44:51 +0100 Subject: Allow wiki link titles Allow linking to wiki pages with alternating titles by separating the title from the link with a pipe, like regular wiki markup does. --- Zotlabs/Lib/NativeWikiPage.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index dddd26af3..d84cc50a8 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -530,8 +530,11 @@ class NativeWikiPage { foreach ($match[1] as $m) { // TODO: Why do we need to double urlencode for this to work? //$pageURLs[] = urlencode(urlencode(escape_tags($m))); - $pageURLs[] = Zlib\NativeWiki::name_encode(escape_tags($m)); - $pages[] = $m; + $titleUri = explode('|',$m); + $page = $titleUri[0] ?? ''; + $title = $titleUri[1] ?? $page; + $pageURLs[] = Zlib\NativeWiki::name_encode(escape_tags($page)); + $pages[] = $title; } $idx = 0; while(strpos($s,'[[') !== false) { -- cgit v1.2.3 From 06f2979e04db2c5eb7e10bc4967d750209a4cc73 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 29 Feb 2020 10:25:22 +0000 Subject: prevent duplicate votes --- Zotlabs/Lib/Activity.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 2f219af1f..02ec7614e 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1673,8 +1673,11 @@ class Activity { - static function update_poll($item,$mid,$content) { + static function update_poll($item,$post) { $multi = false; + $mid = $post['mid']; + $content = $post['title']; + if (! $item) { return false; } @@ -1683,6 +1686,31 @@ class Activity { if ($o && array_key_exists('anyOf',$o)) { $multi = true; } + + $r = q("select mid, title from item where parent_mid = '%s' and author_xchan = '%s'", + dbesc($item['mid']), + dbesc($post['author_xchan']) + ); + + // prevent any duplicate votes by same author for oneOf and duplicate votes with same author and same answer for anyOf + + if ($r) { + if ($multi) { + foreach ($r as $rv) { + if ($rv['title'] === $content && $rv['mid'] !== $mid) { + return false; + } + } + } + else { + foreach ($r as $rv) { + if ($rv['mid'] !== $mid) { + return false; + } + } + } + } + $answer_found = false; $found = false; if ($multi) { -- cgit v1.2.3 From 25cd9b49838cb6e3d2643b27ae1aa2a63a7a0e58 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 6 Mar 2020 09:50:53 +0000 Subject: provide tool to transform channels to zot6. WARNING: transformed channels will not yet be functional without additional patches. --- Zotlabs/Module/Z6trans.php | 200 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 Zotlabs/Module/Z6trans.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Z6trans.php b/Zotlabs/Module/Z6trans.php new file mode 100644 index 000000000..ac8c67c79 --- /dev/null +++ b/Zotlabs/Module/Z6trans.php @@ -0,0 +1,200 @@ + $cols) { + foreach($cols as $col) { + logger("Transforming $table - $col"); + q("UPDATE %s SET %s = replace(%s, '%s', '%s')", + dbesc($table), + dbesc($col), + dbesc($col), + dbesc($zot_xchan), + dbesc($zot6_xchan) + ); + } + logger("$table done."); + } + logger("Transformation completed."); + + + + } + + function get() { + if(!is_site_admin()) + return 'Not Allowed'; + + $path = 'store/z6upgrade.sql'; + + $r = q("SELECT channel.channel_name, channel.channel_hash, xchan.xchan_network FROM channel LEFT JOIN xchan ON channel_hash = xchan_hash WHERE xchan.xchan_network = 'zot' AND channel.channel_removed = 0"); + + foreach($r as $rr) { + + $zot_xchan = $rr['channel_hash']; + + $r = q("SELECT xchan_guid FROM xchan WHERE xchan_hash = '%s' AND xchan_network = 'zot'", + dbesc($zot_xchan) + ); + + if(!$r) { + notice(t('Zot xchan not found. Aborting.') . EOL); + return; + } + + $guid = $r[0]['xchan_guid']; + $r = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", + dbesc($guid) + ); + + if(!$r) { + notice(t('No zot6 xchan found. Aborting.') . EOL); + return; + } + + $zot6_xchan = $r[0]['xchan_hash']; + $zot6_xchan_guid_sig = $r[0]['xchan_guid_sig']; + + //this should probably happen in a db_update during upgrading + $q .= sprintf("UPDATE channel SET channel_hash = '%s', channel_portable_id = '%s', channel_guid_sig = '%s' WHERE channel_hash = '%s';\r\n", + dbesc($zot6_xchan), + dbesc($zot_xchan), + dbesc($zot6_xchan_guid_sig), + dbesc($zot_xchan) + ); + + $core = self::get_core_cols(); + + foreach($core as $table => $cols) { + + foreach($cols as $col) { + + $q .= sprintf("UPDATE %s SET %s = replace(%s, '%s', '%s');\r\n", + dbesc($table), + dbesc($col), + dbesc($col), + dbesc($zot_xchan), + dbesc($zot6_xchan) + ); + + } + + } + + file_put_contents($path, $q); + + } + + + $o = '

' . t('Transform a single channel') . '

'; + $o .= '
'; + $o .= t('Enter zot xchan to transform: ') . '
'; + $o .= '
'; + $o .= '
'; + $o .= '


'; + + + $o .= '

' . t('To transform all channels') . '

'; + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) + $o .= 'Run source ' . $_SERVER["DOCUMENT_ROOT"] . '/' . $path . ' from the mysql console to complete the upgrade.'; + else + $o .= 'Run \i ' . $_SERVER["DOCUMENT_ROOT"] . '/' . $path . ' from the postgresql console to complete the upgrade.'; + + return $o; + + } + + function get_core_cols() { + + $core = [ + 'abconfig' => ['xchan'], + 'abook' => ['abook_xchan'], + 'app' => ['app_author'], + 'attach' => ['creator', 'allow_cid', 'deny_cid'], + 'channel' => ['channel_allow_cid', 'channel_deny_cid'], + 'chat' => ['chat_xchan'], + 'chatpresence' => ['cp_xchan'], + 'chatroom' => ['allow_cid', 'deny_cid'], + 'config' => ['v'], + 'dreport' => ['dreport_recip', 'dreport_xchan'], + 'event' => ['event_xchan', 'allow_cid', 'deny_cid'], + 'iconfig' => ['v'], + 'item' => ['owner_xchan', 'author_xchan', 'source_xchan', 'route', 'allow_cid', 'deny_cid'], + 'mail' => ['from_xchan', 'to_xchan'], + 'menu_item' => ['allow_cid', 'deny_cid'], + 'obj' => ['allow_cid', 'deny_cid'], + 'pconfig' => ['v'], + 'pgrp_member' => ['xchan'], + 'photo' => ['xchan', 'allow_cid', 'deny_cid'], + 'source' => ['src_channel_xchan', 'src_xchan'], + 'updates' => ['ud_hash'], + 'xchat' => ['xchat_xchan'], + 'xconfig' => ['xchan', 'v'], + 'xign' => ['xchan'], + 'xlink' => ['xlink_xchan', 'xlink_link'], + 'xprof' => ['xprof_hash'], + 'xtag' => ['xtag_hash'], + ]; + + return $core; + + } + +} -- cgit v1.2.3 From 720d3dcedc96c7aaf6c4444c8b45acd46b8718b0 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 11 Mar 2020 10:34:25 +0000 Subject: z6trans preparation for db update 1236 --- Zotlabs/Module/Z6trans.php | 118 +++++++++------------------------------------ 1 file changed, 24 insertions(+), 94 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Z6trans.php b/Zotlabs/Module/Z6trans.php index ac8c67c79..98832ad98 100644 --- a/Zotlabs/Module/Z6trans.php +++ b/Zotlabs/Module/Z6trans.php @@ -12,116 +12,50 @@ use Zotlabs\Web\Controller; class Z6trans extends Controller { - function post() { - if(!is_site_admin()) - return; - - $zot_xchan = trim($_POST['zot_xchan']); - - $r = q("SELECT xchan_guid FROM xchan WHERE xchan_hash = '%s' AND xchan_network = 'zot'", - dbesc($zot_xchan) - ); - - if(!$r) { - notice(t('Zot xchan not found. Aborting.') . EOL); - return; - } - - $guid = $r[0]['xchan_guid']; - $r = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", - dbesc($guid) - ); - - if(!$r) { - notice(t('No zot6 xchan found. Aborting.') . EOL); - return; - } - - $zot6_xchan = $r[0]['xchan_hash']; - $zot6_xchan_guid_sig = $r[0]['xchan_guid_sig']; - - - $r = q("SELECT * FROM channel WHERE channel_hash = '%s'", - dbesc($zot_xchan) - ); - - // We got everything we need - start transforming. - - if($r) { - logger("Transforming channel $zot_xchan"); - q("UPDATE channel SET channel_hash = '%s', channel_portable_id = '%s', channel_guid_sig = '%s' WHERE channel_hash = '%s'", - dbesc($zot6_xchan), - dbesc($zot_xchan), - dbesc($zot6_xchan_guid_sig), - dbesc($zot_xchan) - ); - } - - $core = self::get_core_cols(); - - foreach($core as $table => $cols) { - foreach($cols as $col) { - logger("Transforming $table - $col"); - q("UPDATE %s SET %s = replace(%s, '%s', '%s')", - dbesc($table), - dbesc($col), - dbesc($col), - dbesc($zot_xchan), - dbesc($zot6_xchan) - ); - } - logger("$table done."); - } - logger("Transformation completed."); - - - - } - function get() { if(!is_site_admin()) return 'Not Allowed'; - $path = 'store/z6upgrade.sql'; + $path = 'store/z6trans.sql'; - $r = q("SELECT channel.channel_name, channel.channel_hash, xchan.xchan_network FROM channel LEFT JOIN xchan ON channel_hash = xchan_hash WHERE xchan.xchan_network = 'zot' AND channel.channel_removed = 0"); + $r = q("SELECT channel.channel_name, channel.channel_portable_id, xchan.xchan_network FROM channel + LEFT JOIN xchan ON channel_portable_id = xchan_hash + WHERE xchan.xchan_network = 'zot' + AND channel.channel_removed = 0" + ); + + $q = ''; foreach($r as $rr) { - $zot_xchan = $rr['channel_hash']; + $zot_xchan = $rr['channel_portable_id']; $r = q("SELECT xchan_guid FROM xchan WHERE xchan_hash = '%s' AND xchan_network = 'zot'", dbesc($zot_xchan) ); if(!$r) { - notice(t('Zot xchan not found. Aborting.') . EOL); - return; + $q .= '-- ' . $zot_xchan . 'failed: zot xchan not found' . "\r\n"; + continue; } $guid = $r[0]['xchan_guid']; + $r = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", dbesc($guid) ); if(!$r) { - notice(t('No zot6 xchan found. Aborting.') . EOL); - return; + $q .= '-- ' . $zot_xchan . 'failed: zot6 xchan not found' . "\r\n"; + continue; } $zot6_xchan = $r[0]['xchan_hash']; - $zot6_xchan_guid_sig = $r[0]['xchan_guid_sig']; - - //this should probably happen in a db_update during upgrading - $q .= sprintf("UPDATE channel SET channel_hash = '%s', channel_portable_id = '%s', channel_guid_sig = '%s' WHERE channel_hash = '%s';\r\n", - dbesc($zot6_xchan), - dbesc($zot_xchan), - dbesc($zot6_xchan_guid_sig), - dbesc($zot_xchan) - ); $core = self::get_core_cols(); + $q .= '-- Transforming ' . $rr['channel_name'] . "\r\n"; + foreach($core as $table => $cols) { foreach($cols as $col) { @@ -138,24 +72,20 @@ class Z6trans extends Controller { } - file_put_contents($path, $q); - } + if($q) + file_put_contents($path, $q); - $o = '

' . t('Transform a single channel') . '

'; - $o .= '
'; - $o .= t('Enter zot xchan to transform: ') . '
'; - $o .= '
'; - $o .= '
'; - $o .= '


'; - + $o = '

' . t('Update to Hubzilla 5.0 setp 2') . '


'; - $o .= '

' . t('To transform all channels') . '

'; + $o .= '

' . t('To complete the update please run') . '

'; if(ACTIVE_DBTYPE == DBTYPE_MYSQL) - $o .= 'Run source ' . $_SERVER["DOCUMENT_ROOT"] . '/' . $path . ' from the mysql console to complete the upgrade.'; + $o .= 'source ' . $_SERVER["DOCUMENT_ROOT"] . '/' . $path . '

from the mysql console.

'; else - $o .= 'Run \i ' . $_SERVER["DOCUMENT_ROOT"] . '/' . $path . ' from the postgresql console to complete the upgrade.'; + $o .= '\i ' . $_SERVER["DOCUMENT_ROOT"] . '/' . $path . '

from the postgresql console.

'; + + $o .= '

' . t('INFO: this command can take a very long time depending on your DB size.') . '

'; return $o; -- cgit v1.2.3 From c358aa2806717d1af6e47697f87e54b7c9967c9e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 12 Mar 2020 18:27:16 +0000 Subject: first batch of zot6 transition patches. basic communication with transitioned channels *should* work now --- Zotlabs/Daemon/Notifier.php | 14 +++++++++---- Zotlabs/Lib/Libzot.php | 48 ++++++++++++++++++++++---------------------- Zotlabs/Zot6/Zot6Handler.php | 8 ++++---- 3 files changed, 38 insertions(+), 32 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 00c6fb077..fdf0148a6 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -542,11 +542,10 @@ 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, site.site_flags from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . protect_sprintf(implode(',',$recipients)) . ") + $r = q("select hubloc.*, site.site_crypto, site.site_flags, site.site_version, site.site_project from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . protect_sprintf(implode(',',$recipients)) . ") and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) " - ); + ); - if(! $r) { logger('notifier: no hubs', LOGGER_NORMAL, LOG_NOTICE); return; @@ -735,7 +734,14 @@ class Notifier { $packet = zot_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); } - } + } + + if(stripos($hub['site_project'], 'hubzilla') !== false && version_compare($hub['site_version'], '4.7.3', '<=')) { + $encoded_item['owner']['network'] = 'zot'; + $encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']); + $encoded_item['author']['network'] = 'zot'; + $encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']); + } queue_insert( [ diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 42e706754..5e212ad70 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -105,7 +105,7 @@ class Libzot { $data = [ 'type' => $type, 'encoding' => $encoding, - 'sender' => $channel['channel_portable_id'], + 'sender' => $channel['channel_hash'], 'site_id' => self::make_xchan_hash(z_root(), get_config('system','pubkey')), 'version' => System::get_zot_revision(), ]; @@ -422,7 +422,7 @@ class Libzot { [ 'type' => NOTIFY_INTRO, 'from_xchan' => $x['hash'], - 'to_xchan' => $channel['channel_portable_id'], + 'to_xchan' => $channel['channel_hash'], 'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'] ] ); @@ -788,7 +788,7 @@ class Libzot { // see if this is a channel clone that's hosted locally - which we treat different from other xchans/connections - $local = q("select channel_account_id, channel_id from channel where channel_portable_id = '%s' limit 1", + $local = q("select channel_account_id, channel_id from channel where channel_hash = '%s' limit 1", dbesc($xchan_hash) ); if($local) { @@ -1151,7 +1151,7 @@ class Libzot { if($recip_arr) { stringify_array_elms($recip_arr,true); $recips = implode(',',$recip_arr); - $r = q("select channel_portable_id as hash from channel where channel_portable_id in ( " . $recips . " ) and channel_removed = 0 "); + $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) and channel_removed = 0 "); } if(! $r) { @@ -1368,12 +1368,12 @@ class Libzot { $r = []; - $c = q("select channel_id, channel_portable_id from channel where channel_removed = 0"); + $c = q("select channel_id, channel_hash from channel where channel_removed = 0"); if($c) { foreach($c as $cc) { if(perm_is_allowed($cc['channel_id'],$msg['sender'],$perm)) { - $r[] = $cc['channel_portable_id']; + $r[] = $cc['channel_hash']; } } } @@ -1381,7 +1381,7 @@ class Libzot { if($include_sys) { $sys = get_sys_channel(); if($sys) - $r[] = $sys['channel_portable_id']; + $r[] = $sys['channel_hash']; } @@ -1397,7 +1397,7 @@ class Libzot { if($tag['type'] === 'Mention' && (strpos($tag['href'],z_root()) !== false)) { $address = basename($tag['href']); if($address) { - $z = q("select channel_portable_id as hash from channel where channel_address = '%s' + $z = q("select channel_hash as hash from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc($address) ); @@ -1418,7 +1418,7 @@ class Libzot { $thread_parent = self::find_parent($msg,$act); if($thread_parent) { - $z = q("select channel_portable_id as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) ", + $z = q("select channel_hash as hash from channel left join item on channel.channel_id = item.uid where ( item.thr_parent = '%s' OR item.parent_mid = '%s' ) ", dbesc($thread_parent), dbesc($thread_parent) ); @@ -1473,7 +1473,7 @@ class Libzot { $DR = new DReport(z_root(),$sender,$d,$arr['mid']); - $channel = channelx_by_portid($d); + $channel = channelx_by_hash($d); if (! $channel) { $DR->update('recipient not found'); @@ -1510,7 +1510,7 @@ class Libzot { * access checks. */ - if($sender === $channel['channel_portable_id'] && $arr['author_xchan'] === $channel['channel_portable_id'] && $arr['mid'] === $arr['parent_mid']) { + if($sender === $channel['channel_hash'] && $arr['author_xchan'] === $channel['channel_hash'] && $arr['mid'] === $arr['parent_mid']) { $DR->update('self delivery ignored'); $result[] = $DR->get(); continue; @@ -1827,7 +1827,7 @@ class Libzot { $stored = (($item_result && $item_result['item']) ? $item_result['item'] : false); if((is_array($stored)) && ($stored['id'] != $stored['parent']) - && ($stored['author_xchan'] === $channel['channel_hash'] || $stored['author_xchan'] === $channel['channel_portable_id'])) { + && ($stored['author_xchan'] === $channel['channel_hash'] || $stored['author_xchan'] === $channel['channel_hash'])) { retain_item($stored['item']['parent']); } @@ -1949,9 +1949,9 @@ class Libzot { } logger('FOF Activity received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG); - logger('FOF Activity recipient: ' . $channel['channel_portable_id'], LOGGER_DATA, LOG_DEBUG); + logger('FOF Activity recipient: ' . $channel['channel_hash'], LOGGER_DATA, LOG_DEBUG); - $result = self::process_delivery($arr['owner_xchan'],$AS, $arr, [ $channel['channel_portable_id'] ],false,false,true); + $result = self::process_delivery($arr['owner_xchan'],$AS, $arr, [ $channel['channel_hash'] ],false,false,true); if ($result) { $ret = array_merge($ret, $result); } @@ -2207,7 +2207,7 @@ class Libzot { $DR = new DReport(z_root(),$sender,$d,$arr['mid']); - $r = q("select * from channel where channel_portable_id = '%s' limit 1", + $r = q("select * from channel where channel_hash = '%s' limit 1", dbesc($d['hash']) ); @@ -2362,7 +2362,7 @@ class Libzot { $loc = $locations[0]; - $r = q("select * from channel where channel_portable_id = '%s' limit 1", + $r = q("select * from channel where channel_hash = '%s' limit 1", dbesc($sender_hash) ); @@ -2370,7 +2370,7 @@ class Libzot { return; if($loc['url'] !== z_root()) { - $x = q("update channel set channel_moved = '%s' where channel_portable_id = '%s' limit 1", + $x = q("update channel set channel_moved = '%s' where channel_hash = '%s' limit 1", dbesc($loc['url']), dbesc($sender_hash) ); @@ -2404,7 +2404,7 @@ class Libzot { static function encode_locations($channel) { $ret = []; - $x = self::get_hublocs($channel['channel_portable_id']); + $x = self::get_hublocs($channel['channel_hash']); if($x && count($x)) { foreach($x as $hub) { @@ -2752,13 +2752,13 @@ class Libzot { $r = null; if(strlen($zhash)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash - where channel_portable_id = '%s' limit 1", + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + where channel_hash = '%s' limit 1", dbesc($zhash) ); } elseif(strlen($zguid) && strlen($zguid_sig)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($zguid), dbesc($zguid_sig) @@ -2766,7 +2766,7 @@ class Libzot { } elseif(strlen($zaddr)) { if(strpos($zaddr,'[system]') === false) { /* normal address lookup */ - $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1", dbesc($zaddr), dbesc($zaddr) @@ -2786,10 +2786,10 @@ class Libzot { * */ - $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_system = 1 order by channel_id limit 1"); if(! $r) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_removed = 0 order by channel_id limit 1"); } } diff --git a/Zotlabs/Zot6/Zot6Handler.php b/Zotlabs/Zot6/Zot6Handler.php index 37ce11980..d717b147b 100644 --- a/Zotlabs/Zot6/Zot6Handler.php +++ b/Zotlabs/Zot6/Zot6Handler.php @@ -71,7 +71,7 @@ class Zot6Handler implements IHandler { foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel - left join xchan on channel_portable_id = xchan_hash + left join xchan on channel_hash = xchan_hash where xchan_hash ='%s' limit 1", dbesc($recip) ); @@ -139,7 +139,7 @@ class Zot6Handler implements IHandler { $arr = $data['recipients'][0]; - $c = q("select * from channel left join xchan on channel_portable_id = xchan_hash where channel_portable_id = '%s' limit 1", + $c = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_hash = '%s' limit 1", dbesc($arr['portable_id']) ); if (! $c) { @@ -227,8 +227,8 @@ class Zot6Handler implements IHandler { // basically this means "unfriend" foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel - left join xchan on channel_portable_id = xchan_hash - where channel_portable_id = '%s' limit 1", + left join xchan on channel_hash = xchan_hash + where channel_hash = '%s' limit 1", dbesc($recip) ); if ($r) { -- cgit v1.2.3 From c5365261960150a2070b915d27b2b96337651f3d Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 16 Mar 2020 20:12:30 +0000 Subject: Update 1236 and bump version to 4.7.4 --- Zotlabs/Update/_1236.php | 115 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Zotlabs/Update/_1236.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php new file mode 100644 index 000000000..c5f84626b --- /dev/null +++ b/Zotlabs/Update/_1236.php @@ -0,0 +1,115 @@ + Date: Mon, 16 Mar 2020 21:55:59 +0000 Subject: typo --- Zotlabs/Update/_1236.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php index c5f84626b..1ebafcc0b 100644 --- a/Zotlabs/Update/_1236.php +++ b/Zotlabs/Update/_1236.php @@ -19,7 +19,7 @@ class _1236 { foreach($r as $rr) { $zot_xchan = $rr['channel_hash']; - $guid = $r[0]['xchan_guid']; + $guid = $rr[0]['xchan_guid']; $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", dbesc($guid) -- cgit v1.2.3 From eb3dbcce7b1e942fc313b904d1170ac01af2efe8 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 16 Mar 2020 22:04:28 +0000 Subject: one more typo --- Zotlabs/Update/_1236.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php index 1ebafcc0b..d40cc9e25 100644 --- a/Zotlabs/Update/_1236.php +++ b/Zotlabs/Update/_1236.php @@ -19,7 +19,7 @@ class _1236 { foreach($r as $rr) { $zot_xchan = $rr['channel_hash']; - $guid = $rr[0]['xchan_guid']; + $guid = $rr['xchan_guid']; $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", dbesc($guid) -- cgit v1.2.3 From a3acec96745f90443de84d8503334b3a204436fb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 24 Mar 2020 18:26:20 -0700 Subject: issue 1454 - some photo item ActivityStreams links not returning json-ld; requires related fixes in addons/pubcrawl --- Zotlabs/Lib/Activity.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 02ec7614e..c50606d4f 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -323,6 +323,11 @@ class Activity { return $ret; } + + if ($i['obj']) { + $ret = Activity::encode_object($i['obj']); + } + $ret['type'] = $objtype; if ($objtype === 'Question') { -- cgit v1.2.3 From 0c1c386a0af1e8dabaf7acf345dffa5cf5ad89eb Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 25 Mar 2020 11:29:00 +0000 Subject: do not use channel_portable_id in process_channel_sync_delivery(). we should only accept sync packages from channels which are already transitioned to zot6. --- Zotlabs/Lib/Libsync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index c39720735..de389c0a9 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -1022,4 +1022,4 @@ class Libsync { } -} \ No newline at end of file +} -- cgit v1.2.3 From bcdd75b8178309e5c4e65d170505ab60678c2159 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 28 Mar 2020 09:29:49 +0000 Subject: prevent mod fhublocs breaking things. it needs porting to zot6 but has no priority for now. --- Zotlabs/Module/Fhublocs.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhublocs.php b/Zotlabs/Module/Fhublocs.php index 42c119da3..8393d26d6 100644 --- a/Zotlabs/Module/Fhublocs.php +++ b/Zotlabs/Module/Fhublocs.php @@ -10,6 +10,9 @@ require_once('include/crypto.php'); class Fhublocs extends \Zotlabs\Web\Controller { function get() { + + //TODO: this needs updating to zot6!!! + return; if(! is_site_admin()) return; -- cgit v1.2.3 From f49010bb12731c71c278dad8300e8dd117641bf9 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 29 Mar 2020 08:33:42 +0000 Subject: port fhublocs to zot6 and fix issue with primary detection --- Zotlabs/Module/Fhublocs.php | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhublocs.php b/Zotlabs/Module/Fhublocs.php index 8393d26d6..989456f66 100644 --- a/Zotlabs/Module/Fhublocs.php +++ b/Zotlabs/Module/Fhublocs.php @@ -1,6 +1,8 @@ $rr['channel_guid'], @@ -75,7 +74,26 @@ class Fhublocs extends \Zotlabs\Web\Controller { 'hubloc_sitekey' => $sitekey ] ); - +*/ + $h = hubloc_store_lowlevel( + [ + 'hubloc_guid' => $rr['channel_guid'], + 'hubloc_guid_sig' => $rr['channel_guid_sig'], + 'hubloc_hash' => $rr['channel_hash'], + 'hubloc_id_url' => channel_url($rr), + 'hubloc_addr' => channel_reddress($rr), + 'hubloc_primary' => intval($primary), + 'hubloc_url' => z_root(), + 'hubloc_url_sig' => Libzot::sign(z_root(), $rr['channel_prvkey']), + 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(), $sitekey), + 'hubloc_host' => \App::get_hostname(), + 'hubloc_callback' => z_root() . '/zot', + 'hubloc_sitekey' => $sitekey, + 'hubloc_network' => 'zot6', + 'hubloc_updated' => datetime_convert() + ] + ); + if($h) $o . 'local hubloc created for ' . $rr['channel_name'] . EOL; else -- cgit v1.2.3 From b1590ad645eca3f9d35e6fb7250547f2244c3140 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 29 Mar 2020 10:47:22 +0000 Subject: fix check for existing hublocs --- Zotlabs/Module/Fhublocs.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhublocs.php b/Zotlabs/Module/Fhublocs.php index 989456f66..dcd399a1f 100644 --- a/Zotlabs/Module/Fhublocs.php +++ b/Zotlabs/Module/Fhublocs.php @@ -26,7 +26,8 @@ class Fhublocs extends \Zotlabs\Web\Controller { $found = false; $primary_address = ''; - $x = zot_get_hublocs($rr['channel_hash']); + $x = Libzot::get_hublocs($rr['channel_hash']); + if($x) { foreach($x as $xx) { if($xx['hubloc_url'] === z_root() && $xx['hubloc_sitekey'] === $sitekey) { -- cgit v1.2.3 From b739f91caa1522522a4ce093d7c63f0f4c777085 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 29 Mar 2020 15:18:49 +0000 Subject: use Libsync::build_sync_packet() in mod item, default Lib/Queue driver to zot6 and some whitespace cleanup in queue_deliver() --- Zotlabs/Lib/Libsync.php | 1 + Zotlabs/Lib/Queue.php | 2 +- Zotlabs/Module/Item.php | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index de389c0a9..b7cda1770 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -150,6 +150,7 @@ class Libsync { 'account_id' => $channel['channel_account_id'], 'channel_id' => $channel['channel_id'], 'posturl' => $hub['hubloc_callback'], + 'driver' => $hub['hubloc_network'], 'notify' => $n, 'msg' => EMPTY_STR )); diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php index 49891a55b..6acc58bc5 100644 --- a/Zotlabs/Lib/Queue.php +++ b/Zotlabs/Lib/Queue.php @@ -116,7 +116,7 @@ class Queue { dbesc($arr['hash']), intval($arr['account_id']), intval($arr['channel_id']), - dbesc(($arr['driver']) ? $arr['driver'] : 'zot'), + dbesc(($arr['driver']) ? $arr['driver'] : 'zot6'), dbesc($arr['posturl']), intval(1), intval(($arr['priority']) ? $arr['priority'] : 0), diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 86b5c1c7a..fcc040e01 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -11,6 +11,7 @@ use Zotlabs\Lib\ActivityStreams; use Zotlabs\Lib\LDSignatures; use Zotlabs\Web\HTTPSig; use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Libsync; use Zotlabs\Lib\ThreadListener; use App; @@ -1155,7 +1156,7 @@ class Item extends Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); } } if(! $nopush) @@ -1258,7 +1259,7 @@ class Item extends Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($profile_uid,array('item' => array(encode_item($sync_item[0],true)))); } } @@ -1360,7 +1361,7 @@ class Item extends Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); } if($complex) { -- cgit v1.2.3 From 084177a20c194767f227edb61acef236f99061f8 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 31 Mar 2020 19:57:05 +0200 Subject: Avoid multiple run of expiry procedure on large sites --- Zotlabs/Daemon/Expire.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 398425861..bce512b6d 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,6 +9,13 @@ class Expire { cli_startup(); + if ($pid = get_xconfig(0, 'expire', 'procid', false)) { + logger('Expire: procedure already run with PID ' . $pid); + return; + } + + set_xconfig(0, 'expire', 'procid', getmypid()); + // perform final cleanup on previously delete items $r = q("select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s", @@ -90,5 +97,7 @@ class Expire { logger('Expire: sys: done', LOGGER_DEBUG); } + + del_xconfig(0, 'expire', 'procid'); } } -- cgit v1.2.3 From 710448e73fe753c3bd1cac954ea7b5a750a416d1 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 31 Mar 2020 19:58:08 +0200 Subject: Update Expire.php --- Zotlabs/Daemon/Expire.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index bce512b6d..186e88fc9 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -8,11 +8,11 @@ class Expire { static public function run($argc,$argv){ cli_startup(); - - if ($pid = get_xconfig(0, 'expire', 'procid', false)) { - logger('Expire: procedure already run with PID ' . $pid); - return; - } + + if ($pid = get_xconfig(0, 'expire', 'procid', false)) { + logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); + return; + } set_xconfig(0, 'expire', 'procid', getmypid()); -- cgit v1.2.3 From 632996f53e0ff364566a95536b94614387c2582a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 31 Mar 2020 20:03:29 +0200 Subject: Add check if expire procedure is still running --- Zotlabs/Daemon/Expire.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 186e88fc9..c8fb72bb2 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,7 +9,7 @@ class Expire { cli_startup(); - if ($pid = get_xconfig(0, 'expire', 'procid', false)) { + if ($pid = get_xconfig(0, 'expire', 'procid', false) && posix_getpgid($pid)) { logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); return; } -- cgit v1.2.3 From 6c02fa40f11b2d1bd6d058a569a31ac249975e7e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 31 Mar 2020 20:15:09 +0200 Subject: Check if POSIX PHP module is available on PID check --- Zotlabs/Daemon/Expire.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index c8fb72bb2..374f919e6 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,7 +9,7 @@ class Expire { cli_startup(); - if ($pid = get_xconfig(0, 'expire', 'procid', false) && posix_getpgid($pid)) { + if ($pid = get_xconfig(0, 'expire', 'procid', false) && (function_exists('posix_getpgid') ? posix_getpgid($pid) : true)) { logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); return; } -- cgit v1.2.3 From 9773ab7aab3fd694e3ac9de2e88e606d6b04db90 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 31 Mar 2020 20:45:15 +0200 Subject: Use POSIX kill 0 to check expire process status --- Zotlabs/Daemon/Expire.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 374f919e6..bc9e720e9 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,7 +9,7 @@ class Expire { cli_startup(); - if ($pid = get_xconfig(0, 'expire', 'procid', false) && (function_exists('posix_getpgid') ? posix_getpgid($pid) : true)) { + if ($pid = get_xconfig(0, 'expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); return; } -- cgit v1.2.3 From 4a56b77f64f1483bc933a69a70be02df2f8f9187 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 31 Mar 2020 21:00:21 +0200 Subject: Use pconfig --- Zotlabs/Daemon/Expire.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index bc9e720e9..4bdf7ddeb 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,12 +9,12 @@ class Expire { cli_startup(); - if ($pid = get_xconfig(0, 'expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { + if ($pid = get_pconfig(0, 'expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); return; } - - set_xconfig(0, 'expire', 'procid', getmypid()); + + set_pconfig(0, 'expire', 'procid', getmypid()); // perform final cleanup on previously delete items @@ -98,6 +98,6 @@ class Expire { logger('Expire: sys: done', LOGGER_DEBUG); } - del_xconfig(0, 'expire', 'procid'); + del_pconfig(0, 'expire', 'procid'); } } -- cgit v1.2.3 From ffe429be65e8d6198579d3dd987053387799ca78 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Apr 2020 07:44:07 +0000 Subject: transition connections to zot6 if their site has been updated --- Zotlabs/Daemon/Cron_daily.php | 2 ++ Zotlabs/Module/Connections.php | 2 +- Zotlabs/Update/_1236.php | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index 452ef45f1..2cf0c9119 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -96,7 +96,9 @@ class Cron_daily { Master::Summon(array('Cli_suggest')); remove_obsolete_hublocs(); + z6_discover(); + z6trans_connections(); call_hooks('cron_daily',datetime_convert()); diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index 029601867..7dc301623 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -34,7 +34,7 @@ class Connections extends \Zotlabs\Web\Controller { } nav_set_selected('Connections'); - + $active = false; $blocked = false; $hidden = false; diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php index d40cc9e25..6b4e7b299 100644 --- a/Zotlabs/Update/_1236.php +++ b/Zotlabs/Update/_1236.php @@ -105,10 +105,12 @@ class _1236 { } - if(count($r) == $i) + if(count($r) == $i) { + z6trans_connections(); return UPDATE_SUCCESS; - else - return UPDATE_FAILED; + } + + return UPDATE_FAILED; } -- cgit v1.2.3 From 643b2f9205b713bbb3667fdb4d0d549111ccfcaa Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Apr 2020 08:03:19 +0000 Subject: do not enable transition of connections yet --- Zotlabs/Daemon/Cron_daily.php | 2 +- Zotlabs/Update/_1236.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index 2cf0c9119..23099745b 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -98,7 +98,7 @@ class Cron_daily { remove_obsolete_hublocs(); z6_discover(); - z6trans_connections(); + //z6trans_connections(); call_hooks('cron_daily',datetime_convert()); diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php index 6b4e7b299..b27175f99 100644 --- a/Zotlabs/Update/_1236.php +++ b/Zotlabs/Update/_1236.php @@ -106,7 +106,7 @@ class _1236 { } if(count($r) == $i) { - z6trans_connections(); + //z6trans_connections(); return UPDATE_SUCCESS; } -- cgit v1.2.3 From 38be2386dd63a4a18c07e445b9859a5836ed5b46 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Apr 2020 09:26:27 +0000 Subject: cheat with guid_sig to reflect transition to zot6 and re-enable transition of connections --- Zotlabs/Daemon/Cron_daily.php | 2 +- Zotlabs/Update/_1236.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index 23099745b..2cf0c9119 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -98,7 +98,7 @@ class Cron_daily { remove_obsolete_hublocs(); z6_discover(); - //z6trans_connections(); + z6trans_connections(); call_hooks('cron_daily',datetime_convert()); diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php index b27175f99..6b4e7b299 100644 --- a/Zotlabs/Update/_1236.php +++ b/Zotlabs/Update/_1236.php @@ -106,7 +106,7 @@ class _1236 { } if(count($r) == $i) { - //z6trans_connections(); + z6trans_connections(); return UPDATE_SUCCESS; } -- cgit v1.2.3 From c136c142b8148abe75696ca0076a107f04e74d30 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 1 Apr 2020 12:59:12 +0200 Subject: Use config instead pconfig --- Zotlabs/Daemon/Expire.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 4bdf7ddeb..f3f42df6f 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,12 +9,12 @@ class Expire { cli_startup(); - if ($pid = get_pconfig(0, 'expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { + if ($pid = get_config('expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); return; } - set_pconfig(0, 'expire', 'procid', getmypid()); + set_config('expire', 'procid', getmypid()); // perform final cleanup on previously delete items @@ -98,6 +98,6 @@ class Expire { logger('Expire: sys: done', LOGGER_DEBUG); } - del_pconfig(0, 'expire', 'procid'); + del_config('expire', 'procid'); } } -- cgit v1.2.3 From d925ec675984d59b750c91bdd53106ea414bcf71 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Apr 2020 18:13:00 +0000 Subject: fix outgoing mails to zot connections --- Zotlabs/Daemon/Notifier.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index fdf0148a6..d66079216 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -737,10 +737,16 @@ class Notifier { } if(stripos($hub['site_project'], 'hubzilla') !== false && version_compare($hub['site_version'], '4.7.3', '<=')) { - $encoded_item['owner']['network'] = 'zot'; - $encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']); - $encoded_item['author']['network'] = 'zot'; - $encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']); + if($encoded_item['type'] === 'mail') { + $encoded_item['from']['network'] = 'zot'; + $encoded_item['from']['guid_sig'] = str_replace('sha256.', '', $encoded_item['from']['guid_sig']); + } + else { + $encoded_item['owner']['network'] = 'zot'; + $encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']); + $encoded_item['author']['network'] = 'zot'; + $encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']); + } } queue_insert( -- cgit v1.2.3 From 4b3979df04e0cba12049dced3ba037a004c324f6 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 3 Apr 2020 10:49:57 +0200 Subject: Avoid multiple run of expiry procedure on large sites --- Zotlabs/Daemon/Expire.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 398425861..f3f42df6f 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -8,6 +8,13 @@ class Expire { static public function run($argc,$argv){ cli_startup(); + + if ($pid = get_config('expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { + logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); + return; + } + + set_config('expire', 'procid', getmypid()); // perform final cleanup on previously delete items @@ -90,5 +97,7 @@ class Expire { logger('Expire: sys: done', LOGGER_DEBUG); } + + del_config('expire', 'procid'); } } -- cgit v1.2.3 From 625438ff642381472b4ba6c86bad7f26f69e8083 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 19:22:31 +0000 Subject: use timezone info for timezone display only- the actual time is in utc already. --- Zotlabs/Module/Channel_calendar.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index 7d75a7e41..79eb5797f 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -337,21 +337,15 @@ class Channel_calendar extends \Zotlabs\Web\Controller { } $events = []; - if($r) { foreach($r as $rr) { - $tz = get_iconfig($rr, 'event', 'timezone'); - - if(! $tz) - $tz = 'UTC'; - - $start = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c')); + $start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c')); if ($rr['nofinish']){ $end = null; } else { - $end = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c')); + $end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c')); } $catsenabled = feature_enabled(local_channel(),'categories'); @@ -371,12 +365,14 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); + $tz = get_iconfig($rr, 'event', 'timezone'); + $events[] = array( 'calendar_id' => 'channel_calendar', 'rw' => true, 'id'=>$rr['id'], 'uri' => $rr['event_hash'], - 'timezone' => $tz, + 'timezone' => (($tz) ? $tz : 'UTC'), 'start'=> $start, 'end' => $end, 'drop' => $drop, -- cgit v1.2.3 From cec2e92fe381a5e4bb67426290303639dd260358 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 19:50:50 +0000 Subject: more timezone changes --- Zotlabs/Module/Channel_calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index 79eb5797f..87dd2ffb6 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -34,8 +34,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $adjust = intval($_POST['adjust']); - $start = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart'])); - $finish = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend'])); + $start = datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtstart'])); + $finish = datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtend'])); $summary = escape_tags(trim($_POST['summary'])); $desc = escape_tags(trim($_POST['desc'])); -- cgit v1.2.3 From a4831b0f7c608a4337954dfe0ad84486bdc606d6 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 22:01:24 +0200 Subject: Revert "use timezone info for timezone display only- the actual time is in utc already." This reverts commit 625438ff642381472b4ba6c86bad7f26f69e8083 --- Zotlabs/Module/Channel_calendar.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index 87dd2ffb6..c92e6ca1b 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -337,15 +337,21 @@ class Channel_calendar extends \Zotlabs\Web\Controller { } $events = []; + if($r) { foreach($r as $rr) { - $start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c')); + $tz = get_iconfig($rr, 'event', 'timezone'); + + if(! $tz) + $tz = 'UTC'; + + $start = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c')); if ($rr['nofinish']){ $end = null; } else { - $end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c')); + $end = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c')); } $catsenabled = feature_enabled(local_channel(),'categories'); @@ -365,14 +371,12 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); - $tz = get_iconfig($rr, 'event', 'timezone'); - $events[] = array( 'calendar_id' => 'channel_calendar', 'rw' => true, 'id'=>$rr['id'], 'uri' => $rr['event_hash'], - 'timezone' => (($tz) ? $tz : 'UTC'), + 'timezone' => $tz, 'start'=> $start, 'end' => $end, 'drop' => $drop, -- cgit v1.2.3 From cade25a112d3884034090135db421dab805a93d6 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 22:01:44 +0200 Subject: Revert "more timezone changes" This reverts commit cec2e92fe381a5e4bb67426290303639dd260358 --- Zotlabs/Module/Channel_calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index c92e6ca1b..7d75a7e41 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -34,8 +34,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $adjust = intval($_POST['adjust']); - $start = datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtstart'])); - $finish = datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtend'])); + $start = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart'])); + $finish = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend'])); $summary = escape_tags(trim($_POST['summary'])); $desc = escape_tags(trim($_POST['desc'])); -- cgit v1.2.3 From 44b935f8756ea751371065f1edc4f6fab339ab3d Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 4 Apr 2020 15:41:58 +0000 Subject: another attempt to get events right --- Zotlabs/Module/Channel_calendar.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index 7d75a7e41..f83a0167d 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -16,7 +16,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller { if(! local_channel()) return; - + $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0); $event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : ''); @@ -32,10 +32,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $categories = escape_tags(trim($_POST['categories'])); + // allday events have adjust = 0, normal events have adjust = 1 $adjust = intval($_POST['adjust']); - $start = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart'])); - $finish = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend'])); + $start = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtstart'])); + $finish = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtend'])); $summary = escape_tags(trim($_POST['summary'])); $desc = escape_tags(trim($_POST['desc'])); @@ -337,21 +338,16 @@ class Channel_calendar extends \Zotlabs\Web\Controller { } $events = []; - + if($r) { foreach($r as $rr) { - $tz = get_iconfig($rr, 'event', 'timezone'); - - if(! $tz) - $tz = 'UTC'; - - $start = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c')); + $start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c')); if ($rr['nofinish']){ $end = null; } else { - $end = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c')); + $end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c')); } $catsenabled = feature_enabled(local_channel(),'categories'); @@ -371,6 +367,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); + $tz = get_iconfig($rr, 'event', 'timezone'); + + if(! $tz) + $tz = 'UTC'; + $events[] = array( 'calendar_id' => 'channel_calendar', 'rw' => true, -- cgit v1.2.3 From 67c9b5d04954012e062ee16619c1c8369582b670 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 06:47:12 +0000 Subject: fix unseen forum posts count --- Zotlabs/Module/Sse_bs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 90e870330..89e852120 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -399,7 +399,7 @@ class Sse_bs extends Controller { if($r) { $mids = flatten_array_recursive($r); - + $b64mids = []; foreach($mids as $mid) $b64mids[] = 'b64.' . base64url_encode($mid); -- cgit v1.2.3 From 84183d9f7ef669779841cfccd65aae8000012e6d Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 09:11:12 +0000 Subject: show event timezone only if adjust ist set and the offset of the event timezone is different from the channel default timezone offset --- Zotlabs/Module/Channel_calendar.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index f83a0167d..5d5fe300a 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -27,9 +27,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller { if(($xchan) && ($xchan !== get_observer_hash())) return; - $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); - $tz = (($timezone) ? $timezone : date_default_timezone_get()); - $categories = escape_tags(trim($_POST['categories'])); // allday events have adjust = 0, normal events have adjust = 1 @@ -38,6 +35,12 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $start = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtstart'])); $finish = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtend'])); + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); + $tz = (($timezone) ? $timezone : date_default_timezone_get()); + + if(! $adjust) + $tz = 'UTC'; + $summary = escape_tags(trim($_POST['summary'])); $desc = escape_tags(trim($_POST['desc'])); $location = escape_tags(trim($_POST['location'])); -- cgit v1.2.3 From a31981966e4916b6a40af0743f4dcb578511d239 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 09:29:23 +0000 Subject: fix warning if iconfig value is an array --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index c50606d4f..3c16a5367 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -512,7 +512,7 @@ class Activity { if ($item['iconfig']) { foreach ($item['iconfig'] as $att) { if ($att['sharing']) { - $value = ((preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']); + $value = ((is_string($att['v']) && preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']); $ret[] = [ 'type' => 'PropertyValue', 'name' => 'zot.' . $att['cat'] . '.' . $att['k'], 'value' => $value ]; } } -- cgit v1.2.3 From 530b1d038fbd35690acbff5a42eca3a4332d8593 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 11:19:12 +0000 Subject: fix mod import --- Zotlabs/Module/Import.php | 112 +++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 57 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 18cb5560e..87d4739f3 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -212,50 +212,21 @@ class Import extends \Zotlabs\Web\Controller { // create new hubloc for the new channel at this site if(array_key_exists('channel',$data)) { - $r = hubloc_store_lowlevel( - [ - 'hubloc_guid' => $channel['channel_guid'], - 'hubloc_guid_sig' => $channel['channel_guid_sig'], - 'hubloc_hash' => $channel['channel_hash'], - 'hubloc_addr' => channel_reddress($channel), - 'hubloc_network' => 'zot', - 'hubloc_primary' => (($seize) ? 1 : 0), - 'hubloc_url' => z_root(), - 'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])), - 'hubloc_host' => \App::get_hostname(), - 'hubloc_callback' => z_root() . '/post', - 'hubloc_sitekey' => get_config('system','pubkey'), - 'hubloc_updated' => datetime_convert() - ] - ); - - // reset the original primary hubloc if it is being seized - if($seize) { - $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ", - dbesc($channel['channel_hash']), - dbesc(z_root()) - ); - } - - // create a new zot6 hubloc if we have got a channel_portable_id if($channel['channel_portable_id']) { $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $channel['channel_guid'], - 'hubloc_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'hubloc_guid_sig' => $channel['channel_guid_sig'], 'hubloc_hash' => $channel['channel_portable_id'], 'hubloc_addr' => channel_reddress($channel), - 'hubloc_network' => 'zot6', + 'hubloc_network' => 'zot', 'hubloc_primary' => (($seize) ? 1 : 0), 'hubloc_url' => z_root(), - 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])), + 'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])), 'hubloc_host' => \App::get_hostname(), - 'hubloc_callback' => z_root() . '/zot', + 'hubloc_callback' => z_root() . '/post', 'hubloc_sitekey' => get_config('system','pubkey'), - 'hubloc_updated' => datetime_convert(), - 'hubloc_id_url' => channel_url($channel), - 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')) - + 'hubloc_updated' => datetime_convert() ] ); @@ -266,7 +237,35 @@ class Import extends \Zotlabs\Web\Controller { dbesc(z_root()) ); } + } + + // create a new zot6 hubloc if we have got a channel_portable_id + $r = hubloc_store_lowlevel( + [ + 'hubloc_guid' => $channel['channel_guid'], + 'hubloc_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'hubloc_hash' => $channel['channel_hash'], + 'hubloc_addr' => channel_reddress($channel), + 'hubloc_network' => 'zot6', + 'hubloc_primary' => (($seize) ? 1 : 0), + 'hubloc_url' => z_root(), + 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])), + 'hubloc_host' => \App::get_hostname(), + 'hubloc_callback' => z_root() . '/zot', + 'hubloc_sitekey' => get_config('system','pubkey'), + 'hubloc_updated' => datetime_convert(), + 'hubloc_id_url' => channel_url($channel), + 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')) + ] + ); + + // reset the original primary hubloc if it is being seized + if($seize) { + $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ", + dbesc($channel['channel_hash']), + dbesc(z_root()) + ); } } @@ -285,32 +284,12 @@ class Import extends \Zotlabs\Web\Controller { dbesc($channel['channel_portable_id']) ); - $r = xchan_store_lowlevel( - [ - 'xchan_hash' => $channel['channel_hash'], - 'xchan_guid' => $channel['channel_guid'], - 'xchan_guid_sig' => $channel['channel_guid_sig'], - 'xchan_pubkey' => $channel['channel_pubkey'], - 'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'], - 'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'], - 'xchan_photo_s' => z_root() . "/photo/profile/s/" . $channel['channel_id'], - 'xchan_addr' => channel_reddress($channel), - 'xchan_url' => z_root() . '/channel/' . $channel['channel_address'], - 'xchan_connurl' => z_root() . '/poco/' . $channel['channel_address'], - 'xchan_follow' => z_root() . '/follow?f=&url=%s', - 'xchan_name' => $channel['channel_name'], - 'xchan_network' => 'zot', - 'xchan_photo_date' => datetime_convert(), - 'xchan_name_date' => datetime_convert() - ] - ); - if($channel['channel_portable_id']) { $r = xchan_store_lowlevel( [ - 'xchan_hash' => \Zotlabs\Lib\Libzot::make_xchan_hash($channel['channel_guid'],$channel['channel_pubkey']), + 'xchan_hash' => $channel['channel_portable_id'], 'xchan_guid' => $channel['channel_guid'], - 'xchan_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'xchan_guid_sig' => $channel['channel_guid_sig'], 'xchan_pubkey' => $channel['channel_pubkey'], 'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'], 'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'], @@ -320,13 +299,32 @@ class Import extends \Zotlabs\Web\Controller { 'xchan_connurl' => z_root() . '/poco/' . $channel['channel_address'], 'xchan_follow' => z_root() . '/follow?f=&url=%s', 'xchan_name' => $channel['channel_name'], - 'xchan_network' => 'zot6', + 'xchan_network' => 'zot', 'xchan_photo_date' => datetime_convert(), 'xchan_name_date' => datetime_convert() ] ); } + $r = xchan_store_lowlevel( + [ + 'xchan_hash' => $channel['channel_hash'], + 'xchan_guid' => $channel['channel_guid'], + 'xchan_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'xchan_pubkey' => $channel['channel_pubkey'], + 'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'], + 'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'], + 'xchan_photo_s' => z_root() . "/photo/profile/s/" . $channel['channel_id'], + 'xchan_addr' => channel_reddress($channel), + 'xchan_url' => z_root() . '/channel/' . $channel['channel_address'], + 'xchan_connurl' => z_root() . '/poco/' . $channel['channel_address'], + 'xchan_follow' => z_root() . '/follow?f=&url=%s', + 'xchan_name' => $channel['channel_name'], + 'xchan_network' => 'zot6', + 'xchan_photo_date' => datetime_convert(), + 'xchan_name_date' => datetime_convert() + ] + ); } -- cgit v1.2.3 From ea237a97a16c35cc808d3f5a39139c94cc17cbaa Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 11:37:42 +0000 Subject: more mod import fixes --- Zotlabs/Module/Import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 87d4739f3..ef11e1778 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -244,7 +244,7 @@ class Import extends \Zotlabs\Web\Controller { $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $channel['channel_guid'], - 'hubloc_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'hubloc_guid_sig' => $channel['channel_guid_sig'], 'hubloc_hash' => $channel['channel_hash'], 'hubloc_addr' => channel_reddress($channel), 'hubloc_network' => 'zot6', @@ -310,7 +310,7 @@ class Import extends \Zotlabs\Web\Controller { [ 'xchan_hash' => $channel['channel_hash'], 'xchan_guid' => $channel['channel_guid'], - 'xchan_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'xchan_guid_sig' => $channel['channel_guid_sig'], 'xchan_pubkey' => $channel['channel_pubkey'], 'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'], 'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'], -- cgit v1.2.3 From cb2996a40cf86d727bfda2df86bdcc8d643b46da Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 15:00:08 +0000 Subject: another import fix and do not allow importing channels < version 4.7.4 for zot6 compatibility reasons --- Zotlabs/Module/Import.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index ef11e1778..2c6e09fa7 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -137,6 +137,11 @@ class Import extends \Zotlabs\Web\Controller { return; } + if(version_compare($data['compatibility']['version'], '4.7.3', '<=')) { + // zot6 transition: cloning is not compatible with older versions + notice('Data export format is not compatible with this software (not a zot6 channel)'); + return; + } if($moving) $seize = 1; @@ -344,7 +349,7 @@ class Import extends \Zotlabs\Web\Controller { } if($xchan['xchan_network'] === 'zot6') { - $zhash = \Zotlabs\Lib\Libzot::make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_pubkey']); + $zhash = Libzot::make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_pubkey']); if($zhash !== $xchan['xchan_hash']) { logger('forged xchan: ' . print_r($xchan,true)); continue; -- cgit v1.2.3 From af7a31cd1400a6b2f21e7c0a622ab448179f0ef8 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 6 Apr 2020 12:12:44 +0000 Subject: owa: look for zot6 first --- Zotlabs/Module/Owa.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index 89f83bf8f..4c6fd6216 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -33,11 +33,11 @@ class Owa extends \Zotlabs\Web\Controller { if($keyId) { - // Hubzilla connections can have both zot and zot6 hublocs - // The connections will usually be zot so match those first + // Hubzilla connections can have both zot6 and zot hublocs + // The connections will usually be zot6 so match those first $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash - where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) and hubloc_network = 'zot' ", + where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) and hubloc_network = 'zot6' ", dbesc(str_replace('acct:','',$keyId)), dbesc($keyId) ); -- cgit v1.2.3 From 3372fb0761353f646ae2b7bd168650eea5fd6211 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 8 Apr 2020 11:31:17 +0200 Subject: Fix process id disclouse --- Zotlabs/Daemon/Expire.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index f3f42df6f..a688d6f97 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -9,12 +9,14 @@ class Expire { cli_startup(); - if ($pid = get_config('expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { - logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); + $pid = get_config('expire', 'procid', false); + if ($pid && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { + logger('Expire: procedure already run with pid ' . $pid, LOGGER_DEBUG); return; } - set_config('expire', 'procid', getmypid()); + $pid = getmypid(); + set_config('expire', 'procid', $pid); // perform final cleanup on previously delete items @@ -39,7 +41,7 @@ class Expire { if (intval(get_config('system', 'optimize_items'))) q("optimize table item"); - logger('expire: start', LOGGER_DEBUG); + logger('expire: start with pid ' . $pid, LOGGER_DEBUG); $site_expire = intval(get_config('system', 'default_expire_days')); $commented_days = intval(get_config('system','active_expire_days')); -- cgit v1.2.3 From 9c2d48bcd4b8c5cb4efea1232ef3e52c1a0649c9 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 8 Apr 2020 12:20:44 +0000 Subject: update 1236: we have seen situations in the wild where a zot6 xchan was present while its hubloc was missing. fix those separately if required so that we cover both situations. --- Zotlabs/Update/_1236.php | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php index 6b4e7b299..e57338e16 100644 --- a/Zotlabs/Update/_1236.php +++ b/Zotlabs/Update/_1236.php @@ -61,6 +61,34 @@ class _1236 { xchan_store_lowlevel($rec); } + // Now try again + $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", + dbesc($guid) + ); + + if(! $xchan) { + logger('Could not create zot6 xchan record for: ' . $zot_xchan); + continue; + } + + } + + $zot6_xchan = $xchan[0]['xchan_hash']; + $zot6_xchan_guid_sig = $xchan[0]['xchan_guid_sig']; + + $hubloc = q("SELECT hubloc_hash FROM hubloc WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6'", + dbesc($guid), + dbesc(z_root()) + ); + + if(! $hubloc) { + // This should not actually happen. + // A local zot6 hubloc for every channel should have been + // created in update _1226. + + // In case this failed, we will try to fix it here. + logger('No local zot6 hubloc found for: ' . $rr['channel_hash']); + $h = q("SELECT * FROM hubloc WHERE hubloc_hash = '%s' AND hubloc_url = '%s' LIMIT 1", dbesc($zot_xchan), dbesc(z_root()) @@ -68,31 +96,23 @@ class _1236 { if($h) { $rec = $h[0]; - $rec['hubloc_hash'] = $zhash; + $rec['hubloc_hash'] = $zot6_xchan; $rec['hubloc_guid_sig'] = 'sha256.' . $rec['hubloc_guid_sig']; $rec['hubloc_network'] = 'zot6'; $rec['hubloc_url_sig'] = 'sha256.' . $rec['hubloc_url_sig']; $rec['hubloc_callback'] = z_root() . '/zot'; $rec['hubloc_id_url'] = channel_url($rr); $rec['hubloc_site_id'] = Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')); - hubloc_store_lowlevel($rec); - } - // Now try again - $xchan = q("SELECT xchan_hash, xchan_guid_sig FROM xchan WHERE xchan_guid = '%s' AND xchan_network = 'zot6'", - dbesc($guid) - ); + $hubloc = hubloc_store_lowlevel($rec); + } - if(!$xchan) { - logger('Could not create zot6 xchan record for: ' . $zot_xchan); + if(! $hubloc) { + logger('Could not create local zot6 hubloc record for: ' . $zot_xchan); continue; } - } - $zot6_xchan = $xchan[0]['xchan_hash']; - $zot6_xchan_guid_sig = $xchan[0]['xchan_guid_sig']; - logger('Transforming channel: ' . $zot_xchan); q("UPDATE channel SET channel_hash = '%s', channel_portable_id = '%s', channel_guid_sig = '%s' WHERE channel_hash = '%s'", dbesc($zot6_xchan), -- cgit v1.2.3 From 328685d2fbe505fd5b1bf9892a0cce993210ac52 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Apr 2020 09:38:36 +0000 Subject: move from build_sync_packet() to Libsync::build_sync_packet() --- Zotlabs/Daemon/Cron.php | 4 +++- Zotlabs/Daemon/Importfile.php | 4 +++- Zotlabs/Lib/Apps.php | 6 ++++-- Zotlabs/Lib/Chatroom.php | 4 +++- Zotlabs/Lib/NativeWiki.php | 4 +++- Zotlabs/Module/Channel_calendar.php | 8 +++++--- Zotlabs/Module/Chat.php | 6 ++---- Zotlabs/Module/Connedit.php | 5 +++-- Zotlabs/Module/Cover_photo.php | 6 ++++-- Zotlabs/Module/Defperms.php | 3 ++- Zotlabs/Module/File_upload.php | 6 ++++-- Zotlabs/Module/Filestorage.php | 4 ++-- Zotlabs/Module/Group.php | 3 ++- Zotlabs/Module/Like.php | 5 +++-- Zotlabs/Module/Moderate.php | 4 +++- Zotlabs/Module/Notes.php | 3 ++- Zotlabs/Module/Pconfig.php | 4 ++-- Zotlabs/Module/Pdledit.php | 3 ++- Zotlabs/Module/Permcats.php | 5 +++-- Zotlabs/Module/Photos.php | 10 ++++++---- Zotlabs/Module/Profile_photo.php | 8 +++++--- Zotlabs/Module/Profiles.php | 4 +++- Zotlabs/Module/Settings/Calendar.php | 3 ++- Zotlabs/Module/Settings/Channel.php | 3 ++- Zotlabs/Module/Settings/Channel_home.php | 4 +++- Zotlabs/Module/Settings/Connections.php | 3 ++- Zotlabs/Module/Settings/Conversation.php | 3 ++- Zotlabs/Module/Settings/Directory.php | 3 ++- Zotlabs/Module/Settings/Display.php | 3 ++- Zotlabs/Module/Settings/Editor.php | 3 ++- Zotlabs/Module/Settings/Events.php | 3 ++- Zotlabs/Module/Settings/Featured.php | 3 ++- Zotlabs/Module/Settings/Features.php | 4 +++- Zotlabs/Module/Settings/Manage.php | 4 +++- Zotlabs/Module/Settings/Network.php | 3 ++- Zotlabs/Module/Settings/Photos.php | 3 ++- Zotlabs/Module/Settings/Profiles.php | 4 +++- Zotlabs/Module/Share.php | 3 ++- Zotlabs/Module/Starred.php | 3 ++- Zotlabs/Module/Tagger.php | 4 +++- Zotlabs/Module/Thing.php | 8 +++++--- Zotlabs/Module/Wall_attach.php | 4 +++- Zotlabs/Storage/Directory.php | 9 +++++---- Zotlabs/Storage/File.php | 7 ++++--- 44 files changed, 127 insertions(+), 69 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index bd4e0b294..9cdfa9a0f 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -2,6 +2,8 @@ namespace Zotlabs\Daemon; +use Zotlabs\Lib\Libsync; + class Cron { static public function run($argc,$argv) { @@ -147,7 +149,7 @@ class Cron { if($z) { xchan_query($z); $sync_item = fetch_post_tags($z); - build_sync_packet($sync_item[0]['uid'], + Libsync::build_sync_packet($sync_item[0]['uid'], [ 'item' => [ encode_item($sync_item[0],true) ] ] diff --git a/Zotlabs/Daemon/Importfile.php b/Zotlabs/Daemon/Importfile.php index c68ed21cf..749949679 100644 --- a/Zotlabs/Daemon/Importfile.php +++ b/Zotlabs/Daemon/Importfile.php @@ -2,6 +2,8 @@ namespace Zotlabs\Daemon; +use Zotlabs\Lib\Libsync; + class Importfile { static public function run($argc,$argv){ @@ -40,7 +42,7 @@ class Importfile { $sync = attach_export_data($channel,$hash); if($sync) - build_sync_packet($channel['channel_id'],array('file' => array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); return; } diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 9d60e9eae..d65eed14f 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -2,6 +2,8 @@ namespace Zotlabs\Lib; +use Zotlabs\Lib\Libsync; + require_once('include/plugin.php'); require_once('include/channel.php'); @@ -603,7 +605,7 @@ class Apps { intval(TERM_OBJ_APP), intval($r[0]['id']) ); - build_sync_packet($uid,array('app' => $r[0])); + Libsync::build_sync_packet($uid,array('app' => $r[0])); } } } @@ -669,7 +671,7 @@ class Apps { ); } if(! intval($x[0]['app_system'])) { - build_sync_packet($uid,array('app' => $x)); + Libsync::build_sync_packet($uid,array('app' => $x)); } } else { diff --git a/Zotlabs/Lib/Chatroom.php b/Zotlabs/Lib/Chatroom.php index 882c846cd..34853b6ab 100644 --- a/Zotlabs/Lib/Chatroom.php +++ b/Zotlabs/Lib/Chatroom.php @@ -1,6 +1,8 @@ $r)); + Libsync::build_sync_packet($channel['channel_id'],array('chatroom' => $r)); q("delete from chatroom where cr_id = %d", intval($r[0]['cr_id']) diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 662fddad0..6bda76eee 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -2,6 +2,8 @@ namespace Zotlabs\Lib; +use Zotlabs\Lib\Libsync; + define ( 'NWIKI_ITEM_RESOURCE_TYPE', 'nwiki' ); class NativeWiki { @@ -178,7 +180,7 @@ class NativeWiki { foreach($sync_item as $w) { $pkt[] = encode_item($w,true); } - build_sync_packet($uid,array('wiki' => $pkt)); + Libsync::build_sync_packet($uid,array('wiki' => $pkt)); } } } diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index 5d5fe300a..ae4afb2f3 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -1,6 +1,8 @@ array(encode_item($sync_item[0],true)),'event' => $z)); + Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); } } } @@ -430,7 +432,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller { if($r) { $sync_event['event_deleted'] = 1; - build_sync_packet(0,array('event' => array($sync_event))); + Libsync::build_sync_packet(0,array('event' => array($sync_event))); $i = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d", dbesc($event_id), @@ -479,7 +481,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller { if($ii) { xchan_query($ii); $sync_item = fetch_post_tags($ii); - build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); } if($complex) { diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php index db77e2612..6a46cdace 100644 --- a/Zotlabs/Module/Chat.php +++ b/Zotlabs/Module/Chat.php @@ -7,9 +7,7 @@ use Zotlabs\Lib\Apps; use Zotlabs\Web\Controller; use Zotlabs\Lib\Chatroom; use Zotlabs\Access\AccessList; - - - +use Zotlabs\Lib\Libsync; require_once('include/bookmarks.php'); @@ -80,7 +78,7 @@ class Chat extends Controller { intval(local_channel()) ); - build_sync_packet(0, array('chatroom' => $x)); + Libsync::build_sync_packet(0, array('chatroom' => $x)); if($x) goaway(z_root() . '/chat/' . $channel['channel_address'] . '/' . $x[0]['cr_id']); diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index acd7cb769..c0df57390 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -9,6 +9,7 @@ namespace Zotlabs\Module; use Zotlabs\Lib\Apps; use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Libsync; require_once('include/socgraph.php'); require_once('include/selectors.php'); @@ -382,7 +383,7 @@ class Connedit extends \Zotlabs\Web\Controller { if($abconfig) $clone['abconfig'] = $abconfig; - build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); + Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); } /* @brief Generate content of connection edit page @@ -558,7 +559,7 @@ class Connedit extends \Zotlabs\Web\Controller { // PLACEHOLDER contact_remove(local_channel(), $orig_record[0]['abook_id']); - build_sync_packet(0 /* use the current local_channel */, + Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array(array( 'abook_xchan' => $orig_record[0]['abook_xchan'], 'entry_deleted' => true)) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index d97014f9c..615ca6fe0 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -1,6 +1,8 @@ array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); } // Update directory in background @@ -230,7 +232,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $sync = attach_export_data($channel,$base_image['resource_id']); if($sync) - build_sync_packet($channel['channel_id'],array('file' => array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); // Update directory in background \Zotlabs\Daemon\Master::Summon(array('Directory',$channel['channel_id'])); diff --git a/Zotlabs/Module/Defperms.php b/Zotlabs/Module/Defperms.php index 463ecb57a..f2f7c10e5 100644 --- a/Zotlabs/Module/Defperms.php +++ b/Zotlabs/Module/Defperms.php @@ -4,6 +4,7 @@ namespace Zotlabs\Module; use App; use Zotlabs\Lib\Apps; use Zotlabs\Web\Controller; +use Zotlabs\Lib\Libsync; require_once('include/socgraph.php'); require_once('include/selectors.php'); @@ -164,7 +165,7 @@ class Defperms extends Controller { if($abconfig) $clone['abconfig'] = $abconfig; - build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); + Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); } /* @brief Generate content of connection default permissions page diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 4d1cc4cda..1735e9487 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -1,6 +1,8 @@ array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); } goaway(z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['data']['display_path']); @@ -97,7 +99,7 @@ class File_upload extends \Zotlabs\Web\Controller { if($r['success']) { $sync = attach_export_data($channel,$r['data']['hash']); if($sync) - build_sync_packet($channel['channel_id'],array('file' => array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); } } diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index 2c247cd65..c40de2823 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -5,7 +5,7 @@ namespace Zotlabs\Module; * */ - +use Zotlabs\Lib\Libsync; class Filestorage extends \Zotlabs\Web\Controller { @@ -131,7 +131,7 @@ class Filestorage extends \Zotlabs\Web\Controller { if(! $admin_delete) { $sync = attach_export_data($channel, $f['hash'], true); if($sync) { - build_sync_packet($channel['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($channel['channel_id'], array('file' => array($sync))); } } diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php index f836978ee..993d428f5 100644 --- a/Zotlabs/Module/Group.php +++ b/Zotlabs/Module/Group.php @@ -4,6 +4,7 @@ namespace Zotlabs\Module; use App; use Zotlabs\Web\Controller; use Zotlabs\Lib\Apps; +use Zotlabs\Lib\Libsync; require_once('include/group.php'); @@ -80,7 +81,7 @@ class Group extends Controller { info( t('Privacy group updated.') . EOL ); - build_sync_packet(local_channel(),null,true); + Libsync::build_sync_packet(local_channel(),null,true); } goaway(z_root() . '/group/' . argv(1) . '/' . argv(2)); diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index e4636a4a6..61f73bfd5 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; use Zotlabs\Lib\Activity; +use Zotlabs\Lib\Libsync; require_once('include/security.php'); require_once('include/bbcode.php'); @@ -235,7 +236,7 @@ class Like extends \Zotlabs\Web\Controller { if($z) { $z[0]['deleted'] = 1; - build_sync_packet($ch[0]['channel_id'],array('likes' => $z)); + Libsync::build_sync_packet($ch[0]['channel_id'],array('likes' => $z)); q("delete from likes where id = %d", intval($z[0]['id']) @@ -566,7 +567,7 @@ class Like extends \Zotlabs\Web\Controller { dbesc($obj_id) ); if($r) - build_sync_packet($ch[0]['channel_id'],array('likes' => $r)); + Libsync::build_sync_packet($ch[0]['channel_id'],array('likes' => $r)); } diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index a7c98e05e..f1bff3c50 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module; +use Zotlabs\Lib\Libsync; + require_once('include/conversation.php'); @@ -77,7 +79,7 @@ class Moderate extends \Zotlabs\Web\Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); } if($action === 'approve') { \Zotlabs\Daemon\Master::Summon(array('Notifier', 'comment-new', $post_id)); diff --git a/Zotlabs/Module/Notes.php b/Zotlabs/Module/Notes.php index 7572f7420..b448cff83 100644 --- a/Zotlabs/Module/Notes.php +++ b/Zotlabs/Module/Notes.php @@ -4,6 +4,7 @@ namespace Zotlabs\Module; use App; use Zotlabs\Web\Controller; use Zotlabs\Lib\Apps; +use Zotlabs\Lib\Libsync; /** * @brief Notes Module controller. @@ -38,7 +39,7 @@ class Notes extends Controller { if((argc() > 1) && (argv(1) === 'sync')) { require_once('include/zot.php'); - build_sync_packet(); + Libsync::build_sync_packet(); } logger('notes saved.', LOGGER_DEBUG); diff --git a/Zotlabs/Module/Pconfig.php b/Zotlabs/Module/Pconfig.php index 06b94b34f..b2b5d4386 100644 --- a/Zotlabs/Module/Pconfig.php +++ b/Zotlabs/Module/Pconfig.php @@ -1,7 +1,7 @@ 2 && argv(2) === 'drop') { \Zotlabs\Lib\Permcat::delete(local_channel(),$name); - build_sync_packet(); + Libsync::build_sync_packet(); json_return_and_die([ 'success' => true ]); } diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 43c9f86ee..fae8c17f6 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1,6 +1,8 @@ array($sync))); + Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync))); } } @@ -189,7 +191,7 @@ class Photos extends \Zotlabs\Web\Controller { $sync = attach_export_data(\App::$data['channel'],$r[0]['resource_id'], true); if($sync) - build_sync_packet($page_owner_uid,array('file' => array($sync))); + Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync))); } elseif(is_site_admin()) { // If the admin deletes a photo, don't sync @@ -210,7 +212,7 @@ class Photos extends \Zotlabs\Web\Controller { $sync = attach_export_data(\App::$data['channel'],argv(2),true); if($sync) - build_sync_packet($page_owner_uid,array('file' => array($sync))); + Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync))); if(! ($_POST['desc'] && $_POST['newtag'])) goaway(z_root() . '/' . $_SESSION['photo_return']); @@ -420,7 +422,7 @@ class Photos extends \Zotlabs\Web\Controller { $sync = attach_export_data(\App::$data['channel'],$resource_id); if($sync) - build_sync_packet($page_owner_uid,array('file' => array($sync))); + Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync))); goaway(z_root() . '/' . $_SESSION['photo_return']); return; // NOTREACHED diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index a812ca210..d6c80b653 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -1,6 +1,8 @@ array($sync))); + Libsync:: build_sync_packet($channel['channel_id'],array('file' => array($sync))); } $_SESSION['reload_avatar'] = true; @@ -243,7 +245,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { $sync = attach_export_data($channel,$base_image['resource_id']); if($sync) - build_sync_packet($channel['channel_id'],array('file' => array($sync), 'profile' => $sync_profiles)); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync), 'profile' => $sync_profiles)); // Similarly, tell the nav bar to bypass the cache and update the avatar image. @@ -411,7 +413,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { $sync = attach_export_data($channel,$resource_id); if($sync) - build_sync_packet($channel['channel_id'],array('file' => array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); $_SESSION['reload_avatar'] = true; diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 33e7d8a9d..7deceabab 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -1,6 +1,8 @@ $r)); + Libsync::build_sync_packet(local_channel(),array('profile' => $r)); } $channel = \App::get_channel(); diff --git a/Zotlabs/Module/Settings/Calendar.php b/Zotlabs/Module/Settings/Calendar.php index 0298b412e..ab85eb450 100644 --- a/Zotlabs/Module/Settings/Calendar.php +++ b/Zotlabs/Module/Settings/Calendar.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Calendar { @@ -15,7 +16,7 @@ class Calendar { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index b0115d352..ab9b72490 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -3,6 +3,7 @@ namespace Zotlabs\Module\Settings; use Zotlabs\Lib\Apps; +use Zotlabs\Lib\Libsync; require_once('include/selectors.php'); @@ -286,7 +287,7 @@ class Channel { \Zotlabs\Daemon\Master::Summon(array('Directory',local_channel())); - build_sync_packet(); + Libsync::build_sync_packet(); if($email_changed && \App::$config['system']['register_policy'] == REGISTER_VERIFY) { diff --git a/Zotlabs/Module/Settings/Channel_home.php b/Zotlabs/Module/Settings/Channel_home.php index b6ecf4ff1..e8faa7fb2 100644 --- a/Zotlabs/Module/Settings/Channel_home.php +++ b/Zotlabs/Module/Settings/Channel_home.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; + require_once('include/menu.php'); class Channel_home { @@ -24,7 +26,7 @@ class Channel_home { $channel_menu = ((x($_POST['channel_menu'])) ? htmlspecialchars_decode(trim($_POST['channel_menu']),ENT_QUOTES) : ''); set_pconfig(local_channel(),'system','channel_menu',$channel_menu); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Connections.php b/Zotlabs/Module/Settings/Connections.php index cac357791..4369deb27 100644 --- a/Zotlabs/Module/Settings/Connections.php +++ b/Zotlabs/Module/Settings/Connections.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Connections { @@ -15,7 +16,7 @@ class Connections { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Conversation.php b/Zotlabs/Module/Settings/Conversation.php index 43e59a3c2..aa0ff6a7e 100644 --- a/Zotlabs/Module/Settings/Conversation.php +++ b/Zotlabs/Module/Settings/Conversation.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Conversation { @@ -15,7 +16,7 @@ class Conversation { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['aj']) { if($_POST['auto_update'] == 1) diff --git a/Zotlabs/Module/Settings/Directory.php b/Zotlabs/Module/Settings/Directory.php index 13fe6eb79..d1dd0677e 100644 --- a/Zotlabs/Module/Settings/Directory.php +++ b/Zotlabs/Module/Settings/Directory.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Directory { @@ -15,7 +16,7 @@ class Directory { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index 45d80e011..f553fc057 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Display { @@ -78,7 +79,7 @@ class Display { ); call_hooks('display_settings_post', $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); goaway(z_root() . '/settings/display' ); return; // NOTREACHED } diff --git a/Zotlabs/Module/Settings/Editor.php b/Zotlabs/Module/Settings/Editor.php index 5e7a9473a..cf6dd2807 100644 --- a/Zotlabs/Module/Settings/Editor.php +++ b/Zotlabs/Module/Settings/Editor.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Editor { @@ -15,7 +16,7 @@ class Editor { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Events.php b/Zotlabs/Module/Settings/Events.php index eb6dda99b..ab393c932 100644 --- a/Zotlabs/Module/Settings/Events.php +++ b/Zotlabs/Module/Settings/Events.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Events { @@ -15,7 +16,7 @@ class Events { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php index d5d740aff..d615e176c 100644 --- a/Zotlabs/Module/Settings/Featured.php +++ b/Zotlabs/Module/Settings/Featured.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Featured { @@ -10,7 +11,7 @@ class Featured { call_hooks('feature_settings_post', $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); return; } diff --git a/Zotlabs/Module/Settings/Features.php b/Zotlabs/Module/Settings/Features.php index 6a3ab104b..553ff0836 100644 --- a/Zotlabs/Module/Settings/Features.php +++ b/Zotlabs/Module/Settings/Features.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; + class Features { @@ -19,7 +21,7 @@ class Features { set_pconfig(local_channel(),'feature', $k, ''); } } - build_sync_packet(); + Libsync::build_sync_packet(); return; } diff --git a/Zotlabs/Module/Settings/Manage.php b/Zotlabs/Module/Settings/Manage.php index 9bae12022..cbc494cf8 100644 --- a/Zotlabs/Module/Settings/Manage.php +++ b/Zotlabs/Module/Settings/Manage.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; + class Manage { @@ -15,7 +17,7 @@ class Manage { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Network.php b/Zotlabs/Module/Settings/Network.php index ae02b06e9..9f5bdb2e5 100644 --- a/Zotlabs/Module/Settings/Network.php +++ b/Zotlabs/Module/Settings/Network.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Network { @@ -21,7 +22,7 @@ class Network { set_pconfig(local_channel(),'system','network_divmore_height', $network_divmore_height); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Photos.php b/Zotlabs/Module/Settings/Photos.php index 9edbaa929..8195d660b 100644 --- a/Zotlabs/Module/Settings/Photos.php +++ b/Zotlabs/Module/Settings/Photos.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; class Photos { @@ -15,7 +16,7 @@ class Photos { process_module_features_post(local_channel(), $features, $_POST); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Settings/Profiles.php b/Zotlabs/Module/Settings/Profiles.php index fb6abf664..67b03e04f 100644 --- a/Zotlabs/Module/Settings/Profiles.php +++ b/Zotlabs/Module/Settings/Profiles.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module\Settings; +use Zotlabs\Lib\Libsync; + require_once('include/selectors.php'); class Profiles { @@ -19,7 +21,7 @@ class Profiles { $profile_assign = ((x($_POST,'profile_assign')) ? notags(trim($_POST['profile_assign'])) : ''); set_pconfig(local_channel(),'system','profile_assign',$profile_assign); - build_sync_packet(); + Libsync::build_sync_packet(); if($_POST['rpath']) goaway($_POST['rpath']); diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php index a18a81937..c0db9978e 100644 --- a/Zotlabs/Module/Share.php +++ b/Zotlabs/Module/Share.php @@ -4,6 +4,7 @@ namespace Zotlabs\Module; use App; use Zotlabs\Daemon\Master; use Zotlabs\Lib\Activity; +use Zotlabs\Lib\Libsync; require_once('include/security.php'); @@ -124,7 +125,7 @@ class Share extends \Zotlabs\Web\Controller { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]); + Libsync::build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]); } Master::Summon([ 'Notifier','like',$post_id ]); diff --git a/Zotlabs/Module/Starred.php b/Zotlabs/Module/Starred.php index 8349ae25c..2d7063669 100644 --- a/Zotlabs/Module/Starred.php +++ b/Zotlabs/Module/Starred.php @@ -1,6 +1,7 @@ [ encode_item($sync_item[0],true) ] diff --git a/Zotlabs/Module/Tagger.php b/Zotlabs/Module/Tagger.php index e6e80dce3..4fbfb7070 100644 --- a/Zotlabs/Module/Tagger.php +++ b/Zotlabs/Module/Tagger.php @@ -1,6 +1,8 @@ [ encode_item($ret['activity'],true) ] ] diff --git a/Zotlabs/Module/Thing.php b/Zotlabs/Module/Thing.php index c3d8ff802..b065b0022 100644 --- a/Zotlabs/Module/Thing.php +++ b/Zotlabs/Module/Thing.php @@ -5,6 +5,8 @@ namespace Zotlabs\Module; +use Zotlabs\Lib\Libsync; + require_once('include/items.php'); require_once('include/security.php'); require_once('include/selectors.php'); @@ -124,7 +126,7 @@ class Thing extends \Zotlabs\Web\Controller { dbesc($term_hash) ); if($r) { - build_sync_packet(0, array('obj' => $r)); + Libsync::build_sync_packet(0, array('obj' => $r)); } return; @@ -180,7 +182,7 @@ class Thing extends \Zotlabs\Web\Controller { dbesc($hash) ); if($r) { - build_sync_packet(0, array('obj' => $r)); + Libsync::build_sync_packet(0, array('obj' => $r)); } if($activity) { @@ -353,7 +355,7 @@ class Thing extends \Zotlabs\Web\Controller { $r[0]['obj_deleted'] = 1; - build_sync_packet(0,array('obj' => $r)); + Libsync::build_sync_packet(0,array('obj' => $r)); return $o; } diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index e1088d18f..2c0eeec77 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -1,6 +1,8 @@ array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); } if($using_api) diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index ae36fc1c0..8cda75fd1 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -3,6 +3,7 @@ namespace Zotlabs\Storage; use Sabre\DAV; +use Zotlabs\Lib\Libsync; /** * @brief RedDirectory class. @@ -179,7 +180,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo if ($ch) { $sync = attach_export_data($ch, $this->folder_hash); if ($sync) - build_sync_packet($ch['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync))); } $this->red_path = $new_path; @@ -368,7 +369,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $sync = attach_export_data($c[0], $hash); if ($sync) - build_sync_packet($c[0]['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($c[0]['channel_id'], array('file' => array($sync))); } /** @@ -401,7 +402,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo logger('createDirectory: attach_export_data returns $sync:' . print_r($sync, true), LOGGER_DEBUG); if($sync) { - build_sync_packet($r[0]['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($r[0]['channel_id'], array('file' => array($sync))); } } else { @@ -432,7 +433,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo if ($ch) { $sync = attach_export_data($ch, $this->folder_hash, true); if ($sync) - build_sync_packet($ch['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync))); } } diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 36aff1e05..68edde166 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -3,6 +3,7 @@ namespace Zotlabs\Storage; use Sabre\DAV; +use Zotlabs\Lib\Libsync; /** * @brief This class represents a file in DAV. @@ -106,7 +107,7 @@ class File extends DAV\Node implements DAV\IFile { if($ch) { $sync = attach_export_data($ch,$this->data['hash']); if($sync) - build_sync_packet($ch['channel_id'],array('file' => array($sync))); + Libsync::build_sync_packet($ch['channel_id'],array('file' => array($sync))); } } @@ -254,7 +255,7 @@ class File extends DAV\Node implements DAV\IFile { $sync = attach_export_data($c[0],$this->data['hash']); if($sync) - build_sync_packet($c[0]['channel_id'],array('file' => array($sync))); + Libsync::build_sync_packet($c[0]['channel_id'],array('file' => array($sync))); } @@ -378,7 +379,7 @@ class File extends DAV\Node implements DAV\IFile { if($ch) { $sync = attach_export_data($ch, $this->data['hash'], true); if($sync) - build_sync_packet($ch['channel_id'], array('file' => array($sync))); + Libsync::build_sync_packet($ch['channel_id'], array('file' => array($sync))); } } } -- cgit v1.2.3 From 6de823b532fc526a321e6b2b4df2cdd6175b7eb7 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Apr 2020 08:59:42 +0000 Subject: discover_feed() does not exist yet --- Zotlabs/Lib/Connect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Connect.php b/Zotlabs/Lib/Connect.php index 5fc0e3fe1..caac30f7a 100644 --- a/Zotlabs/Lib/Connect.php +++ b/Zotlabs/Lib/Connect.php @@ -97,7 +97,7 @@ class Connect { $feeds = get_config('system','feed_contacts'); if (($feeds) && (in_array($protocol, [ '', 'feed', 'rss' ]))) { - $d = discover_feed($url); + $d = discover_by_url($url); } else { $result['message'] = t('Remote channel or protocol unavailable.'); -- cgit v1.2.3 From 31e1e9cbfb3ad74f8470c79cec2b1b21d3739117 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 12 Apr 2020 21:41:32 +0200 Subject: Remove unnecessary [summary] tag processing --- Zotlabs/Module/Item.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index fcc040e01..321089644 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -721,18 +721,18 @@ class Item extends Controller { // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - + /* if(strpos($body,'[/summary]') !== false) { - $match = ''; - $cnt = preg_match("/\[summary\](.*?)\[\/summary\]/ism",$body,$match); - if($cnt) { - $summary .= $match[1]; - } - $body_content = preg_replace("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/ism", '',$body); - $body = trim($body_content); - } - - $summary = cleanup_bbcode($summary); + $match = ''; + $cnt = preg_match("/\[summary\](.*?)\[\/summary\]/ism",$body,$match); + if($cnt) { + $summary .= $match[1]; + } + $body_content = preg_replace("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/ism", '',$body); + $body = trim($body_content); + } + */ + $summary = cleanup_bbcode($summary); $body = cleanup_bbcode($body); -- cgit v1.2.3 From bbca6be0f94625f541b0d985fe66df54fc8f4be2 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 12 Apr 2020 23:08:11 +0200 Subject: Update Item.php --- Zotlabs/Module/Item.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 321089644..cdfc3c9a8 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -721,17 +721,17 @@ class Item extends Controller { // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - /* + if(strpos($body,'[/summary]') !== false) { $match = ''; $cnt = preg_match("/\[summary\](.*?)\[\/summary\]/ism",$body,$match); if($cnt) { $summary .= $match[1]; } - $body_content = preg_replace("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/ism", '',$body); + $body_content = preg_replace("/\[summary\](.*?)\[\/summary\]/ism", '',$body); $body = trim($body_content); } - */ + $summary = cleanup_bbcode($summary); $body = cleanup_bbcode($body); -- cgit v1.2.3 From 9d0f71bfcbc0d1080a9f93590118046d326cae70 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Apr 2020 08:21:07 +0000 Subject: keychange and request packets via zot6 --- Zotlabs/Daemon/Notifier.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index d66079216..d3b0a6b14 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -672,15 +672,17 @@ class Notifier { $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } } - if($packet_type === 'keychange' && $hub['hubloc_network'] === 'zot') { + if($packet_type === 'keychange' && $hub['hubloc_network'] === 'zot6') { $pmsg = get_pconfig($channel['channel_id'],'system','keychange'); - $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); + $packet = Libzot::build_packet($channel, $packet_type, (($packet_recips) ? $packet_recips : null)); + // $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); + } - elseif($packet_type === 'request' && $hub['hubloc_network'] === 'zot') { + elseif($packet_type === 'request' && $hub['hubloc_network'] === 'zot6') { $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) - ); + $packet = Libzot::build_packet($channel, $packet_type, $env, ['message_id' => $request_message_id], 'activitystreams', $hub['hubloc_sitekey'], $hub['site_crypto']); + // $packet = zot_build_packet($channel,$packet_type,$env,$hub['hubloc_sitekey'],$hub['site_crypto'],$hash, array('message_id' => $request_message_id)); + } if($packet) { -- cgit v1.2.3 From b1f74f4ef470715144728bfd16d5f6b6a802046d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 15 Apr 2020 10:22:54 +0200 Subject: Remove unnecessary [summary] tag processing --- Zotlabs/Module/Item.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index fcc040e01..cdfc3c9a8 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -723,16 +723,16 @@ class Item extends Controller { // we may need virtual or template classes to implement the possible alternatives if(strpos($body,'[/summary]') !== false) { - $match = ''; - $cnt = preg_match("/\[summary\](.*?)\[\/summary\]/ism",$body,$match); - if($cnt) { - $summary .= $match[1]; - } - $body_content = preg_replace("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/ism", '',$body); - $body = trim($body_content); - } - - $summary = cleanup_bbcode($summary); + $match = ''; + $cnt = preg_match("/\[summary\](.*?)\[\/summary\]/ism",$body,$match); + if($cnt) { + $summary .= $match[1]; + } + $body_content = preg_replace("/\[summary\](.*?)\[\/summary\]/ism", '',$body); + $body = trim($body_content); + } + + $summary = cleanup_bbcode($summary); $body = cleanup_bbcode($body); -- cgit v1.2.3 From d6b9c8b93d5f04d986b1c9e61be9146d556f403a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Apr 2020 08:43:28 +0000 Subject: =?UTF-8?q?=C3=83fix=20php=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index dee7cda56..a5dd81d40 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -113,7 +113,7 @@ class ThreadItem { if(intval($item['item_private']) && ($item['owner']['xchan_network'] === 'activitypub')) { $recips = get_iconfig($item['parent'], 'activitypub', 'recips'); - if(! in_array($observer['xchan_url'], $recips['to'])) + if(! is_array($recips['to']) || ! in_array($observer['xchan_url'], $recips['to'])) $privacy_warning = true; } -- cgit v1.2.3 From 91cad21d332154eba17b21d3a2dd6a64d55d0a28 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Apr 2020 11:56:56 +0000 Subject: fetch the item for asld in Lib/Share. This probably fixes addons issue #146 --- Zotlabs/Lib/Share.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php index 3a2ab1783..f8b636c10 100644 --- a/Zotlabs/Lib/Share.php +++ b/Zotlabs/Lib/Share.php @@ -2,6 +2,7 @@ namespace Zotlabs\Lib; +use Zotlabs\Lib\Activity; class Share { @@ -54,7 +55,7 @@ class Share { if(! $this->item) return $obj; - $obj['asld'] = $this->item['mid']; + $obj['asld'] = Activity::fetch_item( [ 'id' => $this->item['mid'] ] ); $obj['type'] = $this->item['obj_type']; $obj['id'] = $this->item['mid']; $obj['content'] = $this->item['body']; -- cgit v1.2.3 From e588ea8a8b697605c40a13210ab2b4c485d45ade Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Apr 2020 15:39:33 +0000 Subject: fix notification filtering --- Zotlabs/Module/Sse_bs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 89e852120..c139fd19b 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -119,7 +119,7 @@ class Sse_bs extends Controller { $sql_extra2 = ''; if(self::$xchans) - $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) "; + $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") "; $item_normal = item_normal(); @@ -183,7 +183,7 @@ class Sse_bs extends Controller { $sql_extra2 = ''; if(self::$xchans) - $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) "; + $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") "; $item_normal = item_normal(); @@ -259,7 +259,7 @@ class Sse_bs extends Controller { $sql_extra2 = ''; if(self::$xchans) - $sql_extra2 = " AND (author_xchan IN (" . self::$xchans . ") OR owner_xchan IN (" . self::$xchans . ")) "; + $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") "; $item_normal = item_normal(); -- cgit v1.2.3 From f7e925beaad5b42e659977e33f2473ce9aa0bbac Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 16 Apr 2020 12:33:02 +0200 Subject: Revert "keychange and request packets via zot6" This reverts commit 9d0f71bfcbc0d1080a9f93590118046d326cae70 --- Zotlabs/Daemon/Notifier.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index d3b0a6b14..d66079216 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -672,17 +672,15 @@ class Notifier { $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } } - if($packet_type === 'keychange' && $hub['hubloc_network'] === 'zot6') { + if($packet_type === 'keychange' && $hub['hubloc_network'] === 'zot') { $pmsg = get_pconfig($channel['channel_id'],'system','keychange'); - $packet = Libzot::build_packet($channel, $packet_type, (($packet_recips) ? $packet_recips : null)); - // $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); - + $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } - elseif($packet_type === 'request' && $hub['hubloc_network'] === 'zot6') { + elseif($packet_type === 'request' && $hub['hubloc_network'] === 'zot') { $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); - $packet = Libzot::build_packet($channel, $packet_type, $env, ['message_id' => $request_message_id], 'activitystreams', $hub['hubloc_sitekey'], $hub['site_crypto']); - // $packet = zot_build_packet($channel,$packet_type,$env,$hub['hubloc_sitekey'],$hub['site_crypto'],$hash, array('message_id' => $request_message_id)); - + $packet = zot_build_packet($channel,$packet_type,$env,$hub['hubloc_sitekey'],$hub['site_crypto'], + $hash, array('message_id' => $request_message_id) + ); } if($packet) { -- cgit v1.2.3 From 223c4c7b9a01f70106e0ae0b72da4a13235af56c Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Apr 2020 09:23:48 +0000 Subject: implement addressing and fix conversation fetching --- Zotlabs/Lib/Activity.php | 210 +++++++++++++++++++++++++++++++++++++++++------ Zotlabs/Module/Item.php | 82 +++++------------- 2 files changed, 208 insertions(+), 84 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 3c16a5367..2ba693049 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -419,7 +419,71 @@ class Activity { $ret['attachment'] = $a; } + $public = (($i['item_private']) ? false : true); + $top_level = (($i['mid'] === $i['parent_mid']) ? true : false); + + if ($public) { + $ret['to'] = [ ACTIVITY_PUBLIC_INBOX ]; + $ret['cc'] = [ z_root() . '/followers/' . substr($i['author']['xchan_addr'],0,strpos($i['author']['xchan_addr'],'@')) ]; + } + else { + + // private activity + + if ($top_level) { + $ret['to'] = self::map_acl($i); + } + else { + $ret['to'] = []; + if ($ret['tag']) { + foreach ($ret['tag'] as $mention) { + if (is_array($mention) && array_key_exists('href',$mention) && $mention['href']) { + $h = q("select * from hubloc where hubloc_id_url = '%s' limit 1", + dbesc($mention['href']) + ); + if ($h) { + if ($h[0]['hubloc_network'] === 'activitypub') { + $addr = $h[0]['hubloc_hash']; + } + else { + $addr = $h[0]['hubloc_id_url']; + } + if (! in_array($addr,$ret['to'])) { + $ret['to'][] = $addr; + } + } + } + } + } + $d = q("select hubloc.* from hubloc left join item on hubloc_hash = owner_xchan where item.id = %d limit 1", + intval($i['parent']) + ); + if ($d) { + if ($d[0]['hubloc_network'] === 'activitypub') { + $addr = $d[0]['hubloc_hash']; + } + else { + $addr = $d[0]['hubloc_id_url']; + } + if (! in_array($addr,$ret['to'])) { + $ret['cc'][] = $addr; + } + } + } + } + + $mentions = self::map_mentions($i); + if (count($mentions) > 0) { + if (! $ret['to']) { + $ret['to'] = $mentions; + } + else { + $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions))); + } + } + return $ret; + } static function decode_taxonomy($item) { @@ -756,57 +820,155 @@ class Activity { return []; } + $t = self::encode_taxonomy($i); + if ($t) { + $ret['tag'] = $t; + } + + // addressing madness + + $public = (($i['item_private']) ? false : true); + $top_level = (($reply) ? false : true); + + if ($public) { + $ret['to'] = [ ACTIVITY_PUBLIC_INBOX ]; + $ret['cc'] = [ z_root() . '/followers/' . substr($i['author']['xchan_addr'],0,strpos($i['author']['xchan_addr'],'@')) ]; + } + else { + + // private activity + + if ($top_level) { + $ret['to'] = self::map_acl($i); + } + else { + $ret['to'] = []; + if ($ret['tag']) { + foreach ($ret['tag'] as $mention) { + if (is_array($mention) && array_key_exists('href',$mention) && $mention['href']) { + $h = q("select * from hubloc where hubloc_id_url = '%s' limit 1", + dbesc($mention['href']) + ); + if ($h) { + if ($h[0]['hubloc_network'] === 'activitypub') { + $addr = $h[0]['hubloc_hash']; + } + else { + $addr = $h[0]['hubloc_id_url']; + } + if (! in_array($addr,$ret['to'])) { + $ret['to'][] = $addr; + } + } + } + } + } + + $d = q("select hubloc.* from hubloc left join item on hubloc_hash = owner_xchan where item.id = %d limit 1", + intval($i['parent']) + ); + if ($d) { + if ($d[0]['hubloc_network'] === 'activitypub') { + $addr = $d[0]['hubloc_hash']; + } + else { + $addr = $d[0]['hubloc_id_url']; + } + if (! in_array($addr,$ret['to'])) { + $ret['cc'][] = $addr; + } + } + } + } + + $mentions = self::map_mentions($i); + if (count($mentions) > 0) { + if (! $ret['to']) { + $ret['to'] = $mentions; + } + else { + $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions))); + } + } + return $ret; } + // Returns an array of URLS for any mention tags found in the item array $i. + static function map_mentions($i) { - if(! $i['term']) { + + if (! $i['term']) { return []; } $list = []; foreach ($i['term'] as $t) { - if($t['ttype'] == TERM_MENTION) { - $list[] = $t['url']; + if (! $t['url']) { + continue; + } + if ($t['ttype'] == TERM_MENTION) { + $url = self::lookup_term_url($t['url']); + $list[] = (($url) ? $url : $t['url']); } } return $list; } - static function map_acl($i,$mentions = false) { + // Returns an array of all recipients targeted by private item array $i. - $private = false; - $list = []; - $x = collect_recipients($i,$private); - if($x) { - stringify_array_elms($x); - if(! $x) - return; - - $strict = (($mentions) ? true : get_config('activitypub','compliance')); + static function map_acl($i) { + $ret = []; - $sql_extra = (($strict) ? " and xchan_network = 'activitypub' " : ''); + if (! $i['item_private']) { + return $ret; + } - $details = q("select xchan_url, xchan_addr, xchan_name from xchan where xchan_hash in (" . implode(',',$x) . ") $sql_extra"); + if ($i['allow_gid']) { + $tmp = expand_acl($i['allow_gid']); + if ($tmp) { + foreach ($tmp as $t) { + $ret[] = z_root() . '/lists/' . $t; + } + } + } - if($details) { - foreach($details as $d) { - if($mentions) { - $list[] = [ 'type' => 'Mention', 'href' => $d['xchan_url'], 'name' => '@' . (($d['xchan_addr']) ? $d['xchan_addr'] : $d['xchan_name']) ]; - } - else { - $list[] = $d['xchan_url']; + if ($i['allow_cid']) { + $tmp = expand_acl($i['allow_cid']); + $list = stringify_array($tmp,true); + if ($list) { + $details = q("select hubloc_id_url from hubloc where hubloc_hash in (" . $list . ") "); + if ($details) { + foreach ($details as $d) { + $ret[] = $d['hubloc_id_url']; } } } } - return $list; - + return $ret; } + static function lookup_term_url($url) { + + // The xchan_url for mastodon is a text/html rendering. This is called from map_mentions where we need + // to convert the mention url to an ActivityPub id. If this fails for any reason, return the url we have + + $r = q("select * from hubloc where hubloc_id_url = '%s' limit 1", + dbesc($url) + ); + + if ($r) { + if ($r[0]['hubloc_network'] === 'activitypub') { + return $r[0]['hubloc_hash']; + } + return $r[0]['hubloc_id_url']; + } + + return $url; + } static function encode_person($p, $extended = true) { diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index cdfc3c9a8..9002b708d 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -43,9 +43,11 @@ class Item extends Controller { if (Libzot::is_zot_request()) { + $conversation = false; + $item_id = argv(1); - if (! $item_id) + if(! $item_id) http_status_exit(404, 'Not found'); $portable_id = EMPTY_STR; @@ -66,32 +68,24 @@ class Item extends Controller { // process an authenticated fetch - $sigdata = HTTPSig::verify(EMPTY_STR); - if($sigdata['portable_id'] && $sigdata['header_valid']) { + $sigdata = HTTPSig::verify(($_SERVER['REQUEST_METHOD'] === 'POST') ? file_get_contents('php://input') : EMPTY_STR); + if ($sigdata['portable_id'] && $sigdata['header_valid']) { $portable_id = $sigdata['portable_id']; + if (! check_channelallowed($portable_id)) { + http_status_exit(403, 'Permission denied'); + } + if (! check_siteallowed($sigdata['signer'])) { + http_status_exit(403, 'Permission denied'); + } observer_auth($portable_id); - // first see if we have a copy of this item's parent owned by the current signer - // include xchans for all zot-like networks - these will have the same guid and public key - - $x = q("select * from xchan where xchan_hash = '%s'", - dbesc($sigdata['portable_id']) + $i = q("select id as item_id from item where mid = '%s' $item_normal and owner_xchan = '%s' limit 1", + dbesc($r[0]['parent_mid']), + dbesc($portable_id) ); - - if ($x) { - $xchans = q("select xchan_hash from xchan where xchan_hash = '%s' OR ( xchan_guid = '%s' AND xchan_pubkey = '%s' ) ", - dbesc($sigdata['portable_id']), - dbesc($x[0]['xchan_guid']), - dbesc($x[0]['xchan_pubkey']) - ); - - if ($xchans) { - $hashes = ids_to_querystr($xchans,'xchan_hash',true); - $i = q("select id as item_id from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1", - dbesc($r[0]['parent_mid']) - ); - } - } + } + elseif (Config::get('system','require_authenticated_fetch',false)) { + http_status_exit(403,'Permission denied'); } // if we don't have a parent id belonging to the signer see if we can obtain one as a visitor that we have permission to access @@ -111,7 +105,7 @@ class Item extends Controller { $parents_str = ids_to_querystr($i,'item_id'); - $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal ", + $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal order by item.id asc", dbesc($parents_str) ); @@ -122,43 +116,10 @@ class Item extends Controller { xchan_query($items,true); $items = fetch_post_tags($items,true); - $observer = App::get_observer(); - $parent = $items[0]; - $recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'],'activitypub','recips', []) : []); - $to = (($recips && array_key_exists('to',$recips) && is_array($recips['to'])) ? $recips['to'] : null); - $nitems = []; - foreach($items as $i) { - - $mids = []; - - if(intval($i['item_private'])) { - if(! $observer) { - continue; - } - // ignore private reshare, possibly from hubzilla - if($i['verb'] === 'Announce') { - if(! in_array($i['thr_parent'],$mids)) { - $mids[] = $i['thr_parent']; - } - continue; - } - // also ignore any children of the private reshares - if(in_array($i['thr_parent'],$mids)) { - continue; - } - - if((! $to) || (! in_array($observer['xchan_url'],$to))) { - continue; - } - - } - $nitems[] = $i; - } - - if(! $nitems) + if(! $items) http_status_exit(404, 'Not found'); - $chan = channelx_by_n($nitems[0]['uid']); + $chan = channelx_by_n($items[0]['uid']); if(! $chan) http_status_exit(404, 'Not found'); @@ -166,7 +127,8 @@ class Item extends Controller { if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream')) http_status_exit(403, 'Forbidden'); - $i = Activity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection'); + + $i = Activity::encode_item_collection($items, 'conversation/' . $item_id, 'OrderedCollection'); if($portable_id) { ThreadListener::store(z_root() . '/item/' . $item_id,$portable_id); } -- cgit v1.2.3 From 3d5fdd086be63bb8e9a889bfe593b3aaa4b4a6a2 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Apr 2020 11:30:19 +0000 Subject: only return hublocs with hubloc_id_url set --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 2ba693049..24214072a 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -939,7 +939,7 @@ class Activity { $tmp = expand_acl($i['allow_cid']); $list = stringify_array($tmp,true); if ($list) { - $details = q("select hubloc_id_url from hubloc where hubloc_hash in (" . $list . ") "); + $details = q("select hubloc_id_url from hubloc where hubloc_hash in (" . $list . ") and hubloc_id_url != ''"); if ($details) { foreach ($details as $d) { $ret[] = $d['hubloc_id_url']; -- cgit v1.2.3 From 4cfc0b1a6410193b65673c5d43180aa9cecaeea2 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Apr 2020 12:19:34 +0000 Subject: de-duplicate $post_tags --- Zotlabs/Lib/Activity.php | 2 +- Zotlabs/Module/Item.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 24214072a..5882a0777 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -890,7 +890,7 @@ class Activity { $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions))); } } - +hz_syslog(print_r($ret,true)); return $ret; } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9002b708d..6de8fe89f 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -721,6 +721,7 @@ class Item extends Controller { ); } } + } if(($str_contact_allow) && (! $str_group_allow)) { @@ -1017,10 +1018,9 @@ class Item extends Controller { $datarray['layout_mid'] = $layout_mid; $datarray['public_policy'] = $public_policy; $datarray['comment_policy'] = map_scope($comment_policy); - $datarray['term'] = $post_tags; + $datarray['term'] = array_unique($post_tags, SORT_REGULAR); $datarray['plink'] = $plink; $datarray['route'] = $route; - // A specific ACL over-rides public_policy completely -- cgit v1.2.3 From 602ca91700fa314265b4f65a04465347e68f53db Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Apr 2020 13:17:37 +0000 Subject: remove debug code --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 5882a0777..24214072a 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -890,7 +890,7 @@ class Activity { $ret['to'] = array_values(array_unique(array_merge($ret['to'], $mentions))); } } -hz_syslog(print_r($ret,true)); + return $ret; } -- cgit v1.2.3 From c7fdc5379595d8829f916032c73f3126abfd37b4 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Apr 2020 13:59:30 +0000 Subject: more do not include hublocs with no hubloc_id_url --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 24214072a..f3421c3fa 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -956,7 +956,7 @@ class Activity { // The xchan_url for mastodon is a text/html rendering. This is called from map_mentions where we need // to convert the mention url to an ActivityPub id. If this fails for any reason, return the url we have - $r = q("select * from hubloc where hubloc_id_url = '%s' limit 1", + $r = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_id_url != '' limit 1", dbesc($url) ); -- cgit v1.2.3 From 109f9eed611949bdd1d03183e8e05d1236a38ac7 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Apr 2020 14:09:08 +0000 Subject: just fetch the info we need --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index f3421c3fa..f80f71a74 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -956,7 +956,7 @@ class Activity { // The xchan_url for mastodon is a text/html rendering. This is called from map_mentions where we need // to convert the mention url to an ActivityPub id. If this fails for any reason, return the url we have - $r = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_id_url != '' limit 1", + $r = q("select hubloc_network, hubloc_hash, hubloc_id_url from hubloc where hubloc_id_url = '%s' and hubloc_id_url != '' limit 1", dbesc($url) ); -- cgit v1.2.3 From 42631b5943551d025c95e0b76e85471f4bde7101 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Apr 2020 14:22:40 +0000 Subject: revert --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index f80f71a74..613f939ab 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -956,7 +956,7 @@ class Activity { // The xchan_url for mastodon is a text/html rendering. This is called from map_mentions where we need // to convert the mention url to an ActivityPub id. If this fails for any reason, return the url we have - $r = q("select hubloc_network, hubloc_hash, hubloc_id_url from hubloc where hubloc_id_url = '%s' and hubloc_id_url != '' limit 1", + $r = q("select hubloc_network, hubloc_hash, hubloc_id_url from hubloc where hubloc_id_url = '%s' limit 1", dbesc($url) ); -- cgit v1.2.3 From ecb1c78173466b80660f56d95539e0d358e71cd4 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 19 Apr 2020 14:17:00 +0000 Subject: make sure $post_tags is defined somewhere outsite a clause to prevent PHP warnings --- Zotlabs/Module/Item.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 6de8fe89f..83f99eecd 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -674,6 +674,8 @@ class Item extends Controller { $str_group_allow = $gacl['allow_gid']; $str_contact_deny = $gacl['deny_cid']; $str_group_deny = $gacl['deny_gid']; + + $post_tags = []; if($mimetype === 'text/bbcode') { @@ -708,7 +710,6 @@ class Item extends Controller { // Set permissions based on tag replacements set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private); - $post_tags = array(); foreach($results as $result) { $success = $result['success']; if($success['replaced']) { -- cgit v1.2.3 From f430a24fa38ea9d47d2916243e33d61b08f50f0f Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 19 Apr 2020 14:24:52 +0000 Subject: missing lib import --- Zotlabs/Module/Item.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 83f99eecd..aa81c11e7 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; +use Zotlabs\Lib\Config; use Zotlabs\Lib\IConfig; use Zotlabs\Lib\Enotify; use Zotlabs\Web\Controller; -- cgit v1.2.3 From 244936b0fd3ac60defa9fa6042e6ee3be869721c Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Apr 2020 09:34:00 +0000 Subject: some work on improving federation of item_private and make sure we deal with an array in array_path_exists() --- Zotlabs/Lib/Activity.php | 9 +++++++-- Zotlabs/Lib/ActivityStreams.php | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 613f939ab..322579610 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2339,8 +2339,13 @@ class Activity { $s['plink'] = $s['mid']; } - if ($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips))) - $s['item_private'] = 1; + // assume this is private unless specifically told otherwise. + + $s['item_private'] = 1; + + if ($act->recips && in_array(ACTIVITY_PUBLIC_INBOX, $act->recips)) { + $s['item_private'] = 0; + } if (is_array($act->obj)) { if (array_key_exists('directMessage',$act->obj) && intval($act->obj['directMessage'])) { diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index d8bd72943..b1ef59364 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -146,15 +146,20 @@ class ActivityStreams { */ function collect_recips($base = '', $namespace = '') { $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); - if(! is_array($this->raw_recips)) + if (! is_array($this->raw_recips)) { $this->raw_recips = []; + } - $this->raw_recips[$f] = $x; + if (! is_array($y)) { + $y = [ $y ]; + } + $this->raw_recips[$f] = $y; + $x = array_merge($x, $y); } } // not yet ready for prime time @@ -411,4 +416,4 @@ class ActivityStreams { } -} \ No newline at end of file +} -- cgit v1.2.3 From 03506bd6cf70719819f35a4979a759a7afee7eab Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Apr 2020 11:58:08 +0000 Subject: use $mid as plink to prevent to long plinks --- Zotlabs/Module/Activity.php | 2 ++ Zotlabs/Module/Item.php | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Activity.php b/Zotlabs/Module/Activity.php index 93b5a15fc..9971ee60f 100644 --- a/Zotlabs/Module/Activity.php +++ b/Zotlabs/Module/Activity.php @@ -170,6 +170,8 @@ class Activity extends Controller { } + goaway(z_root() . '/item/' . argv(1)); + } } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index aa81c11e7..95359ccad 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -157,8 +157,9 @@ class Item extends Controller { } if(argc() > 1 && argv(1) !== 'drop') { - $x = q("select uid, item_wall, llink, mid from item where mid = '%s' ", - dbesc(z_root() . '/item/' . argv(1)) + $x = q("select uid, item_wall, llink, mid from item where mid = '%s' or mid = '%s' ", + dbesc(z_root() . '/item/' . argv(1)), + dbesc(z_root() . '/activity/' . argv(1)) ); if($x) { foreach($x as $xv) { @@ -955,8 +956,9 @@ class Item extends Controller { } if ((! $plink) && ($item_thread_top)) { - $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . gen_link_id($mid); - $plink = substr($plink,0,190); + // $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . gen_link_id($mid); + // $plink = substr($plink,0,190); + $plink = $mid; } if ($datarray['obj']) { -- cgit v1.2.3 From 579adb48978172ae26f8cb1c724b8b17a6a37b34 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Apr 2020 09:42:40 +0000 Subject: fix onepoll --- Zotlabs/Daemon/Onepoll.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index 2f06ec125..fdcb907d1 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -76,7 +76,11 @@ class Onepoll { // update permissions - $x = zot_refresh($contact,$importer); + if($contact['xchan_network'] === 'zot6') + $x = Libzot::refresh($contact,$importer); + + if($contact['xchan_network'] === 'zot') + $x = zot_refresh($contact,$importer); $responded = false; $updated = datetime_convert(); -- cgit v1.2.3 From 88eb19165b2cb9655e47d9ca8d5324a6e00dcf36 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 22 Apr 2020 18:15:02 +0000 Subject: the parent id is required later in the process --- Zotlabs/Module/Display.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 777d183e1..f45f37001 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -101,7 +101,7 @@ class Display extends \Zotlabs\Web\Controller { if($decoded) $item_hash = $decoded; - $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid like '%s' limit 1", + $r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid like '%s' limit 1", dbesc($item_hash . '%') ); @@ -159,14 +159,17 @@ class Display extends \Zotlabs\Web\Controller { } } if($target_item['item_type'] == ITEM_TYPE_CARD) { + $x = q("select * from channel where channel_id = %d limit 1", intval($target_item['uid']) ); + $y = q("select * from iconfig left join item on iconfig.iid = item.id where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'CARD' and item.id = %d limit 1", intval($target_item['uid']), intval($target_item['parent']) ); + if($x && $y) { goaway(z_root() . '/cards/' . $x[0]['channel_address'] . '/' . $y[0]['v']); } -- cgit v1.2.3 From b7a655917ed1f7caa5b8b3d9b92fdd578c6252c4 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Apr 2020 18:19:25 +0000 Subject: some work on deprecating ACTIVITY_OBJ_FILE --- Zotlabs/Lib/Activity.php | 11 +++++++---- Zotlabs/Lib/Enotify.php | 3 +++ Zotlabs/Lib/NativeWiki.php | 2 +- Zotlabs/Module/Sharedwithme.php | 5 ++++- Zotlabs/Module/Sse_bs.php | 8 +++++--- 5 files changed, 20 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 322579610..9b79190bb 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1131,7 +1131,6 @@ class Activity { 'http://activitystrea.ms/schema/1.0/photo' => 'Image', 'http://activitystrea.ms/schema/1.0/profile-photo' => 'Icon', 'http://activitystrea.ms/schema/1.0/event' => 'Event', - 'http://activitystrea.ms/schema/1.0/wiki' => 'Document', 'http://purl.org/zot/activity/location' => 'Place', 'http://purl.org/zot/activity/chessgame' => 'Game', 'http://purl.org/zot/activity/tagterm' => 'zot:Tag', @@ -1139,7 +1138,10 @@ class Activity { 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', 'Invite' => 'Invite', - 'Question' => 'Question' + 'Question' => 'Question', + 'Document' => 'Document', + 'Audio' => 'Audio', + 'Video' => 'Video' ]; call_hooks('activity_obj_decode_mapper',$objs); @@ -1167,7 +1169,6 @@ class Activity { 'http://activitystrea.ms/schema/1.0/photo' => 'Image', 'http://activitystrea.ms/schema/1.0/profile-photo' => 'Icon', 'http://activitystrea.ms/schema/1.0/event' => 'Event', - 'http://activitystrea.ms/schema/1.0/wiki' => 'Document', 'http://purl.org/zot/activity/location' => 'Place', 'http://purl.org/zot/activity/chessgame' => 'Game', 'http://purl.org/zot/activity/tagterm' => 'zot:Tag', @@ -1175,7 +1176,9 @@ class Activity { 'http://purl.org/zot/activity/file' => 'zot:File', 'http://purl.org/zot/activity/mood' => 'zot:Mood', 'Invite' => 'Invite', - 'Question' => 'Question' + 'Question' => 'Question', + 'Audio' => 'Audio', + 'Video' => 'Video' ]; call_hooks('activity_obj_mapper',$objs); diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 85e90d67c..a4fc8aa75 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -818,6 +818,9 @@ class Enotify { $itemem_text = sprintf( t('repeated %s\'s post'), '[bdi]' . $item['author']['xchan_name'] . '[/bdi]'); } + if(in_array($item['obj_type'], ['Document', 'Video', 'Audio', 'Image'])) { + $itemem_text = t('shared a file with you'); + } } $edit = false; diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 6bda76eee..3ec032075 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -73,7 +73,7 @@ class NativeWiki { $arr['item_thread_top'] = 1; $arr['item_private'] = intval($acl->is_private()); $arr['verb'] = ACTIVITY_CREATE; - $arr['obj_type'] = ACTIVITY_OBJ_WIKI; + $arr['obj_type'] = 'Document'; $arr['body'] = '[table][tr][td][h1]New Wiki[/h1][/td][/tr][tr][td][zrl=' . $wiki_url . ']' . $wiki['htmlName'] . '[/zrl][/td][/tr][/table]'; $arr['public_policy'] = map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_wiki'),true); diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php index c986f6695..f9d242dd3 100644 --- a/Zotlabs/Module/Sharedwithme.php +++ b/Zotlabs/Module/Sharedwithme.php @@ -1,5 +1,8 @@ '%s' $item_normal @@ -448,19 +451,18 @@ class Sse_bs extends Controller { $r = q("SELECT * FROM item WHERE verb = '%s' - AND obj_type = '%s' + AND obj_type in ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' AND item_unseen = 1", dbesc(ACTIVITY_POST), - dbesc(ACTIVITY_OBJ_FILE), intval(self::$uid), dbesc(self::$ob_hash) ); if($r) { xchan_query($r); foreach($r as $rr) { - $result['files']['notifications'][] = Enotify::format_files($rr); + $result['files']['notifications'][] = Enotify::format($rr); } $result['files']['count'] = count($r); } -- cgit v1.2.3 From 2b8afd55800754aeb158d77940777ecc2c119d37 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Apr 2020 19:38:19 +0000 Subject: fix file notifications --- Zotlabs/Module/Sse_bs.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index e4394fe33..290c616a9 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -449,12 +449,15 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + $item_normal = item_normal(); + $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type in ('Document', 'Video', 'Audio', 'Image') AND uid = %d - AND owner_xchan != '%s' - AND item_unseen = 1", + AND author_xchan != '%s' + AND item_unseen = 1 + $item_normal", dbesc(ACTIVITY_POST), intval(self::$uid), dbesc(self::$ob_hash) -- cgit v1.2.3 From e2b10f52e02c4cee77af089a544ec55e62048aba Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 24 Apr 2020 14:25:49 +0000 Subject: more work on deprecating ACTIVITY_OBJ_FILE and adapt mod sharedwithme --- Zotlabs/Daemon/Cron.php | 5 --- Zotlabs/Module/Sharedwithme.php | 94 ++++++++++++++++++++++++----------------- Zotlabs/Module/Sse_bs.php | 5 ++- 3 files changed, 58 insertions(+), 46 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index 9cdfa9a0f..46f4e4071 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -38,11 +38,6 @@ class Cron { Master::Summon(array('Poller')); - // maintenance for mod sharedwithme - check for updated items and remove them - - require_once('include/sharedwithme.php'); - apply_updates(); - /** * Chatpresence: if somebody hasn't pinged recently, they've most likely left the page * and shouldn't count as online anymore. We allow an expection for bots. diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php index f9d242dd3..4211a3af8 100644 --- a/Zotlabs/Module/Sharedwithme.php +++ b/Zotlabs/Module/Sharedwithme.php @@ -23,81 +23,80 @@ class Sharedwithme extends Controller { $channel = \App::get_channel(); $is_owner = (local_channel() && (local_channel() == $channel['channel_id'])); - - //check for updated items and remove them - require_once('include/sharedwithme.php'); - apply_updates(); + + $item_normal = item_normal(); //drop single file - localuser if((argc() > 2) && (argv(2) === 'drop')) { - + $id = intval(argv(1)); - - q("DELETE FROM item WHERE id = %d AND uid = %d", - intval($id), - intval(local_channel()) - ); - + + drop_item($id); + goaway(z_root() . '/sharedwithme'); + } //drop all files - localuser if((argc() > 1) && (argv(1) === 'dropall')) { - - q("DELETE FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d", + + $r = q("SELECT id FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal", dbesc(ACTIVITY_POST), - dbesc(ACTIVITY_OBJ_FILE), - intval(local_channel()) + intval(local_channel()), + dbesc($channel['channel_hash']) ); - + + $ids = ids_to_array($r); + + if($ids) + drop_items($ids); + goaway(z_root() . '/sharedwithme'); + } - + //list files - $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", + $r = q("SELECT id, uid, obj, item_unseen FROM item WHERE verb = '%s' AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND owner_xchan != '%s' $item_normal", dbesc(ACTIVITY_POST), - dbesc(ACTIVITY_OBJ_FILE), intval(local_channel()), dbesc($channel['channel_hash']) ); - - $items =array(); - $ids = ''; - + + $items = []; + $ids = []; + if($r) { foreach($r as $rr) { $object = json_decode($rr['obj'],true); - - $item = array(); + $meta = self::get_meta($object); + + $item = []; $item['id'] = $rr['id']; - $item['objfiletype'] = $object['filetype']; - $item['objfiletypeclass'] = getIconFromType($object['filetype']); - $item['objurl'] = rawurldecode(get_rel_link($object['link'],'alternate')) . '?f=&zid=' . $channel['xchan_addr']; - $item['objfilename'] = $object['filename']; - $item['objfilesize'] = userReadableSize($object['filesize']); - $item['objedited'] = $object['edited']; + $item['objfiletype'] = $meta['type']; + $item['objfiletypeclass'] = getIconFromType($meta['type']); + $item['objurl'] = $meta['path'] . '?f=&zid=' . $channel['xchan_addr']; + $item['objfilename'] = $object['name']; + $item['objfilesize'] = userReadableSize($meta['size']); + $item['objedited'] = $meta['edited']; $item['unseen'] = $rr['item_unseen']; $items[] = $item; - if($item['unseen'] > 0) { - $ids .= " '" . $rr['id'] . "',"; + if($item['unseen']) { + $ids[] = $rr['id']; } } } - + + $ids = implode(',', $ids); + if($ids) { - - //remove trailing , - $ids = rtrim($ids, ","); - q("UPDATE item SET item_unseen = 0 WHERE id IN ( $ids ) AND uid = %d", intval(local_channel()) ); - } $o = ''; @@ -117,5 +116,22 @@ class Sharedwithme extends Controller { } + function get_meta($object) { + + $ret = []; + + if(! is_array($object['attachment'])) + return; + + foreach($object['attachment'] as $a) { + if($a['name'] === 'zot.attach.meta') { + $ret = $a['value']; + break; + } + } + + return $ret; + + } } diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 290c616a9..cb4c54961 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -453,11 +453,12 @@ class Sse_bs extends Controller { $r = q("SELECT * FROM item WHERE verb = '%s' - AND obj_type in ('Document', 'Video', 'Audio', 'Image') + AND obj_type IN ('Document', 'Video', 'Audio', 'Image') AND uid = %d AND author_xchan != '%s' AND item_unseen = 1 - $item_normal", + $item_normal + ORDER BY created DESC", dbesc(ACTIVITY_POST), intval(self::$uid), dbesc(self::$ob_hash) -- cgit v1.2.3 From c229f058b4331e3b631d9ca725385ef78bf59778 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 25 Apr 2020 09:15:20 +0000 Subject: fix mod filestorage and fetch the info from attach if only the hash is provided in attach_store_item() --- Zotlabs/Module/Filestorage.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index c40de2823..0c6233493 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -35,12 +35,12 @@ class Filestorage extends \Zotlabs\Web\Controller { $url = get_cloud_url($channel_id, $channel['channel_address'], $resource); - //get the object before permissions change so we can catch eventual former allowed members - $object = get_file_activity_object($channel_id, $resource, $url); - attach_change_permissions($channel_id, $resource, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], $recurse, true); - file_activity($channel_id, $object, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], 'post', $notify); + if($notify) { + $observer = \App::get_observer(); + attach_store_item($channel, $observer, $resource); + } goaway(dirname($url)); } -- cgit v1.2.3 From 837dbb7a1414d9e14d588f1e425acd12a2dc87e3 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 29 Apr 2020 11:10:54 +0000 Subject: =?UTF-8?q?=C3=83fix=20photo=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zotlabs/Lib/Activity.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 9b79190bb..5c72a1175 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -178,7 +178,6 @@ class Activity { static function fetch_image($x) { - $ret = [ 'type' => 'Image', 'id' => $x['id'], @@ -2242,9 +2241,7 @@ class Activity { } - // avoid double images from hubzilla to zap/osada - - if($act->obj['type'] === 'Image' && strpos($s['body'],'zrl=') === false) { + if($act->obj['type'] === 'Image') { $ptr = null; @@ -2258,10 +2255,11 @@ class Activity { } foreach($ptr as $vurl) { if(strpos($s['body'],$vurl['href']) === false) { - $s['body'] .= '[zmg]' . $vurl['href'] . '[/zmg]' . "\n\n" . $s['body']; + $bb_imgs .= '[zmg]' . $vurl['href'] . '[/zmg]' . "\n\n"; break; } } + $s['body'] = $bb_imgs . $s['body']; } elseif(is_string($act->obj['url'])) { if(strpos($s['body'],$act->obj['url']) === false) { -- cgit v1.2.3 From 328900cf3b412b1e8ca7d1e447d2d0ffc19e045a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 29 Apr 2020 14:38:11 +0200 Subject: Force browser photo revalidation --- Zotlabs/Module/Photo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 48e2bf4a5..1cf082bdd 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -213,7 +213,7 @@ class Photo extends \Zotlabs\Web\Controller { if(! $data) killme(); - + $etag = '"' . md5($data . $modified) . '"'; if($modified == 0) @@ -269,7 +269,7 @@ class Photo extends \Zotlabs\Web\Controller { // in the event that infrastructure caching is present. $smaxage = intval($maxage/12); - header("Cache-Control: s-maxage=" . $smaxage . ", max-age=" . $maxage . $cachecontrol); + header("Cache-Control: no-cache, s-maxage=" . $smaxage . ", max-age=" . $maxage . $cachecontrol); } -- cgit v1.2.3 From 03c1419ad0f5ed62b00ee49b81927223daed4c50 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 2 May 2020 11:48:11 +0000 Subject: missing lib include --- Zotlabs/Daemon/Onepoll.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index fdcb907d1..93a5412b0 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -2,6 +2,8 @@ namespace Zotlabs\Daemon; +use Zotlabs\Lib\Libzot; + require_once('include/zot.php'); require_once('include/socgraph.php'); -- cgit v1.2.3 From f4a71db42dec1daa5d3cbf305372bdf47b4add5f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 2 May 2020 17:28:49 +0200 Subject: Display delayed posts on author's channel page --- Zotlabs/Lib/ThreadItem.php | 5 +++-- Zotlabs/Module/Channel.php | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index a5dd81d40..426f88688 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -426,6 +426,7 @@ class ThreadItem { 'editedtime' => (($item['edited'] != $item['created']) ? sprintf( t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r')) : ''), 'expiretime' => (($item['expires'] > NULL_DATE) ? sprintf( t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')):''), 'lock' => $lock, + 'delayed' => $item['item_delayed'], 'privacy_warning' => $privacy_warning, 'verified' => $verified, 'unverified' => $unverified, @@ -460,7 +461,7 @@ class ThreadItem { 'tagger' => ((feature_enabled($conv->get_profile_owner(),'commtag')) ? $tagger : ''), 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing') && ($item['item_type'] == ITEM_TYPE_POST)) ? $filer : ''), 'pinned' => ($pinned ? t('Pinned post') : ''), - 'pinnable' => (($this->is_toplevel() && local_channel() && $item['owner_xchan'] == $observer['xchan_hash'] && $allowed_type && $item['item_private'] == 0) ? '1' : ''), + 'pinnable' => (($this->is_toplevel() && local_channel() && $item['owner_xchan'] == $observer['xchan_hash'] && $allowed_type && $item['item_private'] == 0 && $item['item_delayed'] == 0) ? '1' : ''), 'pinme' => ($pinned ? t('Unpin from the top') : t('Pin to the top')), 'bookmark' => (($conv->get_profile_owner() == local_channel() && local_channel() && $has_bookmarks) ? t('Save Bookmarks') : ''), 'addtocal' => (($has_event) ? t('Add to Calendar') : ''), @@ -488,7 +489,7 @@ class ThreadItem { 'modal_dismiss' => t('Close'), 'showlike' => $showlike, 'showdislike' => $showdislike, - 'comment' => $this->get_comment_box($indent), + 'comment' => ($item['item_delayed'] ? '' : $this->get_comment_box($indent)), 'previewing' => ($conv->is_preview() ? true : false ), 'preview_lbl' => t('This is an unsaved preview'), 'wait' => t('Please wait'), diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 170b81787..08de059a8 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -239,8 +239,12 @@ class Channel extends Controller { /** * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups */ - - $item_normal = item_normal(); + + $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0 + and item.item_unpublished = 0 and item.item_pending_remove = 0 + and item.item_blocked = 0 "; + if (! $is_owner) + $item_normal .= "and item.item_delayed = 0 "; $item_normal_update = item_normal_update(); $sql_extra = item_permissions_sql(App::$profile['profile_uid']); -- cgit v1.2.3 From 46242aeaae084191244008529703c964fa5b2d53 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 4 May 2020 09:24:22 +0000 Subject: display complete perminfo only to owner --- Zotlabs/Module/Viewconnections.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 320a331d1..a0c293ddf 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -97,7 +97,6 @@ class Viewconnections extends \Zotlabs\Web\Controller { $perminfo['connperms'] .= t('Nothing'); } - $url = chanlink_hash($rr['xchan_hash']); if($url) { $contacts[] = array( @@ -111,13 +110,12 @@ class Viewconnections extends \Zotlabs\Web\Controller { 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '', - 'perminfo' => $perminfo, + 'perminfo' => (($is_owner) ? $perminfo : (($perminfo['connpermcount'] === 0) ? $perminfo : [])), 'oneway' => $oneway ); } } - - + if($_REQUEST['aj']) { if($contacts) { $o = replace_macros(get_markup_template('viewcontactsajax.tpl'),array( -- cgit v1.2.3 From de058901c2a8dd5fea09b1594c2ace0b8bd2c90f Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 5 May 2020 07:40:24 +0000 Subject: catch the owner_xchan for activity_share items in notifications filter --- Zotlabs/Module/Sse_bs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index cb4c54961..a8c0b2299 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -119,7 +119,7 @@ class Sse_bs extends Controller { $sql_extra2 = ''; if(self::$xchans) - $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") "; + $sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; $item_normal = item_normal(); @@ -184,7 +184,7 @@ class Sse_bs extends Controller { $sql_extra2 = ''; if(self::$xchans) - $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") "; + $sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; $item_normal = item_normal(); @@ -261,7 +261,7 @@ class Sse_bs extends Controller { $sql_extra2 = ''; if(self::$xchans) - $sql_extra2 = " AND author_xchan IN (" . self::$xchans . ") "; + $sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; $item_normal = item_normal(); -- cgit v1.2.3 From 06d1cf83d2b1acfef5529fe388d2502bea381881 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 5 May 2020 14:51:00 +0000 Subject: deal with polls and votes in enotify --- Zotlabs/Lib/Enotify.php | 27 +++++++++++++++++---------- Zotlabs/Module/Sse_bs.php | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index a4fc8aa75..f706b0fb9 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -143,19 +143,26 @@ class Enotify { $action = t('commented on'); - if(array_key_exists('item',$params) && in_array($params['item']['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { + if(array_key_exists('item',$params)) { - if(! $always_show_in_notices || !($vnotify & VNOTIFY_LIKE)) { - logger('notification: not a visible activity. Ignoring.'); - pop_lang(); - return; - } + if(in_array($params['item']['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { - if(activity_match($params['verb'], ACTIVITY_LIKE)) - $action = t('liked'); + if(! $always_show_in_notices || !($vnotify & VNOTIFY_LIKE)) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); + return; + } + + if(activity_match($params['verb'], ACTIVITY_LIKE)) + $action = t('liked'); + + if(activity_match($params['verb'], ACTIVITY_DISLIKE)) + $action = t('disliked'); + + } - if(activity_match($params['verb'], ACTIVITY_DISLIKE)) - $action = t('disliked'); + if($params['item']['obj_type'] === 'Answer') + $action = t('voted on'); } diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index a8c0b2299..23bc3c96b 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -327,6 +327,7 @@ class Sse_bs extends Controller { $r = q("SELECT * FROM notify WHERE uid = %d AND seen = 0 ORDER BY created DESC", intval(self::$uid) ); + if($r) { foreach($r as $rr) { $result['notify']['notifications'][] = Enotify::format_notify($rr); -- cgit v1.2.3 From 2cb0cade7b41e1251fb90e857f690ec155a10c9e Mon Sep 17 00:00:00 2001 From: Zot Date: Wed, 6 May 2020 11:00:29 +0200 Subject: Revert "issue generating photo thumbnails when uploaded via davfs" This reverts commit 7a0d9a449492ff3b5ef97b997310ed26ec1f53e4. --- Zotlabs/Module/Dav.php | 2 +- Zotlabs/Storage/BasicAuth.php | 11 +++++++++++ Zotlabs/Storage/Directory.php | 19 +++++++++++++++---- Zotlabs/Storage/File.php | 5 +++++ 4 files changed, 32 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Dav.php b/Zotlabs/Module/Dav.php index e8ce6a703..adab25e45 100644 --- a/Zotlabs/Module/Dav.php +++ b/Zotlabs/Module/Dav.php @@ -95,7 +95,7 @@ class Dav extends \Zotlabs\Web\Controller { $auth = new \Zotlabs\Storage\BasicAuth(); - $auth->observer = get_observer_hash(); + // $auth->observer = get_observer_hash(); $auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . ' ' . 'WebDAV'); diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php index a5c01fbb7..3a48f5004 100644 --- a/Zotlabs/Storage/BasicAuth.php +++ b/Zotlabs/Storage/BasicAuth.php @@ -2,6 +2,7 @@ namespace Zotlabs\Storage; +use App; use Sabre\DAV; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; @@ -128,6 +129,16 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { $this->channel_name = $r['channel_address']; $this->channel_id = $r['channel_id']; $this->channel_hash = $this->observer = $r['channel_hash']; + + if ($this->observer) { + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($this->observer) + ); + if ($r) { + App::set_observer(array_shift($r)); + } + } + $_SESSION['uid'] = $r['channel_id']; $_SESSION['account_id'] = $r['channel_account_id']; $_SESSION['authenticated'] = true; diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 8cda75fd1..1231dfa25 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -281,8 +281,19 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $xpath = attach_syspaths($this->auth->owner_id, $hash); - // returns the number of bytes that were written to the file, or FALSE on failure - $size = file_put_contents($f, $data); + + if (is_resource($data)) { + $fp = fopen($f,'wb'); + if ($fp) { + pipe_streams($data,$fp); + fclose($fp); + } + $size = filesize($f); + } + else { + $size = file_put_contents($f, $data); + } + // delete attach entry if file_put_contents() failed if ($size === false) { logger('file_put_contents() failed to ' . $f); @@ -315,7 +326,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $d = q("UPDATE attach SET filesize = '%s', os_path = '%s', display_path = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d", dbesc($size), dbesc($xpath['os_path']), - dbesc($xpath['display_path']), + dbesc($xpath['path']), intval($is_photo), dbesc($edited), dbesc($hash), @@ -364,7 +375,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo $p = photo_upload($c[0], \App::get_observer(), $args); } - \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $this->folder_hash ]); + \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $hash ]); $sync = attach_export_data($c[0], $hash); diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 68edde166..ee96363c4 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -121,6 +121,11 @@ class File extends DAV\Node implements DAV\IFile { logger('put file: ' . basename($this->name), LOGGER_DEBUG); $size = 0; + if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) { + logger('permission denied for put operation'); + throw new DAV\Exception\Forbidden('Permission denied.'); + } + // @todo only 3 values are needed $c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1", intval($this->auth->owner_id) -- cgit v1.2.3 From a04b6d178bd4a5facc827c6ac3b9a51b1a0c88d9 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 7 May 2020 07:55:05 +0000 Subject: deprecate premium channel app --- Zotlabs/Lib/Apps.php | 1 - Zotlabs/Update/_1237.php | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Update/_1237.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index d65eed14f..f11bb9628 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -372,7 +372,6 @@ class Apps { 'OAuth2 Apps Manager' => t('OAuth2 Apps Manager'), 'PDL Editor' => t('PDL Editor'), 'Permission Categories' => t('Permission Categories'), - 'Premium Channel' => t('Premium Channel'), 'Public Stream' => t('Public Stream'), 'My Chatrooms' => t('My Chatrooms'), 'Channel Export' => t('Channel Export') diff --git a/Zotlabs/Update/_1237.php b/Zotlabs/Update/_1237.php new file mode 100644 index 000000000..6c998ba4f --- /dev/null +++ b/Zotlabs/Update/_1237.php @@ -0,0 +1,25 @@ + Date: Thu, 7 May 2020 08:06:38 +0000 Subject: remove more traces of the premium channel app --- Zotlabs/Module/Connect.php | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Connect.php b/Zotlabs/Module/Connect.php index 62d3af840..31da42035 100644 --- a/Zotlabs/Module/Connect.php +++ b/Zotlabs/Module/Connect.php @@ -28,10 +28,6 @@ class Connect extends Controller { $channel_id = App::$data['channel']['channel_id']; - if(! Apps::system_app_installed($channel_id, 'Premium Channel')) { - return; - } - profile_load($which,''); } @@ -42,10 +38,6 @@ class Connect extends Controller { $channel_id = App::$data['channel']['channel_id']; - if(! Apps::system_app_installed($channel_id, 'Premium Channel')) { - return; - } - $edit = ((local_channel() && (local_channel() == $channel_id)) ? true : false); if($edit) { @@ -97,15 +89,6 @@ class Connect extends Controller { $channel_id = App::$data['channel']['channel_id']; - if(! Apps::system_app_installed($channel_id, 'Premium Channel')) { - //Do not display any associated widgets at this point - App::$pdl = ''; - - $o = '' . t('Premium Channel App') . ' (' . t('Not Installed') . '):
'; - $o .= t('Allows you to set restrictions and terms on those that connect with your channel'); - return $o; - } - $edit = ((local_channel() && (local_channel() == $channel_id)) ? true : false); $text = get_pconfig($channel_id,'system','selltext'); -- cgit v1.2.3 From f473b5abfbbac4a6cadaf6fc26ed5fd950987ed6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 May 2020 07:53:21 +0000 Subject: as_vid_sort -> vid_sort --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 5c72a1175..2b88b6683 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1597,7 +1597,7 @@ class Activity { // sort function width decreasing - static function as_vid_sort($a,$b) { + static function vid_sort($a,$b) { if($a['width'] === $b['width']) return 0; return (($a['width'] > $b['width']) ? -1 : 1); @@ -1767,7 +1767,7 @@ class Activity { } } if($mps) { - usort($mps,'as_vid_sort'); + usort($mps,[ __CLASS__, 'vid_sort' ]); foreach($mps as $m) { if(intval($m['width']) < 500) { $s['body'] .= "\n\n" . '[video]' . $m['href'] . '[/video]'; -- cgit v1.2.3 From 3d02758fee664a67c8f15f4a7a885ae629d90cf0 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 May 2020 10:55:57 +0000 Subject: deal with diaspora uuid --- Zotlabs/Lib/Activity.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 2b88b6683..3287dd6fb 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -346,6 +346,7 @@ class Activity { $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid'])); + $ret['diaspora:guid'] = $i['uuid']; if($i['title']) $ret['name'] = $i['title']; @@ -1662,6 +1663,7 @@ class Activity { $s['aid'] = $channel['channel_account_id']; $s['uid'] = $channel['channel_id']; $s['mid'] = urldecode($act->obj['id']); + $s['uuid'] = $act->obj['diaspora:guid']; $s['plink'] = urldecode($act->obj['id']); @@ -1953,6 +1955,7 @@ class Activity { self::actor_store($act->actor['id'],$act->actor); $s['mid'] = $act->obj['id']; + $s['uuid'] = $act->obj['diaspora:guid']; $s['parent_mid'] = $act->parent_id; if($act->data['published']) { @@ -2400,11 +2403,6 @@ class Activity { $item['aid'] = $channel['channel_account_id']; $item['uid'] = $channel['channel_id']; - $s['uuid'] = ''; - - // Friendica sends the diaspora guid in a nonstandard field via AP - if($act->obj['diaspora:guid']) - $s['uuid'] = $act->obj['diaspora:guid']; if(! ( $item['author_xchan'] && $item['owner_xchan'])) { logger('owner or author missing.'); -- cgit v1.2.3 From 22d8523e76f45532aa874eb2da78d9956e4b165e Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 12 May 2020 08:23:41 +0000 Subject: DB update 1238 to fix hubloc_id_url for existing hublocs and set hubloc_id_url in Activity::actor_store() --- Zotlabs/Lib/Activity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 3287dd6fb..4b7ed30f3 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1548,7 +1548,8 @@ class Activity { 'hubloc_host' => $hostname, 'hubloc_callback' => $inbox, 'hubloc_updated' => datetime_convert(), - 'hubloc_primary' => 1 + 'hubloc_primary' => 1, + 'hubloc_id_url' => $profile ] ); } -- cgit v1.2.3 From 6ffdc1b64238f63d3739bb5639b2b4517f90aa34 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 12 May 2020 08:29:54 +0000 Subject: update file --- Zotlabs/Update/_1238.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Zotlabs/Update/_1238.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php new file mode 100644 index 000000000..428f7ce15 --- /dev/null +++ b/Zotlabs/Update/_1238.php @@ -0,0 +1,41 @@ + Date: Tue, 12 May 2020 08:34:35 +0000 Subject: fix update for postgres --- Zotlabs/Update/_1238.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 428f7ce15..e08cd334f 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -21,11 +21,11 @@ class _1238 { // fix singleton networks hubloc_id_url $r2 = q("UPDATE hubloc - LEFT JOIN xchan ON hubloc_hash = xchan_hash - SET hubloc_id_url = xchan_url - WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = '' - AND xchan_url != ''" + LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash + SET hubloc.hubloc_id_url = xchan.xchan_url + WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc.hubloc_id_url = '' + AND xchan.xchan_url != ''" ); if($r1 && $r2) { -- cgit v1.2.3 From 326644104c169ddcc5188af994e1a0fa932ad99f Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 12 May 2020 08:56:05 +0000 Subject: really fix update for postgres --- Zotlabs/Update/_1238.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index e08cd334f..92dfeef38 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -20,13 +20,25 @@ class _1238 { ); // fix singleton networks hubloc_id_url - $r2 = q("UPDATE hubloc - LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash - SET hubloc.hubloc_id_url = xchan.xchan_url - WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc.hubloc_id_url = '' - AND xchan.xchan_url != ''" - ); + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + $r2 = q("UPDATE hubloc + LEFT JOIN xchan ON hubloc_hash = xchan_hash + SET hubloc_id_url = xchan_url + WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc_id_url = '' + AND xchan_url != ''" + ); + } + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r2 = q("UPDATE hubloc + SET hubloc_id_url = xchan_url + FROM xchan + WHERE hubloc_hash = xchan_hash + AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc_id_url = '' + AND xchan_url != ''" + ); + } if($r1 && $r2) { q("COMMIT"); -- cgit v1.2.3 From 1329662edcfc9650982a770247fb52d3ab9c55a3 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 12 May 2020 09:13:59 +0000 Subject: use dbq() in update 1238 --- Zotlabs/Update/_1238.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 92dfeef38..77a14c3fa 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -13,7 +13,7 @@ class _1238 { ); // fix legacy zot hubloc_id_url - $r1 = q("UPDATE hubloc + $r1 = dbq("UPDATE hubloc SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1)) WHERE hubloc_network = 'zot' AND hubloc_id_url = ''" @@ -21,7 +21,7 @@ class _1238 { // fix singleton networks hubloc_id_url if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r2 = q("UPDATE hubloc + $r2 = dbq("UPDATE hubloc LEFT JOIN xchan ON hubloc_hash = xchan_hash SET hubloc_id_url = xchan_url WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') @@ -30,7 +30,7 @@ class _1238 { ); } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r2 = q("UPDATE hubloc + $r2 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash -- cgit v1.2.3 From 4270e17bc4ffedd35ddc5e00f7037162e9b95725 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 14 May 2020 09:27:39 +0000 Subject: implement notifications for direct messages --- Zotlabs/Module/Sse_bs.php | 75 ++++++++++++++++++++++++++++++++++++++-- Zotlabs/Widget/Notifications.php | 20 +++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 23bc3c96b..2f3567e70 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -57,6 +57,7 @@ class Sse_bs extends Controller { $_SESSION['sse_loadtime'] = datetime_convert(); $network = false; + $dm = false; $home = false; $pubs = false; $f = ''; @@ -66,6 +67,10 @@ class Sse_bs extends Controller { $network = true; $f = 'bs_network'; break; + case 'dm': + $dm = true; + $f = 'bs_dm'; + break; case 'home': $home = true; $f = 'bs_home'; @@ -84,6 +89,7 @@ class Sse_bs extends Controller { $result = array_merge( self::bs_network($network), + self::bs_dm($dm), self::bs_home($home), self::bs_notify(), self::bs_intros(), @@ -127,7 +133,7 @@ class Sse_bs extends Controller { $items = q("SELECT * FROM item WHERE uid = %d AND created <= '%s' - AND item_unseen = 1 AND item_wall = 0 + AND item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1) AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal @@ -153,7 +159,7 @@ class Sse_bs extends Controller { } $r = q("SELECT count(id) as total FROM item - WHERE uid = %d and item_unseen = 1 AND item_wall = 0 + WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1) $item_normal $sql_extra AND author_xchan != '%s'", @@ -167,6 +173,71 @@ class Sse_bs extends Controller { return $result; } + function bs_dm($notifications) { + + $result['dm']['notifications'] = []; + $result['dm']['count'] = 0; + + if(! self::$uid) + return $result; + + $limit = intval(self::$limit); + $offset = self::$offset; + + $sql_extra = ''; + if(! (self::$vnotify & VNOTIFY_LIKE)) + $sql_extra = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') "; + + $sql_extra2 = ''; + if(self::$xchans) + $sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; + + $item_normal = item_normal(); + + if ($notifications) { + $items = q("SELECT * FROM item + WHERE uid = %d + AND created <= '%s' + AND item_unseen = 1 AND item_wall = 0 AND item_private = 2 + AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') + AND author_xchan != '%s' + $item_normal + $sql_extra + $sql_extra2 + ORDER BY created DESC LIMIT $limit OFFSET $offset", + intval(self::$uid), + dbescdate($_SESSION['sse_loadtime']), + dbesc(self::$ob_hash) + ); + + if($items) { + $result['dm']['offset'] = ((count($items) == $limit) ? intval($offset + $limit) : -1); + xchan_query($items); + foreach($items as $item) { + $result['dm']['notifications'][] = Enotify::format($item); + } + } + else { + $result['dm']['offset'] = -1; + } + + } + + $r = q("SELECT count(id) as total FROM item + WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private = 2 + $item_normal + $sql_extra + AND author_xchan != '%s'", + intval(self::$uid), + dbesc(self::$ob_hash) + ); + + if($r) + $result['dm']['count'] = intval($r[0]['total']); + + return $result; + } + function bs_home($notifications) { $result['home']['notifications'] = []; diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 077949b4e..e2a543f80 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -28,6 +28,7 @@ class Notifications { ] ]; + $notifications[] = [ 'type' => 'home', 'icon' => 'home', @@ -47,6 +48,25 @@ class Notifications { ] ]; + $notifications[] = [ + 'type' => 'dm', + 'icon' => 'envelope', + 'severity' => 'danger', + 'label' => t('New Direct Messages'), + 'title' => t('New Direct Messages Notifications'), + 'viewall' => [ + 'url' => 'network/?dm=1', + 'label' => t('View your direct messages') + ], + 'markall' => [ + 'label' => t('Mark all notifications read') + ], + 'filter' => [ + 'posts_label' => t('Show new posts only'), + 'name_label' => t('Filter by name or address') + ] + ]; + $notifications[] = [ 'type' => 'mail', 'icon' => 'envelope', -- cgit v1.2.3 From 81338e80865caff4c911980c0cb9689cb10c7087 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 May 2020 10:10:07 +0000 Subject: use zot_record_preferred() when fetching keys --- Zotlabs/Lib/JSalmon.php | 2 +- Zotlabs/Web/HTTPSig.php | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/JSalmon.php b/Zotlabs/Lib/JSalmon.php index bed748432..67512046f 100644 --- a/Zotlabs/Lib/JSalmon.php +++ b/Zotlabs/Lib/JSalmon.php @@ -69,4 +69,4 @@ class JSalmon { } -} \ No newline at end of file +} diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 3d050fd9b..827e0d779 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -243,13 +243,15 @@ class HTTPSig { $url = ((strpos($id,'#')) ? substr($id,0,strpos($id,'#')) : $id); - $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1", + $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s'", dbesc(str_replace('acct:','',$url)), dbesc($url) ); - if($x && $x[0]['xchan_pubkey']) { - return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ]; + $x = Libzot::zot_record_preferred($x); + + if($x && $x['xchan_pubkey']) { + return [ 'portable_id' => $x['xchan_hash'], 'public_key' => $x['xchan_pubkey'] , 'hubloc' => $x ]; } $r = ActivityStreams::fetch($id); @@ -268,13 +270,15 @@ class HTTPSig { function get_webfinger_key($id) { - $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1", + $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s'", dbesc(str_replace('acct:','',$id)), dbesc($id) ); - if($x && $x[0]['xchan_pubkey']) { - return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ]; + $x = Libzot::zot_record_preferred($x); + + if($x && $x['xchan_pubkey']) { + return [ 'portable_id' => $x['xchan_hash'], 'public_key' => $x['xchan_pubkey'] , 'hubloc' => $x ]; } $wf = Webfinger::exec($id); @@ -302,12 +306,15 @@ class HTTPSig { function get_zotfinger_key($id) { - $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s' limit 1", + $x = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_addr = '%s' or hubloc_id_url = '%s'", dbesc(str_replace('acct:','',$id)), dbesc($id) ); - if($x && $x[0]['xchan_pubkey']) { - return [ 'portable_id' => $x[0]['xchan_hash'], 'public_key' => $x[0]['xchan_pubkey'] , 'hubloc' => $x[0] ]; + + $x = Libzot::zot_record_preferred($x); + + if($x && $x['xchan_pubkey']) { + return [ 'portable_id' => $x['xchan_hash'], 'public_key' => $x['xchan_pubkey'] , 'hubloc' => $x ]; } $wf = Webfinger::exec($id); -- cgit v1.2.3 From b4973ede4443aea7e77e112f2fd031f5541ea3d3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 May 2020 12:11:35 +0000 Subject: rewriting the owner for legacy compatibility should be sufficient --- Zotlabs/Daemon/Notifier.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index d66079216..bd5f8ee2c 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -477,7 +477,6 @@ class Notifier { $details = q("select xchan_hash, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . protect_sprintf(implode(',',$recipients)) . ")"); - $recip_list = array(); if($details) { @@ -567,7 +566,6 @@ class Notifier { $hub_env = []; // per-hub envelope so we don't broadcast the entire envelope to all foreach($hubs as $hub) { - if($env_recips) { foreach($env_recips as $er) { if($hub['hubloc_hash'] === $er['hash']) { @@ -744,8 +742,8 @@ class Notifier { else { $encoded_item['owner']['network'] = 'zot'; $encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']); - $encoded_item['author']['network'] = 'zot'; - $encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']); + //$encoded_item['author']['network'] = 'zot'; + //$encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']); } } -- cgit v1.2.3 From f40fedcad69d23b33e8688c6230bc43cfc4f98dd Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 May 2020 12:40:06 +0000 Subject: rewriting the author for legacy compatibility only if author is from this site and add comment. --- Zotlabs/Daemon/Notifier.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index bd5f8ee2c..6e4038fd7 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -734,6 +734,8 @@ class Notifier { } } + + // remove this after most hubs have updated to version 5.0 if(stripos($hub['site_project'], 'hubzilla') !== false && version_compare($hub['site_version'], '4.7.3', '<=')) { if($encoded_item['type'] === 'mail') { $encoded_item['from']['network'] = 'zot'; @@ -742,8 +744,10 @@ class Notifier { else { $encoded_item['owner']['network'] = 'zot'; $encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']); - //$encoded_item['author']['network'] = 'zot'; - //$encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']); + if(strpos($encoded_item['author']['url'], z_root()) === 0) { + $encoded_item['author']['network'] = 'zot'; + $encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']); + } } } -- cgit v1.2.3 From c358d8326e48ceaa7c36c794a59b2a4a2256fd9a Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 May 2020 13:16:07 +0000 Subject: whitespace --- Zotlabs/Daemon/Notifier.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 6e4038fd7..8993d8aee 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -368,10 +368,10 @@ class Notifier { } else { $activity = array_merge(['@context' => [ - ACTIVITYSTREAMS_JSONLD_REV, - 'https://w3id.org/security/v1', - z_root() . ZOT_APSCHEMA_REV - ]], Activity::encode_activity($target_item) + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + z_root() . ZOT_APSCHEMA_REV + ]], Activity::encode_activity($target_item) ); } @@ -637,7 +637,7 @@ class Notifier { } // singleton deliveries by definition 'not got zot'. - // Single deliveries are other federated networks (plugins) and we're essentially + // Single deliveries are other federated networks (plugins) and we're essentially // delivering only to those that have this site url in their abook_instance // and only from within a sync operation. This means if you post from a clone, // and a connection is connected to one of your other clones; assuming that hub -- cgit v1.2.3 From b6efb02ed291fcdfb32e8587a031950d752327bc Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 May 2020 15:08:57 +0000 Subject: uuid for likes --- Zotlabs/Lib/Activity.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4b7ed30f3..5b387e6ee 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -708,6 +708,8 @@ class Activity { $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid'])); } + $ret['diaspora:guid'] = $i['uuid']; + if($i['title']) $ret['name'] = html2plain(bbcode($i['title'], [ 'cache' => true ])); @@ -1983,6 +1985,7 @@ class Activity { $response_activity = true; $s['mid'] = $act->id; + $s['uuid'] = $act['diaspora:guid']; $s['parent_mid'] = $act->obj['id']; // over-ride the object timestamp with the activity -- cgit v1.2.3 From e3aaa39f9eb62a292c81956b92cb71a47ffc075c Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 May 2020 15:26:05 +0000 Subject: Revert "uuid for likes" This reverts commit b6efb02ed291fcdfb32e8587a031950d752327bc. --- Zotlabs/Lib/Activity.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 5b387e6ee..4b7ed30f3 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -708,8 +708,6 @@ class Activity { $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid'])); } - $ret['diaspora:guid'] = $i['uuid']; - if($i['title']) $ret['name'] = html2plain(bbcode($i['title'], [ 'cache' => true ])); @@ -1985,7 +1983,6 @@ class Activity { $response_activity = true; $s['mid'] = $act->id; - $s['uuid'] = $act['diaspora:guid']; $s['parent_mid'] = $act->obj['id']; // over-ride the object timestamp with the activity -- cgit v1.2.3 From 13319985fda0a67e1fb67cf521f6a3ea3b0aebac Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 15 May 2020 19:28:03 +0200 Subject: uuid for likes --- Zotlabs/Lib/Activity.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4b7ed30f3..014ff8949 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -708,6 +708,8 @@ class Activity { $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid'])); } + $ret['diaspora:guid'] = $i['uuid']; + if($i['title']) $ret['name'] = html2plain(bbcode($i['title'], [ 'cache' => true ])); @@ -1984,6 +1986,7 @@ class Activity { $s['mid'] = $act->id; $s['parent_mid'] = $act->obj['id']; + $s['uuid'] = $act->{'diaspora:guid'}; // over-ride the object timestamp with the activity -- cgit v1.2.3 From 6bfac1a9076b25c5c1cd9467e9051544f40d512e Mon Sep 17 00:00:00 2001 From: Keenan Pepper Date: Wed, 27 May 2020 13:52:38 -0700 Subject: Fix bug allowing invite codes to be reused unlimited times The invite codes aren't deleted from the DB because of a malformed query. --- Zotlabs/Module/Register.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index bc813f8e1..278cf15ca 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -118,7 +118,7 @@ class Register extends Controller { $invite_code = ((x($_POST,'invite_code')) ? notags(trim($_POST['invite_code'])) : ''); if($using_invites && $invite_code) { - q("delete * from register where hash = '%s'", dbesc($invite_code)); + q("delete from register where hash = '%s'", dbesc($invite_code)); // @FIXME - this also needs to be considered when using 'invites_remaining' in mod/invite.php set_aconfig($result['account']['account_id'],'system','invites_remaining',$num_invites); } -- cgit v1.2.3 From 3201a4bec5f3524c2eba813e46d69b4c5943840f Mon Sep 17 00:00:00 2001 From: Zot Date: Thu, 11 Jun 2020 12:13:43 +0200 Subject: allow apps to be both pinned and starred independently --- Zotlabs/Lib/Apps.php | 6 ++---- Zotlabs/Module/Apporder.php | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index f11bb9628..7b980b8d3 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -564,7 +564,8 @@ class Apps { '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), '$pinned' => ((strpos($papp['categories'], 'nav_pinned_app') === false) ? false : true), '$navapps' => (($mode == 'nav') ? true : false), - '$order' => (($mode == 'nav-order') ? true : false), + '$order' => (($mode === 'nav-order' || $mode === 'nav-order-pinned') ? true : false), + '$mode' => $mode, '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray'), '$add_nav' => t('Pin to navbar'), @@ -959,9 +960,6 @@ class Apps { if($list) { foreach($list as $li) { $papp = self::app_encode($li); - if($menu !== 'nav_pinned_app' && strpos($papp['categories'],'nav_pinned_app') !== false) - continue; - $syslist[] = $papp; } } diff --git a/Zotlabs/Module/Apporder.php b/Zotlabs/Module/Apporder.php index eac1abc2d..313c2df50 100644 --- a/Zotlabs/Module/Apporder.php +++ b/Zotlabs/Module/Apporder.php @@ -34,9 +34,9 @@ class Apporder extends \Zotlabs\Web\Controller { foreach($syslist as $app) { if($l === 'nav_pinned_app') { - $navbar_apps[] = Zlib\Apps::app_render($app,'nav-order'); + $navbar_apps[] = Zlib\Apps::app_render($app,'nav-order-pinned'); } - elseif(strpos($app['categories'],'nav_pinned_app') === false) { + else { $nav_apps[] = Zlib\Apps::app_render($app,'nav-order'); } } -- cgit v1.2.3 From 8cd66145bdd8bf0f43c2a1774181c974335fc494 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 14 Jun 2020 15:38:44 +0200 Subject: fix discovery --- Zotlabs/Lib/Libzot.php | 2 +- Zotlabs/Module/Wfinger.php | 17 +++++++++-------- Zotlabs/Module/Zfinger.php | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 5e212ad70..dda6d5d95 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2908,7 +2908,7 @@ class Libzot { ]; $ret['channel_role'] = get_pconfig($e['channel_id'],'system','permissions_role','custom'); - $ret['protocols'] = [ 'zot', 'zot6' ]; + $ret['protocols'] = [ 'zot6', 'zot' ]; $ret['searchable'] = $searchable; $ret['adult_content'] = $adult_channel; $ret['public_forum'] = $public_forum; diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index a19bdbedc..efb380033 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -3,6 +3,7 @@ namespace Zotlabs\Module; require_once('include/zot.php'); +use Zotlabs\Lib\Libzot; class Wfinger extends \Zotlabs\Web\Controller { @@ -128,7 +129,7 @@ class Wfinger extends \Zotlabs\Web\Controller { 'http://webfinger.net/ns/name' => $r[0]['channel_name'], 'http://xmlns.com/foaf/0.1/name' => $r[0]['channel_name'], 'https://w3id.org/security/v1#publicKeyPem' => $r[0]['xchan_pubkey'], - 'http://purl.org/zot/federation' => 'zot,zot6' + 'http://purl.org/zot/federation' => 'zot6,zot' ]; foreach($aliases as $alias) @@ -142,7 +143,7 @@ class Wfinger extends \Zotlabs\Web\Controller { [ 'rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], - 'href' => $r[0]['xchan_photo_l'] + 'href' => $r[0]['xchan_photo_l'] ], [ @@ -201,11 +202,6 @@ class Wfinger extends \Zotlabs\Web\Controller { 'rel' => 'http://ostatus.org/schema/1.0/subscribe', 'template' => z_root() . '/follow?f=&url={uri}', ], - - [ - 'rel' => 'http://purl.org/zot/protocol', - 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], - ], [ 'rel' => 'http://purl.org/zot/protocol/6.0', @@ -213,6 +209,11 @@ class Wfinger extends \Zotlabs\Web\Controller { 'href' => channel_url($r[0]) ], + [ + 'rel' => 'http://purl.org/zot/protocol', + 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], + ], + [ 'rel' => 'http://purl.org/openwebauth/v1', 'type' => 'application/x-zot+json', @@ -229,7 +230,7 @@ class Wfinger extends \Zotlabs\Web\Controller { if($zot) { // get a zotinfo packet and return it with webfinger - $result['zot'] = zotinfo( [ 'address' => $r[0]['xchan_addr'] ]); + $result['zot'] = Libzot::zotinfo( [ 'address' => $r[0]['xchan_addr'] ]); } } diff --git a/Zotlabs/Module/Zfinger.php b/Zotlabs/Module/Zfinger.php index 3a20144a5..0151d458a 100644 --- a/Zotlabs/Module/Zfinger.php +++ b/Zotlabs/Module/Zfinger.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; use Zotlabs\Web\HTTPSig; +use Zotlabs\Lib\Libzot; class Zfinger extends \Zotlabs\Web\Controller { @@ -10,10 +11,10 @@ class Zfinger extends \Zotlabs\Web\Controller { require_once('include/zot.php'); require_once('include/crypto.php'); - $x = zotinfo($_REQUEST); + $x = Libzot::zotinfo($_REQUEST); - if($x && $x['guid'] && $x['guid_sig']) { - $chan_hash = make_xchan_hash($x['guid'],$x['guid_sig']); + if($x && $x['id'] && $x['public_key']) { + $chan_hash = Libzot::make_xchan_hash($x['id'],$x['public_key']); if($chan_hash) { $chan = channelx_by_hash($chan_hash); } -- cgit v1.2.3 From ec4dea0920f1f5a3cc1899ca2302acd71ceb0405 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 14 Jun 2020 18:47:18 +0200 Subject: zot6 does not appear to use zfinger --- Zotlabs/Module/Wfinger.php | 11 ++++------- Zotlabs/Module/Zfinger.php | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index efb380033..d24a31a15 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -163,13 +163,13 @@ class Wfinger extends \Zotlabs\Web\Controller { else { $result['links'] = [ - + [ 'rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_l'] ], - + [ 'rel' => 'http://microformats.org/profile/hcard', 'type' => 'text/html', @@ -181,12 +181,11 @@ class Wfinger extends \Zotlabs\Web\Controller { 'href' => z_root() ], - [ 'rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address'], ], - + [ 'rel' => 'http://schemas.google.com/g/2010#updates-from', 'type' => 'application/atom+xml', @@ -197,7 +196,7 @@ class Wfinger extends \Zotlabs\Web\Controller { 'rel' => 'http://webfinger.net/rel/blog', 'href' => z_root() . '/channel/' . $r[0]['channel_address'], ], - + [ 'rel' => 'http://ostatus.org/schema/1.0/subscribe', 'template' => z_root() . '/follow?f=&url={uri}', @@ -220,7 +219,6 @@ class Wfinger extends \Zotlabs\Web\Controller { 'href' => z_root() . '/owa', ], - [ 'rel' => 'magic-public-key', 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), @@ -242,7 +240,6 @@ class Wfinger extends \Zotlabs\Web\Controller { $arr = [ 'channel' => $r[0], 'pchan' => $pchan, 'request' => $_REQUEST, 'result' => $result ]; call_hooks('webfinger',$arr); - json_return_and_die($arr['result'],'application/jrd+json'); } diff --git a/Zotlabs/Module/Zfinger.php b/Zotlabs/Module/Zfinger.php index 0151d458a..533f0a5db 100644 --- a/Zotlabs/Module/Zfinger.php +++ b/Zotlabs/Module/Zfinger.php @@ -10,11 +10,11 @@ class Zfinger extends \Zotlabs\Web\Controller { require_once('include/zot.php'); require_once('include/crypto.php'); - - $x = Libzot::zotinfo($_REQUEST); - if($x && $x['id'] && $x['public_key']) { - $chan_hash = Libzot::make_xchan_hash($x['id'],$x['public_key']); + $x = zotinfo($_REQUEST); + + if($x && $x['guid'] && $x['guid_sig']) { + $chan_hash = make_xchan_hash($x['guid'],$x['guid_sig']); if($chan_hash) { $chan = channelx_by_hash($chan_hash); } -- cgit v1.2.3 From 36e969fd79a252e9aef7a87b8fa2d5f7c75ecd6d Mon Sep 17 00:00:00 2001 From: Zot Date: Wed, 17 Jun 2020 09:12:15 +0200 Subject: zap group compatibility - rewrites DMs and wall-to-wall posts to group pages as new posts authored by the group with an embedded reshare. This currently has known delivery issues due to zot/zot6 xchan confusion which are already slated for resolution in hz5. Specifically "sender is not owner/author" and missing abconfig permissions on the zot6 identity for a channel we're connected with over traditional zot. --- Zotlabs/Access/PermissionRoles.php | 4 ++++ Zotlabs/Module/Item.php | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/PermissionRoles.php b/Zotlabs/Access/PermissionRoles.php index c8b4953a5..82df0c34b 100644 --- a/Zotlabs/Access/PermissionRoles.php +++ b/Zotlabs/Access/PermissionRoles.php @@ -100,6 +100,7 @@ class PermissionRoles { 'post_mail', 'post_like' , 'republish', 'chat' ]; $ret['limits'] = PermissionLimits::Std_Limits(); + $ret['channel_type'] = 'group'; break; @@ -113,6 +114,7 @@ class PermissionRoles { 'view_pages', 'view_wiki', 'post_wall', 'post_comments', 'tag_deliver', 'post_mail', 'post_like' , 'chat' ]; $ret['limits'] = PermissionLimits::Std_Limits(); + $ret['channel_type'] = 'group'; break; @@ -132,6 +134,7 @@ class PermissionRoles { $ret['limits']['view_storage'] = PERMS_SPECIFIC; $ret['limits']['view_pages'] = PERMS_SPECIFIC; $ret['limits']['view_wiki'] = PERMS_SPECIFIC; + $ret['channel_type'] = 'group'; break; @@ -187,6 +190,7 @@ class PermissionRoles { 'post_mail', 'post_like' , 'republish', 'chat', 'write_wiki' ]; $ret['limits'] = PermissionLimits::Std_Limits(); + $ret['channel_type'] = 'group'; break; diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 95359ccad..29563a9a5 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -14,6 +14,7 @@ use Zotlabs\Web\HTTPSig; use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Libsync; use Zotlabs\Lib\ThreadListener; +use Zotlabs\Access\PermissionRoles; use App; require_once('include/crypto.php'); @@ -677,6 +678,25 @@ class Item extends Controller { $str_contact_deny = $gacl['deny_cid']; $str_group_deny = $gacl['deny_gid']; + + $groupww = false; + + // if this is a wall-to-wall post to a group, turn it into a direct message + + $role = get_pconfig($profile_uid,'system','permissions_role'); + + $rolesettings = PermissionRoles::role_perms($role); + + $channel_type = isset($rolesettings['channel_type']) ? $rolesettings['channel_type'] : 'normal'; + + $is_group = (($channel_type === 'group') ? true : false); + + if (($is_group) && ($walltowall) && (! $walltowall_comment)) { + $groupww = true; + $str_contact_allow = $owner_xchan['xchan_hash']; + $str_group_allow = ''; + } + $post_tags = []; if($mimetype === 'text/bbcode') { @@ -1233,7 +1253,11 @@ class Item extends Controller { $datarray['llink'] = z_root() . '/display/' . gen_link_id($datarray['mid']); call_hooks('post_local_end', $datarray); - + + if ($groupww) { + $nopush = false; + } + if(! $nopush) Master::Summon([ 'Notifier', $notify_type, $post_id ]); -- cgit v1.2.3 From 137f56f99498e5770c1b5ae218aa7dfe677f178a Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 19 Jun 2020 08:18:43 +0000 Subject: only redirect to known sites --- Zotlabs/Module/Chanview.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index 2e653d030..20ac41fbe 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -86,19 +86,8 @@ class Chanview extends \Zotlabs\Web\Controller { } if(! \App::$poi) { - - // We don't know who this is, and we can't figure it out from the URL - // On the plus side, there's a good chance we know somebody else at that - // hub so sending them there with a Zid will probably work anyway. - - $url = ($_REQUEST['url']); - if(! $url) { - notice( t('Channel not found.') . EOL); - return; - } - if($observer) - $url = zid($url); - + notice( t('Channel not found.') . EOL); + return; } $is_zot = false; -- cgit v1.2.3 From fa752b0ac1bf4c0b19fcb0f7ff7dcfa3b3b90078 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Jul 2020 19:06:24 -0700 Subject: zot6 group updates to support edit and delete of top-level group posts. This is supported remotely by editing or removing the post that started it all. A W2W post can only be deleted at this time. --- Zotlabs/Lib/ThreadItem.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 426f88688..fadc38b38 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -150,9 +150,11 @@ class ThreadItem { $edpost = false; - if($observer['xchan_hash'] == $this->get_data_value('author_xchan') + if($observer && $observer['xchan_hash'] + && ($observer['xchan_hash'] == $this->get_data_value('author_xchan') || $observer['xchan_hash'] == $this->get_data_value('owner_xchan') - || $this->get_data_value('uid') == local_channel()) + || $observer['xchan_hash'] == $this->get_data_value('source_xchan') + || $this->get_data_value('uid') == local_channel())) $dropping = true; -- cgit v1.2.3 From c0735a5ca20ea5612d475f50eb802cb1cd92cab5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Jul 2020 19:16:37 -0700 Subject: z6trans: don't swap xprof xchans on directory servers because it will fail with duplicate primary key in many cases and the migration will fail on each channel. What this means is that directory servers may take time to pick up zot6 entries if they haven't received them prior to the upgrade. I don't see an easier solution unless we check for existence of the zot6 xchan_hash in the xprof table before converting it. --- Zotlabs/Module/Z6trans.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Z6trans.php b/Zotlabs/Module/Z6trans.php index 98832ad98..58dc09a51 100644 --- a/Zotlabs/Module/Z6trans.php +++ b/Zotlabs/Module/Z6trans.php @@ -119,7 +119,7 @@ class Z6trans extends Controller { 'xconfig' => ['xchan', 'v'], 'xign' => ['xchan'], 'xlink' => ['xlink_xchan', 'xlink_link'], - 'xprof' => ['xprof_hash'], +// 'xprof' => ['xprof_hash'], 'xtag' => ['xtag_hash'], ]; -- cgit v1.2.3 From 774cc852d4bc46a533c5ec2fb533463871721fe0 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 13 Jul 2020 09:18:11 +0000 Subject: fix php warning --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 014ff8949..d883eac67 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -3042,7 +3042,7 @@ class Activity { } } - if (array_key_exists('source',$act) && array_key_exists('mediaType',$act['source'])) { + if (array_path_exists('source/mediaType',$act) && array_path_exists('source/content',$act)) { if ($act['source']['mediaType'] === 'text/bbcode') { $content['bbcode'] = purify_html($act['source']['content']); } -- cgit v1.2.3 From 573af9e3660554c3916eb45f325bfbd84c1a78c5 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 13 Jul 2020 18:59:23 +0000 Subject: fix embeded shares --- Zotlabs/Module/Item.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 29563a9a5..d8c837522 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -816,8 +816,6 @@ class Item extends Controller { $i = 0; foreach($match[2] as $mtch) { $reshare = new \Zotlabs\Lib\Share($mtch); - $datarray['obj'] = $reshare->obj(); - $datarray['obj_type'] = $datarray['obj']['type']; $body = str_replace($match[1][$i],$reshare->bbcode(),$body); $i++; } -- cgit v1.2.3 From ce77f82966d921e144e84506374875dec8965127 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 13 Jul 2020 20:52:15 +0000 Subject: more zot6 --- Zotlabs/Module/Like.php | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 61f73bfd5..edd4cfac8 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -210,20 +210,8 @@ class Like extends \Zotlabs\Web\Controller { if(! $plink) $plink = '[zrl=' . z_root() . '/profile/' . $ch[0]['channel_address'] . ']' . $post_type . '[/zrl]'; - $links = array(); - $links[] = array('rel' => 'alternate', 'type' => 'text/html', - 'href' => z_root() . '/profile/' . $ch[0]['channel_address']); - $links[] = array('rel' => 'photo', 'type' => $ch[0]['xchan_photo_mimetype'], - 'href' => $ch[0]['xchan_photo_l']); - - $object = json_encode(array( - 'type' => ACTIVITY_OBJ_PROFILE, - 'title' => $ch[0]['channel_name'], - 'id' => $ch[0]['xchan_url'] . '/' . $ch[0]['xchan_hash'], - 'link' => $links - )); - - + $object = json_encode(Activity::fetch_profile([ 'id' => channel_url($ch[0]) ])); + // second like of the same thing is "undo" for the first like $z = q("select * from likes where channel_id = %d and liker = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' limit 1", @@ -408,27 +396,8 @@ class Like extends \Zotlabs\Web\Controller { $body = $item['body']; - $object = json_encode(array( - 'type' => $objtype, - 'id' => $item['mid'], - 'asld' => Activity::fetch_item( [ 'id' => $item['mid'] ] ), - 'parent' => (($item['thr_parent']) ? $item['thr_parent'] : $item['parent_mid']), - 'link' => $links, - 'title' => $item['title'], - 'content' => $item['body'], - 'created' => $item['created'], - 'edited' => $item['edited'], - 'author' => array( - 'name' => $item_author['xchan_name'], - 'address' => $item_author['xchan_addr'], - 'guid' => $item_author['xchan_guid'], - 'guid_sig' => $item_author['xchan_guid_sig'], - 'link' => array( - array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item_author['xchan_url']), - array('rel' => 'photo', 'type' => $item_author['xchan_photo_mimetype'], 'href' => $item_author['xchan_photo_m'])), - ), - )); - + $object = json_encode(Activity::fetch_item( [ 'id' => $item['mid'] ])); + if(! intval($item['item_thread_top'])) $post_type = 'comment'; -- cgit v1.2.3 From 634a515ec15baff240a2e41603d576c1c5dc88c7 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 14 Jul 2020 12:43:34 +0000 Subject: reduce result sets and work around a regression in justifiedGallery --- Zotlabs/Module/Articles.php | 2 +- Zotlabs/Module/Cards.php | 2 +- Zotlabs/Module/Channel.php | 2 +- Zotlabs/Module/Directory.php | 2 +- Zotlabs/Module/Dirsearch.php | 2 +- Zotlabs/Module/Moderate.php | 2 +- Zotlabs/Module/Network.php | 2 +- Zotlabs/Module/Photos.php | 4 ++-- Zotlabs/Module/Pubstream.php | 2 +- Zotlabs/Module/Search.php | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php index 2c43b4764..3f726ebb9 100644 --- a/Zotlabs/Module/Articles.php +++ b/Zotlabs/Module/Articles.php @@ -149,7 +149,7 @@ class Articles extends Controller { } $itemspage = get_pconfig(local_channel(),'system','itemspage'); - App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 3f0e93de5..c44f7942b 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -145,7 +145,7 @@ class Cards extends Controller { $itemspage = get_pconfig(local_channel(),'system','itemspage'); - App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 08de059a8..9c8cddab3 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -334,7 +334,7 @@ class Channel extends Controller { $itemspage = get_pconfig(local_channel(),'system','itemspage'); - App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); if($noscript_content || $load) { diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 3eafd9f71..e1bf0f6cf 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -14,7 +14,7 @@ require_once('include/html2plain.php'); class Directory extends Controller { function init() { - App::set_pager_itemspage(60); + App::set_pager_itemspage(30); if(local_channel() && x($_GET,'ignore')) { q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ", diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php index 62af75f4c..c15b13a90 100644 --- a/Zotlabs/Module/Dirsearch.php +++ b/Zotlabs/Module/Dirsearch.php @@ -11,7 +11,7 @@ require_once('include/dir_fns.php'); class Dirsearch extends Controller { function init() { - App::set_pager_itemspage(60); + App::set_pager_itemspage(30); } diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index f1bff3c50..b66b052a6 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -16,7 +16,7 @@ class Moderate extends \Zotlabs\Web\Controller { return; } - \App::set_pager_itemspage(60); + \App::set_pager_itemspage(30); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); //show all items diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index adfdc011b..fe1aa4386 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -452,7 +452,7 @@ class Network extends \Zotlabs\Web\Controller { } else { $itemspage = get_pconfig(local_channel(),'system','itemspage'); - App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); } diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index fae8c17f6..649e753ad 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -708,7 +708,7 @@ class Photos extends \Zotlabs\Web\Controller { ]); if($x = photos_album_exists($owner_uid, get_observer_hash(), $datum)) { - \App::set_pager_itemspage(60); + \App::set_pager_itemspage(30); $album = $x['display_path']; } else { @@ -1289,7 +1289,7 @@ class Photos extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= "\r\n" . '' . "\r\n"; - \App::set_pager_itemspage(60); + \App::set_pager_itemspage(30); $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.album, p.imgscale, p.created, p.display_path FROM photo p diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 92ef44696..76a3e0d9e 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -169,7 +169,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $pager_sql = ''; } else { - \App::set_pager_itemspage(20); + \App::set_pager_itemspage(10); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); } diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 686afb2d2..d586ae12f 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -159,7 +159,7 @@ class Search extends \Zotlabs\Web\Controller { if(($update) && ($load)) { $itemspage = get_pconfig(local_channel(),'system','itemspage'); - \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); // in case somebody turned off public access to sys channel content with permissions -- cgit v1.2.3 From d2f1c3743172dc59e5935d77322998fa03c2cc22 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 16 Jul 2020 10:49:08 +0000 Subject: more itemspage work --- Zotlabs/Module/Settings/Display.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index f553fc057..01ae8652a 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -36,9 +36,9 @@ class Display { if($browser_update < 10000) $browser_update = 10000; - $itemspage = ((x($_POST,'itemspage')) ? intval($_POST['itemspage']) : 20); - if($itemspage > 100) - $itemspage = 100; + $itemspage = ((x($_POST,'itemspage')) ? intval($_POST['itemspage']) : 10); + if($itemspage > 30) + $itemspage = 30; set_pconfig(local_channel(),'system','preload_images',$preload_images); @@ -159,7 +159,7 @@ class Display { $browser_update = (($browser_update == 0) ? 80 : $browser_update / 1000); // default if not set: 40 seconds $itemspage = intval(get_pconfig(local_channel(), 'system','itemspage')); - $itemspage = (($itemspage > 0 && $itemspage < 101) ? $itemspage : 20); // default if not set: 20 items + $itemspage = (($itemspage > 0 && $itemspage <= 30) ? $itemspage : 10); // default if not set: 10 items $nosmile = get_pconfig(local_channel(),'system','no_smilies'); $nosmile = (($nosmile===false)? '0': $nosmile); // default if not set: 0 @@ -197,7 +197,7 @@ class Display { '$preload_images' => array('preload_images', t("Preload images before rendering the page"), $preload_images, t("The subjective page load time will be longer but the page will be ready when displayed"), $yes_no), '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), - '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), + '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 30 items')), '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1-intval($nosmile), '', $yes_no), '$channel_menu' => [ 'channel_menu', t('Provide channel menu in navigation bar'), get_pconfig(local_channel(),'system','channel_menu',get_config('system','channel_menu',0)), t('Default: channel menu located in app menu'),$yes_no ], '$manual_update' => array('manual_update', t('Manual conversation updates'), channel_manual_conv_update(local_channel()), t('Default is on, turning this off may increase screen jumping'), $yes_no), -- cgit v1.2.3 From 4f95b44ff239f92574491b3053b7f5aace6432d3 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Jul 2020 17:29:40 +0000 Subject: zot6 testing --- Zotlabs/Lib/Activity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d883eac67..5297c1f95 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -20,7 +20,7 @@ class Activity { if(is_array($x)) { - if(array_key_exists('asld',$x)) { + if(array_key_exists('asld',$x) && is_array($x['asld'])) { return $x['asld']; } @@ -165,6 +165,7 @@ class Activity { $r = q("select * from item where mid = '%s' limit 1", dbesc($x['id']) ); + if($r) { xchan_query($r,true); $r = fetch_post_tags($r,true); -- cgit v1.2.3 From ca969cd0ed53563e6b5d518838e4da75f9f3e893 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Jul 2020 17:54:14 +0000 Subject: =?UTF-8?q?those=20are=20not=20l=C3=83ikely=20to=20be=20parents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 5297c1f95..698556001 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2562,8 +2562,8 @@ class Activity { switch($a->type) { case 'Create': case 'Update': - case 'Like': - case 'Dislike': + //case 'Like': + //case 'Dislike': case 'Announce': $item = self::decode_note($a); break; -- cgit v1.2.3 From dd2ffae8bf913e686bb700624154f9176489396d Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Jul 2020 19:08:03 +0000 Subject: Revert "zot6 testing" This reverts commit 4f95b44ff239f92574491b3053b7f5aace6432d3. --- Zotlabs/Lib/Activity.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 698556001..b8432f95a 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -20,7 +20,7 @@ class Activity { if(is_array($x)) { - if(array_key_exists('asld',$x) && is_array($x['asld'])) { + if(array_key_exists('asld',$x)) { return $x['asld']; } @@ -165,7 +165,6 @@ class Activity { $r = q("select * from item where mid = '%s' limit 1", dbesc($x['id']) ); - if($r) { xchan_query($r,true); $r = fetch_post_tags($r,true); -- cgit v1.2.3 From 9b5e270379bc2301f3edde2290525e3b546fa049 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 24 Jul 2020 20:46:55 +0000 Subject: tool to fix missing hubloc_id_url entries --- Zotlabs/Module/Fhubloc_id_url.php | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Zotlabs/Module/Fhubloc_id_url.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php new file mode 100644 index 000000000..f384d9d8d --- /dev/null +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -0,0 +1,41 @@ + Date: Sun, 26 Jul 2020 07:16:06 +0000 Subject: improve profile detection and reduce feed result set --- Zotlabs/Lib/Activity.php | 33 +++++++++++++++++++++++++++++---- Zotlabs/Module/Feed.php | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index b8432f95a..25f19510d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1456,11 +1456,35 @@ class Activity { $icon = $person_obj['icon']; } - if(is_array($person_obj['url']) && array_key_exists('href', $person_obj['url'])) - $profile = $person_obj['url']['href']; - else - $profile = $url; + $links = false; + $profile = false; + + if (is_array($person_obj['url'])) { + if (! array_key_exists(0,$person_obj['url'])) { + $links = [ $person_obj['url'] ]; + } + else { + $links = $person_obj['url']; + } + } + + if ($links) { + foreach ($links as $link) { + if (array_key_exists('mediaType',$link) && $link['mediaType'] === 'text/html') { + $profile = $link['href']; + } + } + if (! $profile) { + $profile = $links[0]['href']; + } + } + elseif (isset($person_obj['url']) && is_string($person_obj['url'])) { + $profile = $person_obj['url']; + } + if (! $profile) { + $profile = $url; + } $inbox = $person_obj['inbox']; @@ -1492,6 +1516,7 @@ class Activity { ); if(! $r) { // create a new record + $r = xchan_store_lowlevel( [ 'xchan_hash' => $url, diff --git a/Zotlabs/Module/Feed.php b/Zotlabs/Module/Feed.php index 36869abbe..b5e7b28fa 100644 --- a/Zotlabs/Module/Feed.php +++ b/Zotlabs/Module/Feed.php @@ -17,7 +17,7 @@ class Feed extends \Zotlabs\Web\Controller { $params['pages'] = ((x($_REQUEST,'pages')) ? intval($_REQUEST['pages']) : 0); $params['top'] = ((x($_REQUEST,'top')) ? intval($_REQUEST['top']) : 0); $params['start'] = ((x($_REQUEST,'start')) ? intval($_REQUEST['start']) : 0); - $params['records'] = ((x($_REQUEST,'records')) ? intval($_REQUEST['records']) : 40); + $params['records'] = ((x($_REQUEST,'records')) ? intval($_REQUEST['records']) : 10); $params['direction'] = ((x($_REQUEST,'direction')) ? dbesc($_REQUEST['direction']) : 'desc'); $params['cat'] = ((x($_REQUEST,'cat')) ? escape_tags($_REQUEST['cat']) : ''); $params['compat'] = ((x($_REQUEST,'compat')) ? intval($_REQUEST['compat']) : 0); -- cgit v1.2.3 From 33e4d7c0d8b3f7b4088a1b02c3519b626a07daae Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 26 Jul 2020 07:45:20 +0000 Subject: fix hubloc_id_url for activitypub with broken xchan_url --- Zotlabs/Module/Fhubloc_id_url.php | 29 +++++++++++++++++++++++------ Zotlabs/Update/_1238.php | 28 +++++++++++++++++++++------- 2 files changed, 44 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php index f384d9d8d..a03f3f1b6 100644 --- a/Zotlabs/Module/Fhubloc_id_url.php +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -19,23 +19,40 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { // fix singleton networks hubloc_id_url if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r2 = dbq("UPDATE hubloc + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc LEFT JOIN xchan ON hubloc_hash = xchan_hash SET hubloc_id_url = xchan_url WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = '' - AND xchan_url != ''" + AND hubloc_id_url = ''" ); + } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r2 = dbq("UPDATE hubloc + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = '' - AND xchan_url != ''" + AND hubloc_id_url = ''" ); + + } } } diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 77a14c3fa..0e25c36bb 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -21,26 +21,40 @@ class _1238 { // fix singleton networks hubloc_id_url if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r2 = dbq("UPDATE hubloc + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc LEFT JOIN xchan ON hubloc_hash = xchan_hash SET hubloc_id_url = xchan_url WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = '' - AND xchan_url != ''" + AND hubloc_id_url = ''" ); } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r2 = dbq("UPDATE hubloc + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = '' - AND xchan_url != ''" + AND hubloc_id_url = ''" ); } - if($r1 && $r2) { + if($r1 && $r2 && $r3) { q("COMMIT"); return UPDATE_SUCCESS; } -- cgit v1.2.3 From 9f0f794a0a6bc93750e2e8169bd80db10b5bb1b9 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 26 Jul 2020 07:46:22 +0000 Subject: whitespace --- Zotlabs/Module/Fhubloc_id_url.php | 2 +- Zotlabs/Update/_1238.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php index a03f3f1b6..d332c7400 100644 --- a/Zotlabs/Module/Fhubloc_id_url.php +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -44,7 +44,7 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { AND xchan_hash != ''" ); - $r3 = dbq("UPDATE hubloc + $r3 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 0e25c36bb..32c21f161 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -45,7 +45,7 @@ class _1238 { AND xchan_hash != ''" ); - $r3 = dbq("UPDATE hubloc + $r3 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash -- cgit v1.2.3 From e31903cbc9fd9d1230fb4472f25f03f493e79629 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 29 Jul 2020 19:53:00 +0000 Subject: add some context to the notifications --- Zotlabs/Lib/Enotify.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index f706b0fb9..90c498d78 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -856,11 +856,11 @@ class Enotify { 'photo' => $item[$who]['xchan_photo_s'], 'when' => (($edit) ? datetime_convert('UTC', date_default_timezone_get(), $item['edited']) : datetime_convert('UTC', date_default_timezone_get(), $item['created'])), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), - 'b64mid' => 'b64.' . base64url_encode($item['mid']), + 'b64mid' => (($item['mid']) ? 'b64.' . base64url_encode($item['mid']) : ''), //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), - 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => bbcode(escape_tags($itemem_text)), + 'body' => htmlentities(html2plain(bbcode($item['body'])), ENT_COMPAT, 'UTF-8', false), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], @@ -885,7 +885,6 @@ class Enotify { $mid = basename($tt['link']); $b64mid = ((strpos($mid, 'b64.') === 0) ? $mid : 'b64.' . base64url_encode($mid)); - $x = [ 'notify_link' => z_root() . '/notify/view/' . $tt['id'], 'name' => $tt['xname'], @@ -893,8 +892,8 @@ class Enotify { 'photo' => $tt['photo'], 'when' => datetime_convert('UTC', date_default_timezone_get(), $tt['created']), 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), - 'b64mid' => (($tt['otype'] == 'item') ? $b64mid : 'undefined'), - 'notify_id' => (($tt['otype'] == 'item') ? $tt['id'] : 'undefined'), + 'b64mid' => (($tt['otype'] == 'item') ? $b64mid : ''), + 'notify_id' => (($tt['otype'] == 'item') ? $tt['id'] : ''), 'message' => $message ]; @@ -980,8 +979,7 @@ class Enotify { $x = [ 'notify_link' => z_root() . '/admin/accounts', 'name' => $rr['account_email'], - 'addr' => $rr['account_email'], - 'url' => '', + //'addr' => $rr['account_email'], 'photo' => z_root() . '/' . get_default_profile_photo(48), 'when' => datetime_convert('UTC', date_default_timezone_get(),$rr['account_created']), 'hclass' => ('notify-unseen'), -- cgit v1.2.3 From 06f03eb13a336761c49a353bc69b84323ba34f9c Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 30 Jul 2020 08:21:43 +0000 Subject: respect notifications settings --- Zotlabs/Module/Sse_bs.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 2f3567e70..6d5acf276 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -34,7 +34,7 @@ class Sse_bs extends Controller { } } - self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify'); + self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify', -1); self::$evdays = intval(get_pconfig(self::$uid, 'system', 'evdays')); self::$limit = 100; self::$offset = 0; @@ -116,6 +116,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_NETWORK)) + return $result; + $limit = intval(self::$limit); $offset = self::$offset; @@ -181,6 +184,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_MAIL)) + return $result; + $limit = intval(self::$limit); $offset = self::$offset; @@ -246,6 +252,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_CHANNEL)) + return $result; + $limit = intval(self::$limit); $offset = self::$offset; @@ -309,6 +318,9 @@ class Sse_bs extends Controller { $result['pubs']['notifications'] = []; $result['pubs']['count'] = 0; + if(! (self::$vnotify & VNOTIFY_PUBS)) + return $result; + if((observer_prohibited(true))) { return $result; } @@ -395,6 +407,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_SYSTEM)) + return $result; + $r = q("SELECT * FROM notify WHERE uid = %d AND seen = 0 ORDER BY created DESC", intval(self::$uid) ); @@ -419,6 +434,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_INTRO)) + return $result; + $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ORDER BY abook_created DESC LIMIT 50", intval(self::$uid) ); @@ -443,6 +461,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_FORUMS)) + return $result; + $forums = get_forum_channels(self::$uid); if($forums) { @@ -521,6 +542,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_FILES)) + return $result; + $item_normal = item_normal(); $r = q("SELECT * FROM item @@ -556,6 +580,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_MAIL)) + return $result; + $r = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan where channel_id = %d and mail_seen = 0 and mail_deleted = 0 and from_xchan != '%s' order by created desc", @@ -583,6 +610,9 @@ class Sse_bs extends Controller { if(! self::$uid) return $result; + if(! (self::$vnotify & VNOTIFY_EVENT)) + return $result; + $r = q("SELECT * FROM event left join xchan on event_xchan = xchan_hash WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 and etype in ( 'event', 'birthday' ) @@ -611,6 +641,9 @@ class Sse_bs extends Controller { if(! self::$uid && ! is_site_admin()) return $result; + if(! (self::$vnotify & VNOTIFY_REGISTER)) + return $result; + $r = q("SELECT account_email, account_created from account where (account_flags & %d) > 0", intval(ACCOUNT_PENDING) ); -- cgit v1.2.3 From 976d6baf6a0ea5a2dfb692720adddb7b9e53a10c Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 30 Jul 2020 08:48:02 +0000 Subject: use the compact view in html2plain() --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 90c498d78..03a824b9b 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -860,7 +860,7 @@ class Enotify { //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => bbcode(escape_tags($itemem_text)), - 'body' => htmlentities(html2plain(bbcode($item['body'])), ENT_COMPAT, 'UTF-8', false), + 'body' => htmlentities(html2plain(bbcode($item['body']), 75, true), ENT_COMPAT, 'UTF-8', false), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], -- cgit v1.2.3 From 5ecbbfc7dfe1d1f3d36a02ac36b659538d6c5937 Mon Sep 17 00:00:00 2001 From: Zot Date: Wed, 5 Aug 2020 19:13:44 +0200 Subject: update profile|cover photo activities converted to z6 --- Zotlabs/Module/Cover_photo.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 615ca6fe0..dff645f2b 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -293,14 +293,6 @@ class Cover_photo extends \Zotlabs\Web\Controller { $arr['item_thread_top'] = 1; $arr['item_origin'] = 1; $arr['item_wall'] = 1; - $arr['obj_type'] = ACTIVITY_OBJ_PHOTO; - $arr['verb'] = ACTIVITY_UPDATE; - - $arr['obj'] = json_encode(array( - 'type' => $arr['obj_type'], - 'id' => z_root() . '/photo/' . $photo['resource_id'] . '-7', - 'link' => array('rel' => 'photo', 'type' => $photo['mimetype'], 'href' => z_root() . '/photo/' . $photo['resource_id'] . '-7') - )); if($profile && stripos($profile['gender'],t('female')) !== false) $t = t('%1$s updated her %2$s'); -- cgit v1.2.3 From 393cee661913d8ec5b9d5352faf8e340b9db56b4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 15 Aug 2020 13:17:04 +0200 Subject: $id is expected to be an array with a calendarId and an instanceId for caldav --- Zotlabs/Module/Cdav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index ac73b8a5b..d7d57664c 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -819,7 +819,7 @@ class Cdav extends Controller { return; } - $id = explode(':', $_REQUEST['target'])[0]; + $id = explode(':', $_REQUEST['target']); $ext = 'ics'; $table = 'calendarobjects'; $column = 'calendarid'; -- cgit v1.2.3 From ea845aeacdaa00b35a86550d5f9b0d3fcd2b40d4 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 16 Aug 2020 16:29:00 -0700 Subject: issue with DAV - moveInto and variable scope --- Zotlabs/Storage/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index ee96363c4..76295d922 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -27,7 +27,7 @@ class File extends DAV\Node implements DAV\IFile { * * filename (string) * * filetype (string) */ - private $data; + public $data; /** * @see \\Sabre\\DAV\\Auth\\Backend\\BackendInterface * @var \\Zotlabs\\Storage\\BasicAuth $auth -- cgit v1.2.3 From e55a1a6aa8fe55d20b588f0223a15018053bfd48 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 20 Aug 2020 08:43:13 +0000 Subject: fix item deletion --- Zotlabs/Daemon/Notifier.php | 5 +++-- Zotlabs/Lib/Activity.php | 38 +++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 8993d8aee..0f5393f0a 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -361,8 +361,9 @@ class Notifier { $encoded_item = encode_item($target_item); - // activitystreams version - $m = get_iconfig($target_item,'activitystreams','signed_data'); + // activitystreams version (recreate for deleted items) + $m = ((intval($target_item['item_deleted'])) ? '' : get_iconfig($target_item,'activitystreams','signed_data')); + if($m) { $activity = json_decode($m,true); } diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 25f19510d..83c04c042 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -314,14 +314,6 @@ class Activity { else { $objtype = self::activity_obj_mapper($i['obj_type']); } - - if(intval($i['item_deleted'])) { - $ret['type'] = 'Tombstone'; - $ret['formerType'] = $objtype; - $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid'])); - return $ret; - } - if ($i['obj']) { $ret = Activity::encode_object($i['obj']); @@ -651,16 +643,36 @@ class Activity { $ret['obj'] = []; } - if(intval($i['item_deleted'])) { - $ret['type'] = 'Tombstone'; - $ret['formerType'] = self::activity_obj_mapper($i['obj_type']); - $ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid'])); + if (intval($i['item_deleted'])) { + $ret['type'] = 'Delete'; + $ret['id'] = str_replace('/item/','/activity/',$i['mid']) . '#delete'; $actor = self::encode_person($i['author'],false); - if($actor) + if ($actor) $ret['actor'] = $actor; else return []; + + if ($i['obj']) { + if (! is_array($i['obj'])) { + $i['obj'] = json_decode($i['obj'],true); + } + $obj = self::encode_object($i['obj']); + if ($obj) + $ret['object'] = $obj; + else + return []; + } + else { + $obj = self::encode_item($i); + if ($obj) + $ret['object'] = $obj; + else + return []; + } + + $ret['to'] = [ ACTIVITY_PUBLIC_INBOX ]; return $ret; + } -- cgit v1.2.3 From c36b2ca91506561bf3c0f024e558a40179504dce Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 20 Aug 2020 08:53:58 +0000 Subject: be more clear in comment --- Zotlabs/Daemon/Notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 0f5393f0a..0efa93cce 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -361,7 +361,7 @@ class Notifier { $encoded_item = encode_item($target_item); - // activitystreams version (recreate for deleted items) + // Re-use existing signature unless the activity type changed to a Tombstone, which won't verify. $m = ((intval($target_item['item_deleted'])) ? '' : get_iconfig($target_item,'activitystreams','signed_data')); if($m) { -- cgit v1.2.3 From c4c47f777724937746c99c064e65f52723443e59 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 20 Aug 2020 22:47:33 +0200 Subject: first cut on implementing additional encryption with the SJCL library. aes only and no backward compatibility. --- Zotlabs/Lib/ThreadStream.php | 2 +- Zotlabs/Module/Chat.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 020e8729b..f54b3f6c2 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -23,7 +23,7 @@ class ThreadStream { private $preview = false; private $prepared_item = ''; public $reload = ''; - private $cipher = 'aes256'; + private $cipher = 'AES-256'; // $prepared_item is for use by alternate conversation structures such as photos // wherein we've already prepared a top level item which doesn't look anything like diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php index 6a46cdace..66ba42d33 100644 --- a/Zotlabs/Module/Chat.php +++ b/Zotlabs/Module/Chat.php @@ -197,7 +197,7 @@ class Chat extends Controller { $cipher = get_pconfig(local_channel(),'system','default_cipher'); if(! $cipher) - $cipher = 'aes256'; + $cipher = 'AES-256'; $o = replace_macros(get_markup_template('chat.tpl'),array( -- cgit v1.2.3 From 49df57df45f82e2e0f1b10f2508f61b78d6d3ac0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 21 Aug 2020 10:55:55 +0200 Subject: use the default setting and also add the mode to the cipher. aes-128 is to be preferred over aes-256 according to bruce schneier https://www.schneier.com/blog/archives/2009/07/another_new_aes.html#c386957 --- Zotlabs/Lib/ThreadStream.php | 2 +- Zotlabs/Module/Chat.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index f54b3f6c2..68b2c70dd 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -23,7 +23,7 @@ class ThreadStream { private $preview = false; private $prepared_item = ''; public $reload = ''; - private $cipher = 'AES-256'; + private $cipher = 'AES-128-CCM'; // $prepared_item is for use by alternate conversation structures such as photos // wherein we've already prepared a top level item which doesn't look anything like diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php index 66ba42d33..28e775f9d 100644 --- a/Zotlabs/Module/Chat.php +++ b/Zotlabs/Module/Chat.php @@ -197,7 +197,7 @@ class Chat extends Controller { $cipher = get_pconfig(local_channel(),'system','default_cipher'); if(! $cipher) - $cipher = 'AES-256'; + $cipher = 'AES-128-CCM'; $o = replace_macros(get_markup_template('chat.tpl'),array( -- cgit v1.2.3 From c53794a8a2bd4c6100d4c5f8e7785c8436b454fa Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 23 Aug 2020 19:17:23 +0200 Subject: an attempt to fix update 1238 for older hubs with broken xchan entries --- Zotlabs/Module/Fhubloc_id_url.php | 11 ++++++----- Zotlabs/Update/_1238.php | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php index d332c7400..1ecb6f1e0 100644 --- a/Zotlabs/Module/Fhubloc_id_url.php +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -9,7 +9,10 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { if(! is_site_admin()) return; - + + // completely remove broken xchan entries + $r = dbq("DELETE FROM xchan WHERE xchan_hash = ''"); + // fix legacy zot hubloc_id_url $r1 = dbq("UPDATE hubloc SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1)) @@ -23,8 +26,7 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { $r2 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' - AND xchan_url = '' - AND xchan_hash != ''" + AND xchan_url = ''" ); $r3 = dbq("UPDATE hubloc @@ -40,8 +42,7 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { $r2 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' - AND xchan_url = '' - AND xchan_hash != ''" + AND xchan_url = ''" ); $r3 = dbq("UPDATE hubloc diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 32c21f161..2a10e594f 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -12,6 +12,9 @@ class _1238 { dbesc('Premium Channel') ); + // completely remove broken xchan entries + $r = dbq("DELETE FROM xchan WHERE xchan_hash = ''"); + // fix legacy zot hubloc_id_url $r1 = dbq("UPDATE hubloc SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1)) @@ -25,8 +28,7 @@ class _1238 { $r2 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' - AND xchan_url = '' - AND xchan_hash != ''" + AND xchan_url = ''" ); $r3 = dbq("UPDATE hubloc @@ -41,8 +43,7 @@ class _1238 { $r2 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' - AND xchan_url = '' - AND xchan_hash != ''" + AND xchan_url = ''" ); $r3 = dbq("UPDATE hubloc -- cgit v1.2.3 From 0189d06375320b3a6766f3b713a2e10533e97bb5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 24 Aug 2020 13:44:30 +0200 Subject: provide some sort of feedback --- Zotlabs/Module/Fhubloc_id_url.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php index 1ecb6f1e0..6303e2460 100644 --- a/Zotlabs/Module/Fhubloc_id_url.php +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -55,5 +55,10 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { } + + if($r && $r1 && $r2 && $r3) + return 'Completed'; + else + return 'Failed'; } } -- cgit v1.2.3 From 6177ec9134b458865ebf382a6e03827bb1834365 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 24 Aug 2020 20:31:59 +0200 Subject: prefix table names --- Zotlabs/Module/Fhubloc_id_url.php | 8 ++++---- Zotlabs/Update/_1238.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php index 6303e2460..eb86b702d 100644 --- a/Zotlabs/Module/Fhubloc_id_url.php +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -30,10 +30,10 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { ); $r3 = dbq("UPDATE hubloc - LEFT JOIN xchan ON hubloc_hash = xchan_hash - SET hubloc_id_url = xchan_url - WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = ''" + LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash + SET hubloc.hubloc_id_url = xchan.xchan_url + WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc.hubloc_id_url = ''" ); } diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 2a10e594f..533358219 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -32,10 +32,10 @@ class _1238 { ); $r3 = dbq("UPDATE hubloc - LEFT JOIN xchan ON hubloc_hash = xchan_hash - SET hubloc_id_url = xchan_url - WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = ''" + LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash + SET hubloc.hubloc_id_url = xchan.xchan_url + WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc.hubloc_id_url = ''" ); } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { -- cgit v1.2.3 From 1fbc6fa431aa820382f1a457644f5307efc68c90 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 25 Aug 2020 06:48:22 +0200 Subject: add check against null --- Zotlabs/Module/Fhubloc_id_url.php | 6 ++++-- Zotlabs/Update/_1238.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php index eb86b702d..3d27df4fa 100644 --- a/Zotlabs/Module/Fhubloc_id_url.php +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -33,7 +33,8 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash SET hubloc.hubloc_id_url = xchan.xchan_url WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc.hubloc_id_url = ''" + AND hubloc.hubloc_id_url = '' + AND xchan.xchan_url IS NOT NULL" ); } @@ -50,7 +51,8 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { FROM xchan WHERE hubloc_hash = xchan_hash AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = ''" + AND hubloc_id_url = '' + AND xchan_url IS NOT NULL" ); diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 533358219..364763ee4 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -35,7 +35,8 @@ class _1238 { LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash SET hubloc.hubloc_id_url = xchan.xchan_url WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc.hubloc_id_url = ''" + AND hubloc.hubloc_id_url = '' + AND xchan.xchan_url IS NOT NULL" ); } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { @@ -51,7 +52,8 @@ class _1238 { FROM xchan WHERE hubloc_hash = xchan_hash AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = ''" + AND hubloc_id_url = '' + AND xchan_url IS NOT NULL" ); } -- cgit v1.2.3 From 5aaa8f44a284a9c6c69f0c4bb11d59cb3c048b36 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 26 Aug 2020 20:15:21 +0200 Subject: remove hublocs without a hubloc_hash and also remove hublocs where hubloc_id_url could not be fixed --- Zotlabs/Module/Fhubloc_id_url.php | 33 +++++++++++++++++++++++---------- Zotlabs/Update/_1238.php | 24 ++++++++++++++++-------- 2 files changed, 39 insertions(+), 18 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php index 3d27df4fa..a5627a33d 100644 --- a/Zotlabs/Module/Fhubloc_id_url.php +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -10,11 +10,16 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { if(! is_site_admin()) return; - // completely remove broken xchan entries - $r = dbq("DELETE FROM xchan WHERE xchan_hash = ''"); + q("START TRANSACTION"); + + // remove broken xchan entries + $r0 = dbq("DELETE FROM xchan WHERE xchan_hash = ''"); + + // remove broken hubloc entries + $r1 = dbq("DELETE FROM hubloc WHERE hubloc_hash = ''"); // fix legacy zot hubloc_id_url - $r1 = dbq("UPDATE hubloc + $r2 = dbq("UPDATE hubloc SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1)) WHERE hubloc_network = 'zot' AND hubloc_id_url = ''" @@ -23,13 +28,13 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { // fix singleton networks hubloc_id_url if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { // fix entries for activitypub which miss the xchan_url due to an earlier bug - $r2 = dbq("UPDATE xchan + $r3 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' AND xchan_url = ''" ); - $r3 = dbq("UPDATE hubloc + $r4 = dbq("UPDATE hubloc LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash SET hubloc.hubloc_id_url = xchan.xchan_url WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') @@ -40,13 +45,13 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { // fix entries for activitypub which miss the xchan_url due to an earlier bug - $r2 = dbq("UPDATE xchan + $r3 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' AND xchan_url = ''" ); - $r3 = dbq("UPDATE hubloc + $r4 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash @@ -58,9 +63,17 @@ class Fhubloc_id_url extends \Zotlabs\Web\Controller { } - if($r && $r1 && $r2 && $r3) + if($r0 && $r1 && $r2 && $r3 && $r4) { + // remove hubloc entries where hubloc_id_url could not be fixed + $r5 = dbq("DELETE FROM hubloc WHERE hubloc_id_url = ''"); + } + + if($r0 && $r1 && $r2 && $r3 && $r4 && $r5) { + q("COMMIT"); return 'Completed'; - else - return 'Failed'; + } + + q("ROLLBACK"); + return 'Failed'; } } diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 364763ee4..1c79cc36e 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -12,11 +12,14 @@ class _1238 { dbesc('Premium Channel') ); - // completely remove broken xchan entries - $r = dbq("DELETE FROM xchan WHERE xchan_hash = ''"); + // remove broken xchan entries + $r0 = dbq("DELETE FROM xchan WHERE xchan_hash = ''"); + + // remove broken hubloc entries + $r1 = dbq("DELETE FROM hubloc WHERE hubloc_hash = ''"); // fix legacy zot hubloc_id_url - $r1 = dbq("UPDATE hubloc + $r2 = dbq("UPDATE hubloc SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1)) WHERE hubloc_network = 'zot' AND hubloc_id_url = ''" @@ -25,13 +28,13 @@ class _1238 { // fix singleton networks hubloc_id_url if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { // fix entries for activitypub which miss the xchan_url due to an earlier bug - $r2 = dbq("UPDATE xchan + $r3 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' AND xchan_url = ''" ); - $r3 = dbq("UPDATE hubloc + $r4 = dbq("UPDATE hubloc LEFT JOIN xchan ON hubloc.hubloc_hash = xchan.xchan_hash SET hubloc.hubloc_id_url = xchan.xchan_url WHERE hubloc.hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') @@ -41,13 +44,13 @@ class _1238 { } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { // fix entries for activitypub which miss the xchan_url due to an earlier bug - $r2 = dbq("UPDATE xchan + $r3 = dbq("UPDATE xchan SET xchan_url = xchan_hash WHERE xchan_network = 'activitypub' AND xchan_url = ''" ); - $r3 = dbq("UPDATE hubloc + $r4 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash @@ -57,7 +60,12 @@ class _1238 { ); } - if($r1 && $r2 && $r3) { + if($r0 && $r1 && $r2 && $r3 && $r4) { + // remove hubloc entries where hubloc_id_url could not be fixed + $r5 = dbq("DELETE FROM hubloc WHERE hubloc_id_url = ''"); + } + + if($r0 && $r1 && $r2 && $r3 && $r4 && $r5) { q("COMMIT"); return UPDATE_SUCCESS; } -- cgit v1.2.3 From 1b161b0ee4d16711dc6540b14f50f20b68a7b565 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 26 Aug 2020 21:13:32 +0200 Subject: move z6trans_connections() to cron from cron daily --- Zotlabs/Daemon/Cron.php | 5 +++++ Zotlabs/Daemon/Cron_daily.php | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index 46f4e4071..703d6ce08 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -155,6 +155,11 @@ class Cron { } } + + // check if any connections transitioned to zot6 and upgrade the connections to zot6 at this hub if so. + require_once('include/connections.php'); + z6trans_connections(); + require_once('include/attach.php'); attach_upgrade(); diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index 2cf0c9119..07533cc6e 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -98,7 +98,6 @@ class Cron_daily { remove_obsolete_hublocs(); z6_discover(); - z6trans_connections(); call_hooks('cron_daily',datetime_convert()); -- cgit v1.2.3 From ff09b2131e6ba7045d5afd65adfd49e427617afc Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 11 Sep 2020 12:11:09 +0000 Subject: disable community tags until we agree on how to implemnt this in zot6/activitypub --- Zotlabs/Lib/ThreadItem.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index fadc38b38..024502d2a 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -287,12 +287,16 @@ class ThreadItem { $settings = ''; + $tagger = []; + // FIXME - check this permission if($conv->get_profile_owner() == local_channel()) { + /* disable until we agree on how to implemnt this in zot6/activitypub $tagger = array( 'tagit' => t("Add Tag"), 'classtagger' => "", ); + */ $settings = t('Conversation Tools'); } -- cgit v1.2.3 From 4acdf9e8177187cf3921b0bce27e9a476d3ad617 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 16 Sep 2020 09:16:27 +0000 Subject: deprecate $a variable for *_plugin_admin() and *_plugin_admin_post() --- Zotlabs/Module/Admin/Addons.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Addons.php b/Zotlabs/Module/Admin/Addons.php index 243eb242f..b67ab7b3a 100644 --- a/Zotlabs/Module/Admin/Addons.php +++ b/Zotlabs/Module/Admin/Addons.php @@ -18,7 +18,7 @@ class Addons { @include_once("addon/" . argv(2) . "/" . argv(2) . ".php"); if(function_exists(argv(2).'_plugin_admin_post')) { $func = argv(2) . '_plugin_admin_post'; - $func($a); + $func(); } goaway(z_root() . '/admin/addons/' . argv(2) ); @@ -332,7 +332,7 @@ class Addons { @require_once("addon/$plugin/$plugin.php"); if(function_exists($plugin.'_plugin_admin')) { $func = $plugin.'_plugin_admin'; - $func($a, $admin_form); + $func($admin_form); } } -- cgit v1.2.3 From 9299aff2af7e1821ee4066c55b4a9e0a3ca900f5 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 18 Sep 2020 13:43:01 +0200 Subject: Boost DB conversion speed to Z6 --- Zotlabs/Module/Z6trans.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Z6trans.php b/Zotlabs/Module/Z6trans.php index 58dc09a51..31132bbe3 100644 --- a/Zotlabs/Module/Z6trans.php +++ b/Zotlabs/Module/Z6trans.php @@ -71,13 +71,31 @@ class Z6trans extends Controller { } } + + $zot = dbesc($zot_xchan); + $zot6 = dbesc($zot6_xchan); + + // Item table + foreach(['owner_xchan', 'author_xchan'] as $x) { + $q .= sprintf("UPDATE item SET $x = '%s' WHERE $x = '%s';\r\n", + $zot6, + $zot + ); + } + $q .= "UPDATE item SET source_xchan = replace(source_xchan, '$zot', '$zot6'), route = replace(route, '$zot', '$zot6'), allow_cid = replace(allow_cid, '$zot', '$zot6'), deny_cid = replace(deny_cid, '$zot', '$zot6');\r\n"; + + // photo table + $q .= "UPDATE photo SET xchan = replace(xchan, '$zot', '$zot6'), allow_cid = replace(allow_cid, '$zot', '$zot6'), deny_cid = replace(deny_cid, '$zot', '$zot6');\r\n"; + // dreport table + $q .= "UPDATE dreport SET dreport_recip = '$zot6' WHERE dreport_recip = '$zot';\r\n"; + $q .= "UPDATE dreport SET dreport_xchan = '$zot6' WHERE dreport_xchan = '$zot';\r\n"; } if($q) file_put_contents($path, $q); - $o = '

' . t('Update to Hubzilla 5.0 setp 2') . '


'; + $o = '

' . t('Update to Hubzilla 5.0 step 2') . '


'; $o .= '

' . t('To complete the update please run') . '

'; if(ACTIVE_DBTYPE == DBTYPE_MYSQL) @@ -103,16 +121,16 @@ class Z6trans extends Controller { 'chatpresence' => ['cp_xchan'], 'chatroom' => ['allow_cid', 'deny_cid'], 'config' => ['v'], - 'dreport' => ['dreport_recip', 'dreport_xchan'], +// 'dreport' => ['dreport_recip', 'dreport_xchan'], 'event' => ['event_xchan', 'allow_cid', 'deny_cid'], 'iconfig' => ['v'], - 'item' => ['owner_xchan', 'author_xchan', 'source_xchan', 'route', 'allow_cid', 'deny_cid'], +// 'item' => ['owner_xchan', 'author_xchan', 'source_xchan', 'route', 'allow_cid', 'deny_cid'], 'mail' => ['from_xchan', 'to_xchan'], 'menu_item' => ['allow_cid', 'deny_cid'], 'obj' => ['allow_cid', 'deny_cid'], 'pconfig' => ['v'], 'pgrp_member' => ['xchan'], - 'photo' => ['xchan', 'allow_cid', 'deny_cid'], +// 'photo' => ['xchan', 'allow_cid', 'deny_cid'], 'source' => ['src_channel_xchan', 'src_xchan'], 'updates' => ['ud_hash'], 'xchat' => ['xchat_xchan'], -- cgit v1.2.3 From 9c8d73208123a2566aa44db4dfe53201cc8cb3ab Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 19 Sep 2020 19:19:03 +0000 Subject: 5.0RC testing: their_perms should be reset before they are recreated. Otherwise withdrawn permissions will not take effect locally. --- Zotlabs/Lib/Libzot.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index dda6d5d95..f4eb26463 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -316,14 +316,22 @@ class Libzot { $x = self::import_xchan($record['data'], (($force) ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED)); + if(! $x['success']) return false; if($channel && $record['data']['permissions']) { $permissions = explode(',',$record['data']['permissions']); + if($permissions && is_array($permissions)) { $old_read_stream_perm = get_abconfig($channel['channel_id'],$x['hash'],'their_perms','view_stream'); + // We need to reset their_perms prior to setting the new ones. + // Otherwise withdrawn permissions will not take effect locally. + q("DELETE FROM abconfig WHERE chan = %d AND xchan = '%s' AND cat = 'their_perms'", + intval($channel['channel_id']), + dbesc($x['hash']) + ); foreach($permissions as $p) { set_abconfig($channel['channel_id'],$x['hash'],'their_perms',$p,'1'); } -- cgit v1.2.3 From c38fc0b9067382b91dcd26b4da9742fd9d650f6c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 Sep 2020 16:49:36 +0200 Subject: adapt mod z6trans to point to util/z6convert.php in case anyone stumbles over outdated doco. --- Zotlabs/Module/Z6trans.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Z6trans.php b/Zotlabs/Module/Z6trans.php index 31132bbe3..72667316f 100644 --- a/Zotlabs/Module/Z6trans.php +++ b/Zotlabs/Module/Z6trans.php @@ -14,7 +14,19 @@ class Z6trans extends Controller { function get() { if(!is_site_admin()) - return 'Not Allowed'; + return '

Not Allowed

'; + + $o = '

' . t('Update to Hubzilla 5.0 step 2') . '


'; + + $o .= '

' . t('To complete the update please run') . '

'; + + $o .= '' . t('php util/z6convert.php') . ''; + + $o .= '

' . t('from the terminal.') . '

'; + + return $o; + +/* this code is outdated use util/z6convert.php instead $path = 'store/z6trans.sql'; @@ -106,6 +118,7 @@ class Z6trans extends Controller { $o .= '

' . t('INFO: this command can take a very long time depending on your DB size.') . '

'; return $o; +*/ } -- cgit v1.2.3 From 34217f5f901ae4dca180bceccef425de1eef4aeb Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 19 Sep 2020 23:45:37 +0000 Subject: apply channel name changes to all associated xchans (cherry picked from commit f2ac1e4b7d2aa4854ed08ded49b2ed2dd10fab59) --- Zotlabs/Module/Profiles.php | 4 ++-- Zotlabs/Module/Settings/Channel.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 7deceabab..645d74add 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -607,10 +607,10 @@ class Profiles extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); if($namechanged && $is_default) { - $r = q("UPDATE xchan SET xchan_name = '%s', xchan_name_date = '%s' WHERE xchan_hash = '%s'", + $r = q("UPDATE xchan SET xchan_name = '%s', xchan_name_date = '%s' WHERE xchan_url = '%s'", dbesc($name), dbesc(datetime_convert()), - dbesc($channel['xchan_hash']) + dbesc(z_root() . '/channel/' . $channel['xchan_address']) ); $r = q("UPDATE channel SET channel_name = '%s' WHERE channel_hash = '%s'", dbesc($name), diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index ab9b72490..2eed1efc9 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -274,10 +274,11 @@ class Channel { } if($name_change) { - $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_hash = '%s'", + // change name on all associated xchans by matching the url + $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_url = '%s'", dbesc($username), dbesc(datetime_convert()), - dbesc($channel['channel_hash']) + dbesc(z_root() . '/channel/' . $channel['channel_address']) ); $r = q("update profile set fullname = '%s' where uid = %d and is_default = 1", dbesc($username), -- cgit v1.2.3 From f422362747e6def2feffe99aa8a2e555be3b409b Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 19 Sep 2020 23:49:15 +0000 Subject: use channel index (cherry picked from commit 846d30239d97091d1e6b56e923c1965471f6bbff) --- Zotlabs/Module/Profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 645d74add..9ac0e725e 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -610,7 +610,7 @@ class Profiles extends \Zotlabs\Web\Controller { $r = q("UPDATE xchan SET xchan_name = '%s', xchan_name_date = '%s' WHERE xchan_url = '%s'", dbesc($name), dbesc(datetime_convert()), - dbesc(z_root() . '/channel/' . $channel['xchan_address']) + dbesc(z_root() . '/channel/' . $channel['channel_address']) ); $r = q("UPDATE channel SET channel_name = '%s' WHERE channel_hash = '%s'", dbesc($name), -- cgit v1.2.3 From 81e2f73c9870b502ab0b56009459932282f87f02 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 23 Sep 2020 09:48:14 +0000 Subject: 5.0RC testing: fix mod locs --- Zotlabs/Module/Locs.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Locs.php b/Zotlabs/Module/Locs.php index 47ece8041..63ca763a9 100644 --- a/Zotlabs/Module/Locs.php +++ b/Zotlabs/Module/Locs.php @@ -1,16 +1,18 @@ Date: Wed, 23 Sep 2020 11:44:10 +0000 Subject: 5.0RC testing: update hublocs by hubloc_id_url of we mark it deleted or change primary to catch both zot and zot6 hublocs. only set the zot6 hubloc as primary. --- Zotlabs/Lib/Libsync.php | 16 ++++++++-------- Zotlabs/Module/Locs.php | 16 +++++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index b7cda1770..b16080a51 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -819,9 +819,9 @@ class Libsync { } if(intval($r[0]['hubloc_primary']) && (! $location['primary'])) { - $m = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_id = %d", + $m = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), - intval($r[0]['hubloc_id']) + intval($r[0]['hubloc_id_url']) ); $r[0]['hubloc_primary'] = intval($location['primary']); hubloc_change_primary($r[0]); @@ -848,18 +848,18 @@ class Libsync { } } if(intval($r[0]['hubloc_deleted']) && (! intval($location['deleted']))) { - $n = q("update hubloc set hubloc_deleted = 0, hubloc_updated = '%s' where hubloc_id = %d", + $n = q("update hubloc set hubloc_deleted = 0, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), - intval($r[0]['hubloc_id']) + dbesc($r[0]['hubloc_id_url']) ); $what .= 'undelete_hub '; $changed = true; } elseif((! intval($r[0]['hubloc_deleted'])) && (intval($location['deleted']))) { logger('deleting hubloc: ' . $r[0]['hubloc_addr']); - $n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d", + $n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), - intval($r[0]['hubloc_id']) + dbesc($r[0]['hubloc_id_url']) ); $what .= 'delete_hub '; $changed = true; @@ -918,9 +918,9 @@ class Libsync { foreach($xisting as $x) { if(! array_key_exists('updated',$x)) { logger('Deleting unreferenced hub location ' . $x['hubloc_addr']); - $r = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d", + $r = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), - intval($x['hubloc_id']) + dbesc($x['hubloc_id_url']) ); $what .= 'removed_hub '; $changed = true; diff --git a/Zotlabs/Module/Locs.php b/Zotlabs/Module/Locs.php index 63ca763a9..4c935a6a2 100644 --- a/Zotlabs/Module/Locs.php +++ b/Zotlabs/Module/Locs.php @@ -18,7 +18,7 @@ class Locs extends Controller { $hubloc_id = intval($_REQUEST['primary']); if($hubloc_id) { - $r = q("select hubloc_id from hubloc where hubloc_id = %d and hubloc_hash = '%s' limit 1", + $r = q("select * from hubloc where hubloc_id = %d and hubloc_hash = '%s' limit 1", intval($hubloc_id), dbesc($channel['channel_hash']) ); @@ -28,10 +28,11 @@ class Locs extends Controller { return; } - $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' ", - dbesc($channel['channel_hash']) + q("UPDATE hubloc SET hubloc_primary = 0 WHERE hubloc_primary = 1 AND (hubloc_hash = '%s' OR hubloc_hash = '%s')", + dbesc($channel['channel_hash']), + dbesc($channel['channel_portable_id']) ); - $r = q("update hubloc set hubloc_primary = 1 where hubloc_id = %d and hubloc_hash = '%s'", + q("UPDATE hubloc SET hubloc_primary = 1 WHERE hubloc_id = %d AND hubloc_hash = '%s'", intval($hubloc_id), dbesc($channel['channel_hash']) ); @@ -70,9 +71,10 @@ class Locs extends Controller { } } - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d and hubloc_hash = '%s'", - intval($hubloc_id), - dbesc($channel['channel_hash']) + q("UPDATE hubloc SET hubloc_deleted = 1 WHERE hubloc_id_url = '%s' AND (hubloc_hash = '%s' OR hubloc_hash = '%s')", + dbesc($r[0]['hubloc_id_url']), + dbesc($channel['channel_hash']), + dbesc($channel['channel_portable_id']) ); Master::Summon( [ 'Notifier', 'refresh_all', $channel['channel_id'] ] ); return; -- cgit v1.2.3 From 42ef6208c14ac579c1071ea880664dbcd42df907 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 23 Sep 2020 11:50:30 +0000 Subject: 5.0RC testing: do not use intval() on hubloc_id_url --- Zotlabs/Lib/Libsync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index b16080a51..cff320e11 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -821,7 +821,7 @@ class Libsync { if(intval($r[0]['hubloc_primary']) && (! $location['primary'])) { $m = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_id_url = '%s'", dbesc(datetime_convert()), - intval($r[0]['hubloc_id_url']) + dbesc($r[0]['hubloc_id_url']) ); $r[0]['hubloc_primary'] = intval($location['primary']); hubloc_change_primary($r[0]); -- cgit v1.2.3 From 5edec37d571b79dc4fcc30aac1c48b2fc1ae66c9 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 23 Sep 2020 12:14:16 +0000 Subject: 5.0RC testing: comment out global remove --- Zotlabs/Module/Removeaccount.php | 4 ++-- Zotlabs/Module/Removeme.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Removeaccount.php b/Zotlabs/Module/Removeaccount.php index 9d2bbd0de..cd18b79c0 100644 --- a/Zotlabs/Module/Removeaccount.php +++ b/Zotlabs/Module/Removeaccount.php @@ -37,7 +37,7 @@ class Removeaccount extends \Zotlabs\Web\Controller { } } - $global_remove = intval($_POST['global']); + $global_remove = 0; //intval($_POST['global']); account_remove($account_id, 1 - $global_remove); } @@ -57,7 +57,7 @@ class Removeaccount extends \Zotlabs\Web\Controller { '$title' => t('Remove This Account'), '$desc' => array(t('WARNING: '), t('This account and all its channels will be completely removed from the network. '), t('This action is permanent and can not be undone!')), '$passwd' => t('Please enter your password for verification:'), - '$global' => array('global', t('Remove this account, all its channels and all its channel clones from the network'), false, t('By default only the instances of the channels located on this hub will be removed from the network')), + // '$global' => array('global', t('Remove this account, all its channels and all its channel clones from the network'), false, t('By default only the instances of the channels located on this hub will be removed from the network')), '$submit' => t('Remove Account') )); diff --git a/Zotlabs/Module/Removeme.php b/Zotlabs/Module/Removeme.php index 451e280c3..876d61ca6 100644 --- a/Zotlabs/Module/Removeme.php +++ b/Zotlabs/Module/Removeme.php @@ -37,7 +37,7 @@ class Removeme extends \Zotlabs\Web\Controller { } } - $global_remove = intval($_POST['global']); + $global_remove = 0; //intval($_POST['global']); channel_remove(local_channel(),1 - $global_remove,true); @@ -60,7 +60,7 @@ class Removeme extends \Zotlabs\Web\Controller { '$title' => t('Remove This Channel'), '$desc' => [ t('WARNING: '), t('This channel will be completely removed from the network. '), t('This action is permanent and can not be undone!') ], '$passwd' => t('Please enter your password for verification:'), - '$global' => [ 'global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network'), [ t('No'),t('Yes') ] ], + // '$global' => [ 'global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network'), [ t('No'),t('Yes') ] ], '$submit' => t('Remove Channel') )); -- cgit v1.2.3 From d23e8309555640ddbb909d2ef32baa0936d0c34b Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 23 Sep 2020 14:28:04 +0000 Subject: port mod gprobe --- Zotlabs/Daemon/Gprobe.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Gprobe.php b/Zotlabs/Daemon/Gprobe.php index f1ffb2d81..da92fbec7 100644 --- a/Zotlabs/Daemon/Gprobe.php +++ b/Zotlabs/Daemon/Gprobe.php @@ -2,7 +2,9 @@ namespace Zotlabs\Daemon; -require_once('include/zot.php'); +use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Webfinger; +use Zotlabs\Lib\Zotfinger; // performs zot_finger on $argv[1], which is a hex_encoded webbie/reddress @@ -22,12 +24,16 @@ class Gprobe { ); if(! $r) { - $j = \Zotlabs\Zot\Finger::run($url,null); - if($j['success']) { - $y = import_xchan($j); + $href = Webfinger::zot_url(punify($url)); + if($href) { + $zf = Zotfinger::exec($href,$channel); + } + if(is_array($zf) && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) { + $xc = Libzot::import_xchan($zf['data']); } } return; + } } -- cgit v1.2.3 From 2fe2cc5e6562490d7bcab5e4a74e2aa61c512ddb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 25 Sep 2020 12:44:44 +0200 Subject: 5.0RC testing: channel is not set and not required here --- Zotlabs/Daemon/Gprobe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Gprobe.php b/Zotlabs/Daemon/Gprobe.php index da92fbec7..6951aa1d4 100644 --- a/Zotlabs/Daemon/Gprobe.php +++ b/Zotlabs/Daemon/Gprobe.php @@ -26,7 +26,7 @@ class Gprobe { if(! $r) { $href = Webfinger::zot_url(punify($url)); if($href) { - $zf = Zotfinger::exec($href,$channel); + $zf = Zotfinger::exec($href, null); } if(is_array($zf) && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) { $xc = Libzot::import_xchan($zf['data']); -- cgit v1.2.3 From 2c316c788e89ab0d9a64a4a1490c7074d1e5c3da Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 25 Sep 2020 13:41:21 +0200 Subject: port mod chanview --- Zotlabs/Module/Chanview.php | 56 +++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index 20ac41fbe..1c476d125 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -1,13 +1,17 @@ Date: Fri, 25 Sep 2020 13:47:40 +0200 Subject: if we do not have App::$poi here we would already have returned. No need to check here. --- Zotlabs/Module/Chanview.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index 1c476d125..06ff10f9e 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -99,19 +99,17 @@ class Chanview extends \Zotlabs\Web\Controller { $is_zot = false; $connected = false; - if (App::$poi) { - $url = App::$poi['xchan_url']; - if(in_array(App::$poi['xchan_network'], ['zot', 'zot6'])) { - $is_zot = true; - } - if(local_channel()) { - $c = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s' limit 1", - intval(local_channel()), - dbesc(App::$poi['xchan_hash']) - ); - if($c) - $connected = true; - } + $url = App::$poi['xchan_url']; + if(in_array(App::$poi['xchan_network'], ['zot', 'zot6'])) { + $is_zot = true; + } + if(local_channel()) { + $c = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s' limit 1", + intval(local_channel()), + dbesc(App::$poi['xchan_hash']) + ); + if($c) + $connected = true; } // We will load the chanview template if it's a foreign network, -- cgit v1.2.3 From 3f784a974a1ccc15f69865f8015b0c36fd7bc1d7 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 26 Sep 2020 15:05:16 +0200 Subject: deprecate \Zotlabs\Zot\Finger where apropriate --- Zotlabs/Module/Magic.php | 237 +++++++++++++++------------------------------- Zotlabs/Module/Owa.php | 95 ++++++++----------- Zotlabs/Module/Regdir.php | 35 ++++--- 3 files changed, 131 insertions(+), 236 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 6ac656a04..b4372e26d 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -1,214 +1,133 @@ false, + 'url' => '', + 'message' => '' + ]; - $ret = array('success' => false, 'url' => '', 'message' => ''); logger('mod_magic: invoked', LOGGER_DEBUG); - - logger('mod_magic: args: ' . print_r($_REQUEST,true),LOGGER_DATA); - - $addr = ((x($_REQUEST,'addr')) ? $_REQUEST['addr'] : ''); - $bdest = ((x($_REQUEST,'bdest')) ? $_REQUEST['bdest'] : ''); - $dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : ''); - $test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0); - $rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0); - $owa = ((x($_REQUEST,'owa')) ? intval($_REQUEST['owa']) : 0); - $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : ''); - - if($bdest) + + logger('args: ' . print_r($_REQUEST,true),LOGGER_DATA); + + $addr = ((x($_REQUEST,'addr')) ? $_REQUEST['addr'] : ''); + $bdest = ((x($_REQUEST,'bdest')) ? $_REQUEST['bdest'] : ''); + $dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : ''); + $rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0); + $owa = ((x($_REQUEST,'owa')) ? intval($_REQUEST['owa']) : 0); + $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : ''); + + // bdest is preferred as it is hex-encoded and can survive url rewrite and argument parsing + + if ($bdest) { $dest = hex2bin($bdest); + } $parsed = parse_url($dest); - if(! $parsed) { - if($test) { - $ret['message'] .= 'could not parse ' . $dest . EOL; - return($ret); - } + + if (! $parsed) { goaway($dest); } - + $basepath = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : ''); - - $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1", - dbesc($basepath) - ); - - if(! $x) { - - /* - * We have no records for, or prior communications with this hub. - * If an address was supplied, let's finger them to create a hub record. - * Otherwise we'll use the special address '[system]' which will return - * either a system channel or the first available normal channel. We don't - * really care about what channel is returned - we need the hub information - * from that response so that we can create signed auth packets destined - * for that hub. - * - */ - - $j = \Zotlabs\Zot\Finger::run((($addr) ? $addr : '[system]@' . $parsed['host']),null); - if($j['success']) { - import_xchan($j); - - // Now try again - - $x = q("select * from hubloc where hubloc_url = '%s' order by hubloc_connected desc limit 1", - dbesc($basepath) - ); - } - } - - if(! $x) { - if($rev) - goaway($dest); - else { - logger('mod_magic: no channels found for requested hub.' . print_r($_REQUEST,true)); - if($test) { - $ret['message'] .= 'This site has no previous connections with ' . $basepath . EOL; - return $ret; - } - notice( t('Hub not found.') . EOL); - return; - } - } - + $owapath = SConfig::get($basepath,'system','openwebauth', $basepath . '/owa'); + // This is ready-made for a plugin that provides a blacklist or "ask me" before blindly authenticating. // By default, we'll proceed without asking. - - $arr = array( - 'channel_id' => local_channel(), - 'xchan' => $x[0], + + $arr = [ + 'channel_id' => local_channel(), 'destination' => $dest, - 'proceed' => true - ); - + 'proceed' => true + ]; + call_hooks('magic_auth',$arr); $dest = $arr['destination']; - if(! $arr['proceed']) { - if($test) { - $ret['message'] .= 'cancelled by plugin.' . EOL; - return $ret; - } + if (! $arr['proceed']) { goaway($dest); } - - if((get_observer_hash()) && ($x[0]['hubloc_url'] === z_root())) { + + if((get_observer_hash()) && (stripos($dest,z_root()) === 0)) { + // We are already authenticated on this site and a registered observer. - // Just redirect. - if($test) { - $ret['success'] = true; - $ret['message'] .= 'Local site - you are already authenticated.' . EOL; - return $ret; - } - - $delegation_success = false; - if($delegate) { + // First check if this is a delegate request on the local system and process accordingly. + // Otherwise redirect. + + if ($delegate) { + $r = q("select * from channel left join hubloc on channel_hash = hubloc_hash where hubloc_addr = '%s' limit 1", dbesc($delegate) ); - - if($r && intval($r[0]['channel_id'])) { - $allowed = perm_is_allowed($r[0]['channel_id'],get_observer_hash(),'delegate'); - if($allowed) { + + if ($r) { + $c = array_shift($r); + if (perm_is_allowed($c['channel_id'],get_observer_hash(),'delegate')) { $tmp = $_SESSION; - $_SESSION['delegate_push'] = $tmp; - $_SESSION['delegate_channel'] = $r[0]['channel_id']; - $_SESSION['delegate'] = get_observer_hash(); - $_SESSION['account_id'] = intval($r[0]['channel_account_id']); - change_channel($r[0]['channel_id']); - - $delegation_success = true; + $_SESSION['delegate_push'] = $tmp; + $_SESSION['delegate_channel'] = $c['channel_id']; + $_SESSION['delegate'] = get_observer_hash(); + $_SESSION['account_id'] = intval($c['channel_account_id']); + + change_channel($c['channel_id']); } } } - - - - // FIXME: check and honour local delegation - - + goaway($dest); } - - if(local_channel()) { - $channel = \App::get_channel(); - + + if (local_channel()) { + $channel = App::get_channel(); + // OpenWebAuth - if($owa) { + if ($owa) { $dest = strip_zids($dest); $dest = strip_query_param($dest,'f'); + // We now post to the OWA endpoint. This improves security by providing a signed digest + $data = json_encode([ 'OpenWebAuth' => random_string() ]); $headers = []; $headers['Accept'] = 'application/x-zot+json' ; + $headers['Content-Type'] = 'application/x-zot+json' ; $headers['X-Open-Web-Auth'] = random_string(); - $headers['Host'] = $parsed['host']; $headers['Digest'] = HTTPSig::generate_digest_header($data); + $headers['Host'] = $parsed['host']; + $headers['(request-target)'] = 'post ' . '/owa'; - $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], 'acct:' . channel_reddress($channel),true,'sha512'); - $x = z_post_url($basepath . '/owa',$data,$redirects,[ 'headers' => $headers ]); - - if($x['success']) { + $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], channel_url($channel),true,'sha512'); + $x = z_post_url($owapath,$data,$redirects,[ 'headers' => $headers ]); + logger('owa fetch returned: ' . print_r($x,true),LOGGER_DATA); + if ($x['success']) { $j = json_decode($x['body'],true); - if($j['success']) { + if ($j['success'] && $j['encrypted_token']) { + // decrypt the token using our private key $token = ''; - if($j['encrypted_token']) { - openssl_private_decrypt(base64url_decode($j['encrypted_token']),$token,$channel['channel_prvkey']); - } - else { - $token = $j['token']; - } - - $strp = strpbrk($dest,'?&'); - $args = (($strp) ? '&owt=' . $token : '?f=&owt=' . $token) . (($delegate) ? '&delegate=1' : ''); + openssl_private_decrypt(base64url_decode($j['encrypted_token']),$token,$channel['channel_prvkey']); + $x = strpbrk($dest,'?&'); + // redirect using the encrypted token which will be exchanged for an authenticated session + $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token) . (($delegate) ? '&delegate=1' : ''); goaway($dest . $args); } } - goaway($dest); - } - - - $token = random_string(); - - \Zotlabs\Lib\Verify::create('auth',$channel['channel_id'],$token,$x[0]['hubloc_url']); - - $target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode(channel_reddress($channel)) - . '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION; - - if($delegate) - $target_url .= '&delegate=' . urlencode($delegate); - - logger('mod_magic: redirecting to: ' . $target_url, LOGGER_DEBUG); - - if($test) { - $ret['success'] = true; - $ret['url'] = $target_url; - $ret['message'] = 'token ' . $token . ' created for channel ' . $channel['channel_id'] . ' for url ' . $x[0]['hubloc_url'] . EOL; - return $ret; } - - goaway($target_url); - } - - if($test) { - $ret['message'] = 'Not authenticated or invalid arguments to mod_magic' . EOL; - return $ret; - } - + goaway($dest); - } - + } diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index 4c6fd6216..561e35754 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -3,10 +3,12 @@ namespace Zotlabs\Module; use Zotlabs\Web\HTTPSig; +use Zotlabs\Lib\Verify; +use Zotlabs\Web\Controller; /** * OpenWebAuth verifier and token generator - * See https://macgirvin.com/wiki/mike/OpenWebAuth/Home + * See spec/OpenWebAuth/Home.md * Requests to this endpoint should be signed using HTTP Signatures * using the 'Authorization: Signature' authentication method * If the signature verifies a token is returned. @@ -14,74 +16,51 @@ use Zotlabs\Web\HTTPSig; * This token may be exchanged for an authenticated cookie. */ -class Owa extends \Zotlabs\Web\Controller { +class Owa extends Controller { function init() { $ret = [ 'success' => false ]; - foreach([ 'REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION' ] as $head) { - if(array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,9) === 'Signature') { - if($head !== 'HTTP_AUTHORIZATION') { - $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER[$head]; - continue; - } - - $sigblock = HTTPSig::parse_sigheader($_SERVER[$head]); - if($sigblock) { - $keyId = $sigblock['keyId']; - - if($keyId) { - - // Hubzilla connections can have both zot6 and zot hublocs - // The connections will usually be zot6 so match those first - - $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash - where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) and hubloc_network = 'zot6' ", - dbesc(str_replace('acct:','',$keyId)), - dbesc($keyId) - ); + if (array_key_exists('REDIRECT_REMOTE_USER',$_SERVER) && (! array_key_exists('HTTP_AUTHORIZATION',$_SERVER))) { + $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['REDIRECT_REMOTE_USER']; + } - // If nothing was found, try searching on any network - - if (! $r) { + if (array_key_exists('HTTP_AUTHORIZATION',$_SERVER) && substr(trim($_SERVER['HTTP_AUTHORIZATION']),0,9) === 'Signature') { + $sigblock = HTTPSig::parse_sigheader($_SERVER['HTTP_AUTHORIZATION']); + if ($sigblock) { + $keyId = $sigblock['keyId']; + if ($keyId) { + $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash + where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) ", + dbesc(str_replace('acct:','',$keyId)), + dbesc($keyId) + ); + if (! $r) { + $found = discover_by_webbie(str_replace('acct:','',$keyId)); + if ($found) { $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash - where ( hubloc_addr = '%s' or hubloc_id_url = '%s' )", + where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) ", dbesc(str_replace('acct:','',$keyId)), dbesc($keyId) ); } - - // If nothing was found on any network, use network discovery and create a new record - - if (! $r) { - $found = discover_by_webbie(str_replace('acct:','',$keyId)); - if($found) { - $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash - where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) ", - dbesc(str_replace('acct:','',$keyId)), - dbesc($keyId) - ); - } - } - - if ($r) { - foreach($r as $hubloc) { - $verified = HTTPSig::verify(file_get_contents('php://input'),$hubloc['xchan_pubkey']); - if($verified && $verified['header_signed'] && $verified['header_valid']) { - logger('OWA header: ' . print_r($verified,true),LOGGER_DATA); - logger('OWA success: ' . $hubloc['hubloc_addr'],LOGGER_DATA); - $ret['success'] = true; - $token = random_string(32); - \Zotlabs\Lib\Verify::create('owt',0,$token,$hubloc['hubloc_network'] . ',' . $hubloc['hubloc_addr']); - $result = ''; - openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']); - $ret['encrypted_token'] = base64url_encode($result); - break; - } - else { - logger('OWA fail: ' . $hubloc['hubloc_id'] . ' ' . $hubloc['hubloc_addr']); - } + } + if ($r) { + foreach ($r as $hubloc) { + $verified = HTTPSig::verify(file_get_contents('php://input')); + if ($verified && $verified['header_signed'] && $verified['header_valid'] && ($verified['content_valid'] || (! $verified['content_signed']))) { + logger('OWA header: ' . print_r($verified,true),LOGGER_DATA); + logger('OWA success: ' . $hubloc['hubloc_addr'],LOGGER_DATA); + $ret['success'] = true; + $token = random_string(32); + Verify::create('owt',0,$token,$hubloc['hubloc_addr']); + $result = ''; + openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']); + $ret['encrypted_token'] = base64url_encode($result); + break; + } else { + logger('OWA fail: ' . $hubloc['hubloc_id'] . ' ' . $hubloc['hubloc_addr']); } } } diff --git a/Zotlabs/Module/Regdir.php b/Zotlabs/Module/Regdir.php index f4d16c562..e49f89231 100644 --- a/Zotlabs/Module/Regdir.php +++ b/Zotlabs/Module/Regdir.php @@ -1,6 +1,9 @@ datetime_convert('UTC','UTC','2015-08-31')) ? ' and site_valid = 1 ' : '' ); if ($dirmode == DIRECTORY_MODE_STANDALONE) { $r = array(array('site_url' => z_root())); } else { - $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' and site_type = %d $sql_extra ", + $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' and site_type = %d and site_valid = 1 ", dbesc(get_directory_realm()), intval(SITE_TYPE_ZOT) ); -- cgit v1.2.3 From a80e59812bab4287f787bf5514de866c92024e08 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 28 Sep 2020 12:36:22 +0000 Subject: RC5.0 testing: fix purge and some cleanup --- Zotlabs/Daemon/Notifier.php | 64 ++++++++++++++++++----------- Zotlabs/Module/Connedit.php | 98 +++++++++++++++++++++++---------------------- 2 files changed, 90 insertions(+), 72 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 0efa93cce..ac35b4558 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -45,18 +45,18 @@ require_once('include/bbcode.php'); * * where COMMAND is one of the following: * - * activity (in diaspora.php, dfrn_confirm.php, profiles.php) - * comment-import (in diaspora.php, items.php) - * comment-new (in item.php) - * drop (in diaspora.php, items.php, photos.php) - * edit_post (in item.php) - * event (in events.php) - * expire (in items.php) - * like (in like.php, poke.php) - * mail (in message.php) - * tag (in photos.php, poke.php, tagger.php) - * tgroup (in items.php) - * wall-new (in photos.php, item.php) + * activity (in diaspora.php, dfrn_confirm.php, profiles.php) + * comment-import (in diaspora.php, items.php) + * comment-new (in item.php) + * drop (in diaspora.php, items.php, photos.php) + * edit_post (in item.php) + * event (in events.php) + * expire (in items.php) + * like (in like.php, poke.php) + * mail (in message.php) + * tag (in photos.php, poke.php, tagger.php) + * tgroup (in items.php) + * wall-new (in photos.php, item.php) * * and ITEM_ID is the id of the item in the database that needs to be sent to others. * @@ -66,9 +66,10 @@ require_once('include/bbcode.php'); * permission_reject abook_id * permission_update abook_id * refresh_all channel_id + * purge channel_id xchan_hash * purge_all channel_id * expire channel_id - * relay item_id (item was relayed to owner, we will deliver it as owner) + * relay item_id (item was relayed to owner, we will deliver it as owner) * single_activity item_id (deliver to a singleton network from the appropriate clone) * single_mail mail_id (deliver to a singleton network from the appropriate clone) * location channel_id @@ -240,25 +241,40 @@ class Notifier { $packet_type = 'location'; $location = true; } + elseif($cmd === 'purge') { + $xchan = $argv[3]; + logger('notifier: purge: ' . $item_id . ' => ' . $xchan); + if (! $xchan) { + return; + } + + $channel = channelx_by_n($item_id); + $recipients[] = $xchan; + $private = true; + $packet_type = 'purge'; + $packet_recips[] = ['hash' => $xchan]; + } elseif($cmd === 'purge_all') { + logger('notifier: purge_all: ' . $item_id); - $s = q("select * from channel where channel_id = %d limit 1", - intval($item_id) - ); - if($s) - $channel = $s[0]; - $uid = $item_id; - $recipients = array(); + $channel = channelx_by_n($item_id); + + $recipients = []; $r = q("select abook_xchan from abook where abook_channel = %d and abook_self = 0", intval($item_id) ); - if($r) { - foreach($r as $rr) { - $recipients[] = $rr['abook_xchan']; - } + if (! $r) { + return; + } + foreach ($r as $rr) { + $recipients[] = $rr['abook_xchan']; + $packet_recips[] = ['hash' => $rr['abook_xchan']]; } + $private = false; $packet_type = 'purge'; + + } else { diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index c0df57390..0fc807d42 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -7,9 +7,16 @@ namespace Zotlabs\Module; * */ +use App; use Zotlabs\Lib\Apps; use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Libsync; +use Zotlabs\Daemon\Master; +use Zotlabs\Web\Controller; +use Zotlabs\Access\Permissions; +use Zotlabs\Access\PermissionLimits; +use Zotlabs\Web\HTTPHeaders; +use Zotlabs\Lib\Permcat; require_once('include/socgraph.php'); require_once('include/selectors.php'); @@ -17,7 +24,7 @@ require_once('include/group.php'); require_once('include/photos.php'); -class Connedit extends \Zotlabs\Web\Controller { +class Connedit extends Controller { /* @brief Initialize the connection-editor * @@ -37,12 +44,12 @@ class Connedit extends \Zotlabs\Web\Controller { intval(argv(1)) ); if($r) { - \App::$poi = array_shift($r); + App::$poi = array_shift($r); } } - $channel = \App::get_channel(); + $channel = App::get_channel(); if($channel) head_set_icon($channel['xchan_photo_s']); @@ -62,7 +69,7 @@ class Connedit extends \Zotlabs\Web\Controller { if(! $contact_id) return; - $channel = \App::get_channel(); + $channel = App::get_channel(); // TODO if configured for hassle-free permissions, we'll post the form with ajax as soon as the // connection enable is toggled to a special autopost url and set permissions immediately, leaving @@ -141,7 +148,7 @@ class Connedit extends \Zotlabs\Web\Controller { $rating_text = trim(escape_tags($_REQUEST['rating_text'])); - $all_perms = \Zotlabs\Access\Permissions::Perms(); + $all_perms = Permissions::Perms(); if($all_perms) { foreach($all_perms as $perm => $desc) { @@ -213,7 +220,7 @@ class Connedit extends \Zotlabs\Web\Controller { $record = $z[0]['xlink_id']; } if($record) { - \Zotlabs\Daemon\Master::Summon(array('Ratenotif','rating',$record)); + Master::Summon(array('Ratenotif','rating',$record)); } } @@ -228,7 +235,7 @@ class Connedit extends \Zotlabs\Web\Controller { // request. The workaround is to approve the connection, then go back and // adjust permissions as desired. - $p = \Zotlabs\Access\Permissions::connect_perms(local_channel()); + $p = Permissions::connect_perms(local_channel()); $my_perms = $p['perms']; if($my_perms) { foreach($my_perms as $k => $v) { @@ -258,12 +265,12 @@ class Connedit extends \Zotlabs\Web\Controller { else notice( t('Failed to update connection record.') . EOL); - if(! intval(\App::$poi['abook_self'])) { + if(! intval(App::$poi['abook_self'])) { if($new_friend) { - \Zotlabs\Daemon\Master::Summon( [ 'Notifier', 'permission_accept', $contact_id ] ); + Master::Summon( [ 'Notifier', 'permission_accept', $contact_id ] ); } - \Zotlabs\Daemon\Master::Summon( [ + Master::Summon( [ 'Notifier', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id @@ -276,7 +283,7 @@ class Connedit extends \Zotlabs\Web\Controller { require_once('include/group.php'); $g = group_rec_byhash(local_channel(),$default_group); if($g) - group_add_member(local_channel(),'',\App::$poi['abook_xchan'],$g['id']); + group_add_member(local_channel(),'',App::$poi['abook_xchan'],$g['id']); } // Check if settings permit ("post new friend activity" is allowed, and @@ -300,19 +307,19 @@ class Connedit extends \Zotlabs\Web\Controller { $xarr['item_private'] = (($xarr['allow_cid']||$xarr['allow_gid']||$xarr['deny_cid']||$xarr['deny_gid']) ? 1 : 0); $obj = array( 'type' => ACTIVITY_OBJ_PERSON, - 'title' => \App::$poi['xchan_name'], - 'id' => \App::$poi['xchan_hash'], + 'title' => App::$poi['xchan_name'], + 'id' => App::$poi['xchan_hash'], 'link' => array( - array('rel' => 'alternate', 'type' => 'text/html', 'href' => \App::$poi['xchan_url']), - array('rel' => 'photo', 'type' => \App::$poi['xchan_photo_mimetype'], 'href' => \App::$poi['xchan_photo_l']) + array('rel' => 'alternate', 'type' => 'text/html', 'href' => App::$poi['xchan_url']), + array('rel' => 'photo', 'type' => App::$poi['xchan_photo_mimetype'], 'href' => App::$poi['xchan_photo_l']) ), ); $xarr['obj'] = json_encode($obj); $xarr['obj_type'] = ACTIVITY_OBJ_PERSON; - $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . \App::$poi['xchan_url'] . ']' . \App::$poi['xchan_name'] . '[/zrl]'; + $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . App::$poi['xchan_url'] . ']' . App::$poi['xchan_name'] . '[/zrl]'; - $xarr['body'] .= "\n\n\n" . '[zrl=' . \App::$poi['xchan_url'] . '][zmg=80x80]' . \App::$poi['xchan_photo_m'] . '[/zmg][/zrl]'; + $xarr['body'] .= "\n\n\n" . '[zrl=' . App::$poi['xchan_url'] . '][zmg=80x80]' . App::$poi['xchan_photo_m'] . '[/zmg][/zrl]'; post_activity_item($xarr); @@ -320,7 +327,7 @@ class Connedit extends \Zotlabs\Web\Controller { // pull in a bit of content if there is any to pull in - \Zotlabs\Daemon\Master::Summon(array('Onepoll',$contact_id)); + Master::Summon(array('Onepoll',$contact_id)); } @@ -333,11 +340,11 @@ class Connedit extends \Zotlabs\Web\Controller { intval($contact_id) ); if($r) { - \App::$poi = $r[0]; + App::$poi = $r[0]; } if($new_friend) { - $arr = array('channel_id' => local_channel(), 'abook' => \App::$poi); + $arr = array('channel_id' => local_channel(), 'abook' => App::$poi); call_hooks('accept_follow', $arr); } @@ -357,23 +364,23 @@ class Connedit extends \Zotlabs\Web\Controller { function connedit_clone(&$a) { - if(! \App::$poi) + if(! App::$poi) return; - $channel = \App::get_channel(); + $channel = App::get_channel(); $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and abook_id = %d LIMIT 1", intval(local_channel()), - intval(\App::$poi['abook_id']) + intval(App::$poi['abook_id']) ); if($r) { - \App::$poi = array_shift($r); + App::$poi = array_shift($r); } - $clone = \App::$poi; + $clone = App::$poi; unset($clone['abook_id']); unset($clone['abook_account']); @@ -402,11 +409,11 @@ class Connedit extends \Zotlabs\Web\Controller { } $section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : ''); - $channel = \App::get_channel(); + $channel = App::get_channel(); $yes_no = array(t('No'),t('Yes')); - $connect_perms = \Zotlabs\Access\Permissions::connect_perms(local_channel()); + $connect_perms = Permissions::connect_perms(local_channel()); $o .= "