diff options
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 5 | ||||
-rw-r--r-- | Zotlabs/Lib/JcsEddsa2022.php | 25 | ||||
-rw-r--r-- | Zotlabs/Lib/JcsEddsa2022SignException.php | 15 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 63 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadStream.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Channel.php | 15 | ||||
-rw-r--r-- | Zotlabs/Module/Display.php | 15 | ||||
-rw-r--r-- | Zotlabs/Module/Hq.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Like.php | 16 | ||||
-rw-r--r-- | Zotlabs/Module/Network.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Pubstream.php | 5 | ||||
-rw-r--r-- | Zotlabs/Module/Request.php | 21 | ||||
-rw-r--r-- | Zotlabs/Render/Theme.php | 9 | ||||
-rw-r--r-- | Zotlabs/Widget/Messages.php | 6 | ||||
-rw-r--r-- | Zotlabs/Widget/Notifications.php | 8 | ||||
-rw-r--r-- | Zotlabs/Widget/Pinned.php | 4 | ||||
-rw-r--r-- | Zotlabs/Zot6/Zot6Handler.php | 2 |
17 files changed, 142 insertions, 75 deletions
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 12dbfee7f..6d5e249ef 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -910,14 +910,13 @@ class Enotify { } 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); $x = [ - 'notify_link' => $tt['link'], + 'notify_link' => (($tt['ntype'] === NOTIFY_INTRO) ? z_root() . '/notify/view/' . $tt['id'] : $tt['link']), 'name' => $tt['xname'], 'url' => $tt['url'], 'photo' => $tt['photo'], @@ -929,11 +928,9 @@ class Enotify { ]; return $x; - } static public function format_intros($rr) { - return [ 'notify_link' => z_root() . '/connections#' . $rr['abook_id'], 'name' => $rr['xchan_name'], diff --git a/Zotlabs/Lib/JcsEddsa2022.php b/Zotlabs/Lib/JcsEddsa2022.php index 14f16c94b..c56f093af 100644 --- a/Zotlabs/Lib/JcsEddsa2022.php +++ b/Zotlabs/Lib/JcsEddsa2022.php @@ -7,11 +7,28 @@ use StephenHill\Base58; class JcsEddsa2022 { - public function __construct() { - return $this; - } - + /** + * Sign arbitrary data with the keys of the provided channel. + * + * @param $data The data to be signed. + * @param array $channel A channel as an array of key/value pairs. + * + * @return An array with the following fields: + * - `type`: The type of signature, always `DataIntegrityProof`. + * - `cryptosuite`: The cryptographic algorithm used, always `eddsa-jcs-2022`. + * - `created`: The UTC date and timestamp when the signature was created. + * - `verificationMethod`: The channel URL and the public key separated by a `#`. + * - `proofPurpose`: The purpose of the signature, always `assertionMethod`. + * - `proofValue`: The signature itself. + * + * @throws JcsEddsa2022SignatureException if the channel is missing, or + * don't have valid keys. + */ public function sign($data, $channel): array { + if (!is_array($channel) || !isset($channel['channel_epubkey'], $channel['channel_eprvkey'])) { + throw new JcsEddsa2022SignException('Invalid or missing channel provided.'); + } + $base58 = new Base58(); $pubkey = (new Multibase())->publicKey($channel['channel_epubkey']); $options = [ diff --git a/Zotlabs/Lib/JcsEddsa2022SignException.php b/Zotlabs/Lib/JcsEddsa2022SignException.php new file mode 100644 index 000000000..81d02d631 --- /dev/null +++ b/Zotlabs/Lib/JcsEddsa2022SignException.php @@ -0,0 +1,15 @@ +<?php +/* + * SPDX-FileCopyrightText: 2025 The Hubzilla Community + * SPDX-FileContributor: Harald Eilertsen <haraldei@anduin.net> + * + * SPDX-License-Identifier: MIT + */ + +namespace Zotlabs\Lib; + +use Exception; + +class JcsEddsa2022SignException extends Exception +{ +} diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 5bb658bba..dee64caac 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -206,9 +206,9 @@ class ThreadItem { } if (in_array($item['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) { - $response_verbs[] = 'attendyes'; - $response_verbs[] = 'attendno'; - $response_verbs[] = 'attendmaybe'; + $response_verbs[] = 'accept'; + $response_verbs[] = 'reject'; + $response_verbs[] = 'tentativeaccept'; if($this->is_commentable() && $observer) { $isevent = true; $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); @@ -222,7 +222,6 @@ class ThreadItem { $response_verbs[] = 'comment'; $responses = get_responses($response_verbs, $item); - /* * We should avoid doing this all the time, but it depends on the conversation mode * And the conv mode may change when we change the conv, or it changes its mode @@ -231,7 +230,13 @@ class ThreadItem { $this->check_wall_to_wall(); + $children = $this->get_children(); + $children_count = count($children); + if($this->is_toplevel()) { + $conv->comments_total = $responses['comment']['count'] ?? 0; + $conv->comments_loaded = $children_count; + if((local_channel() && $conv->get_profile_owner() === local_channel()) || (local_channel() && App::$module === 'pubstream')) { $star = [ 'toggle' => t("Toggle Star Status"), @@ -243,7 +248,6 @@ class ThreadItem { $is_comment = true; } - $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); $forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : ''); $unverified = '' ; // (($this->is_wall_to_wall() && (! intval($item['item_verified']))) ? t('Message cannot be verified') : ''); @@ -324,9 +328,8 @@ class ThreadItem { $viewthread = z_root() . '/channel/' . $owner_address . '?f=&mid=' . urlencode(gen_link_id($item['mid'])); $comment_count_txt = ['label' => sprintf(tt('%d comment', '%d comments', $total_children), $total_children), 'count' => $total_children]; - $list_unseen_txt = $unseen_comments ? ['label' => sprintf(t('%d unseen'), $unseen_comments), 'count' => $unseen_comments] : []; - $children = $this->get_children(); + $list_unseen_txt = $unseen_comments ? ['label' => sprintf(t('%d unseen'), $unseen_comments), 'count' => $unseen_comments] : []; $has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false); @@ -350,6 +353,21 @@ class ThreadItem { $contact = App::$contacts[$item['author_xchan']]; } + $load_more = false; + $load_more_title = ''; + $comments_total_percent = 0; + if ($conv->comments_total > $conv->comments_loaded) { + // provide a load more comments button + $load_more = true; + $load_more_title = sprintf(t('Load the next few of total %d replies'), $conv->comments_total); + $comments_total_percent = round(100 * 3 / $conv->comments_total); + } + + $expand = ''; + if ($this->threaded && !empty($item['comment_count'] && !$this->is_toplevel())) { + $expand = t('Expand Replies'); + } + $tmp_item = array( 'template' => $this->get_template(), 'mode' => $mode, @@ -424,6 +442,7 @@ class ThreadItem { 'share' => $share, 'embed' => $embed, 'rawmid' => $item['mid'], + 'parent_mid' => $item['parent_mid'], 'plink' => get_plink($item), 'edpost' => $edpost, 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts') && ($item['item_type'] == ITEM_TYPE_POST)) ? $star : ''), @@ -463,18 +482,23 @@ class ThreadItem { 'reaction_str' => [t('Add yours'), t('Remove yours')], 'is_contained' => $this->is_toplevel() && str_contains($item['tgt_type'], 'Collection'), 'observer_activity' => [ - 'like' => intval($item['observer_liked'] ?? 0), - 'dislike' => intval($item['observer_disliked'] ?? 0), - 'announce' => intval($item['observer_announced'] ?? 0), - 'comment' => intval($item['observer_commented'] ?? 0), - 'attendyes' => intval($item['observer_accepted'] ?? 0), - 'attendno' => intval($item['observer_rejected'] ?? 0), - 'attendmaybe' => intval($item['observer_tentativelyaccepted'] ?? 0) + 'like' => intval($item['observer_like_count'] ?? 0), + 'dislike' => intval($item['observer_dislike_count'] ?? 0), + 'announce' => intval($item['observer_announce_count'] ?? 0), + 'comment' => intval($item['observer_comment_count'] ?? 0), + 'accept' => intval($item['observer_accept_count'] ?? 0), + 'reject' => intval($item['observer_reject_count'] ?? 0), + 'tentativeaccept' => intval($item['observer_tentativeaccept_count'] ?? 0) ], 'threaded' => $this->threaded, 'blog_mode' => $this->get_display_mode() === 'list', 'collapse_comments' => t('show less'), - 'expand_comments' => $this->threaded ? t('show more') : t('show all') + 'expand_comments' => $this->threaded ? t('show more') : t('show all'), + 'load_more' => $load_more, + 'load_more_title' => $load_more_title, + 'comments_total' => $conv->comments_total, + 'comments_total_percent' => $comments_total_percent, + 'expand' => $expand ); $arr = array('item' => $item, 'output' => $tmp_item); @@ -483,20 +507,19 @@ class ThreadItem { $result = $arr['output']; $result['children'] = array(); - $nb_children = count($children); - $visible_comments = Config::Get('system', 'expanded_comments', 3); + $visible_comments = 3; // Config::Get('system', 'expanded_comments', 3); - if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) { + if(($this->get_display_mode() === 'normal') && ($children_count > 0)) { foreach($children as $child) { $result['children'][] = $child->get_template_data($thread_level + 1, $conv_flags); } // Collapse - if($thread_level === 1 && $nb_children > $visible_comments) { + if($thread_level === 1 && $children_count > $visible_comments) { $result['children'][0]['comment_firstcollapsed'] = true; $result['children'][0]['num_comments'] = $comment_count_txt['label']; - $result['children'][$nb_children - ($visible_comments + 1)]['comment_lastcollapsed'] = true; + $result['children'][$children_count - ($visible_comments + 1)]['comment_lastcollapsed'] = true; } } diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index ee18d8de1..1d968fa1a 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -25,6 +25,8 @@ class ThreadStream { public $reload = ''; private $cipher = 'AES-128-CCM'; public $mid_uuid_map = []; + public $comments_total = 0; + public $comments_loaded = 0; // $prepared_item is for use by alternate conversation structures such as photos diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 9671cedf3..f73f25d5f 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -337,7 +337,7 @@ class Channel extends Controller { if (($update) && (!$load)) { if ($mid) { - $r = q("SELECT parent AS item_id from item where $identifier = '%s' and uid = %d $item_normal_update + $r = q("SELECT *, parent AS item_id from item where $identifier = '%s' and uid = %d $item_normal_update AND item_wall = 1 $simple_update $permission_sql $sql_extra limit 1", dbesc($mid), intval(App::$profile['profile_uid']) @@ -386,7 +386,7 @@ class Channel extends Controller { if ($noscript_content || $load) { if ($mid) { - $r = q("SELECT parent AS item_id from item where $identifier = '%s' and uid = %d $item_normal + $r = q("SELECT *, parent AS item_id from item where $identifier = '%s' and uid = %d $item_normal AND item_wall = 1 $permission_sql $sql_extra limit 1", dbesc($mid), intval(App::$profile['profile_uid']) @@ -417,12 +417,15 @@ class Channel extends Controller { } } if ($r) { - $parents_str = ids_to_querystr($r, 'item_id'); + $thr_parents = null; + if ($mid) { + $thr_parents = get_recursive_thr_parents($r[0]); + } - $r = items_by_parent_ids($parents_str, permission_sql: $permission_sql, blog_mode: $blog_mode); + $items = items_by_parent_ids($r, $thr_parents, $permission_sql, $blog_mode); - xchan_query($r); - $items = fetch_post_tags($r, true); + xchan_query($items); + $items = fetch_post_tags($items, true); $items = conv_sort($items, $ordering); if ($load && $mid && (!count($items))) { diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 07973431c..094466665 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -288,15 +288,12 @@ class Display extends Controller { } if($r) { - $parents_str = ids_to_querystr($r,'item_id'); - if($parents_str) { - $thr_parents = get_recursive_thr_parents($target_item); - $items = items_by_parent_ids($parents_str, $thr_parents, $permission_sql); - - xchan_query($items); - $items = fetch_post_tags($items,true); - $items = conv_sort($items,'created'); - } + $thr_parents = get_recursive_thr_parents($target_item); + $items = items_by_parent_ids($r, $thr_parents, $permission_sql); + + xchan_query($items); + $items = fetch_post_tags($items,true); + $items = conv_sort($items,'created'); } else { $items = array(); diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 562278973..241a5101a 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -201,7 +201,7 @@ class Hq extends \Zotlabs\Web\Controller { if($r) { $thr_parents = get_recursive_thr_parents($target_item); - $items = items_by_parent_ids($r[0]['item_id'], $thr_parents); + $items = items_by_parent_ids($r, $thr_parents); xchan_query($items,true,(($sys_item) ? local_channel() : 0)); $items = fetch_post_tags($items,true); diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 218d35f1e..52c559a17 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -22,9 +22,9 @@ class Like extends Controller { 'like' => 'Like', 'dislike' => 'Dislike', 'announce' => ACTIVITY_SHARE, - 'attendyes' => 'Accept', - 'attendno' => 'Reject', - 'attendmaybe' => 'TentativeAccept' + 'accept' => 'Accept', + 'reject' => 'Reject', + 'tentativeaccept' => 'TentativeAccept' ]; // unlike (etc.) reactions are an undo of positive reactions, rather than a negative action. @@ -67,7 +67,7 @@ class Like extends Controller { $items = conv_sort($items, 'commented'); } else { - $item = item_by_item_id($arr['item']['id']); + $item = item_by_item_id($arr['item']['id'], $arr['item']['parent']); xchan_query($item, true); $item = fetch_post_tags($item, true); } @@ -474,11 +474,11 @@ class Like extends Controller { $bodyverb = t('%1$s likes %2$s\'s %3$s'); if ($verb === 'dislike') $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); - if ($verb === 'attendyes') + if ($verb === 'accept') $bodyverb = t('%1$s is attending %2$s\'s %3$s'); - if ($verb === 'attendno') + if ($verb === 'reject') $bodyverb = t('%1$s is not attending %2$s\'s %3$s'); - if ($verb === 'attendmaybe') + if ($verb === 'tentativeaccept') $bodyverb = t('%1$s may attend %2$s\'s %3$s'); if (!isset($bodyverb)) @@ -561,7 +561,7 @@ class Like extends Controller { call_hooks('post_local_end', $arr); - if ($is_rsvp && in_array($verb, ['attendyes', 'attendmaybe'])) { + if ($is_rsvp && in_array($verb, ['accept', 'tentativeaccept'])) { event_addtocal($item_id, local_channel()); } diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index fd30adccc..f95d92fe2 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -507,9 +507,7 @@ class Network extends \Zotlabs\Web\Controller { // Then fetch all the children of the parents that are on this page if($r) { - $parents_str = ids_to_querystr($r, 'item_id'); - - $items = items_by_parent_ids($parents_str, blog_mode: $blog_mode); + $items = items_by_parent_ids($r, blog_mode: $blog_mode); xchan_query($items, true); $items = fetch_post_tags($items, true); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 79245f9c2..99b8ab587 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -251,10 +251,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $parents_str = ''; if($r) { - - $parents_str = ids_to_querystr($r,'item_id'); - - $items = items_by_parent_ids($parents_str); + $items = items_by_parent_ids($r); // use effective_uid param of xchan_query to help sort out comment permission // for sys_channel owned items. diff --git a/Zotlabs/Module/Request.php b/Zotlabs/Module/Request.php index bfd75ad95..439f56282 100644 --- a/Zotlabs/Module/Request.php +++ b/Zotlabs/Module/Request.php @@ -12,9 +12,9 @@ class Request extends Controller 'like' => 'Like', 'dislike' => 'Dislike', 'announce' => 'Announce', - 'attendyes' => 'Accept', - 'attendno' => 'Reject', - 'attendmaybe' => 'TentativeAccept' + 'accept' => 'Accept', + 'reject' => 'Reject', + 'tentativeaccept' => 'TentativeAccept' ]; if (array_key_exists($verb, $verbs)) { @@ -29,13 +29,24 @@ class Request extends Controller { $mid = $_GET['mid']; $parent = intval($_GET['parent']); + + $offset = null; + if ($_GET['verb'] === 'load') { + $offset = intval($_GET['offset']); + } + $module = strip_tags($_GET['module']); - $items = items_by_thr_parent($mid, $parent); + $items = items_by_thr_parent($mid, $parent, $offset); xchan_query($items); $items = fetch_post_tags($items,true); + if ($module === 'channel') { + $parts = explode('@', $items[0]['owner']['xchan_addr']); + profile_load($parts[0]); + } + $ret['html'] = conversation($items, $module, true, 'r_preview'); json_return_and_die($ret); @@ -44,7 +55,7 @@ class Request extends Controller public function get() : string { - if ($_GET['verb'] === 'comment') { + if (in_array($_GET['verb'], ['comment', 'load'])) { return self::processSubthreadRequest(); } diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 9403d21a3..2faf3631a 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -87,8 +87,13 @@ class Theme { // Find any theme at all and use it. $fallback = array_merge(glob('view/theme/*/css/style.css'), glob('view/theme/*/php/style.php')); - if(count($fallback)) - return(array(str_replace('view/theme/', '', substr($fallback[0], 0, -14)))); + + if (empty($fallback)) { + logger('Unable to find a theme'); + http_status_exit(500, 'internal server error'); + } + + return(array(str_replace('view/theme/', '', substr($fallback[0], 0, -14)))); } diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php index 761679120..cc1811ffc 100644 --- a/Zotlabs/Widget/Messages.php +++ b/Zotlabs/Widget/Messages.php @@ -86,8 +86,6 @@ class Messages { $entries = []; $limit = 30; $order_sql = 'i.created DESC'; - $dummy_order_sql = ''; - $filter_sql = ''; $loadtime = (($offset) ? $_SESSION['messages_loadtime'] : datetime_convert()); $vnotify = get_pconfig(local_channel(), 'system', 'vnotify', -1); @@ -103,14 +101,18 @@ class Messages { $vnotify_sql_i = " AND i.verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') "; } + $filter_sql = ''; if($type !== 'filed' && $author) { $filter_sql = " AND (i.owner_xchan = '" . protect_sprintf(dbesc($author)) . "') "; } + $filed_filter_sql = ''; if($type === 'filed' && $file) { $filed_filter_sql = " AND (term.term = '" . protect_sprintf(dbesc($file)) . "') "; } + $dummy_order_sql = ''; + switch($type) { case 'direct': $type_sql = ' AND i.item_private = 2 AND i.item_thread_top = 1 '; diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index fb256ec99..f9cee6e71 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -30,7 +30,7 @@ class Notifications { 'label' => t('Mark all read') ], 'filter' => [ - 'posts_label' => t('Conversation starters only'), + 'posts_label' => t('Conversation starters'), 'name_label' => t('Filter by name or address') ] ]; @@ -50,7 +50,7 @@ class Notifications { 'label' => t('Mark all seen') ], 'filter' => [ - 'posts_label' => t('Conversation starters only'), + 'posts_label' => t('Conversation starters'), 'name_label' => t('Filter by name or address') ] ]; @@ -69,7 +69,7 @@ class Notifications { 'label' => t('Mark all read') ], 'filter' => [ - 'posts_label' => t('Conversation starters only'), + 'posts_label' => t('Conversation starters'), 'name_label' => t('Filter by name or address') ] ]; @@ -163,7 +163,7 @@ class Notifications { ], */ 'filter' => [ - 'posts_label' => t('Conversation starters only'), + 'posts_label' => t('Conversation starters'), 'name_label' => t('Filter by name or address') ] ]; diff --git a/Zotlabs/Widget/Pinned.php b/Zotlabs/Widget/Pinned.php index 9daf396b8..7b95d3bc6 100644 --- a/Zotlabs/Widget/Pinned.php +++ b/Zotlabs/Widget/Pinned.php @@ -197,12 +197,12 @@ class Pinned { return []; - $r = q("SELECT parent FROM item WHERE uuid IN ( '%s' ) AND uid = %d AND id = parent AND item_private = 0", + $r = q("SELECT parent AS item_id FROM item WHERE uuid IN ( '%s' ) AND uid = %d AND id = parent AND item_private = 0", dbesc(implode(",", $mids_list)), intval($this->uid) ); - return items_by_parent_ids($r[0]['parent'], blog_mode: true); + return items_by_parent_ids($r, blog_mode: true); } diff --git a/Zotlabs/Zot6/Zot6Handler.php b/Zotlabs/Zot6/Zot6Handler.php index 2ef9e3b8d..1716ff84b 100644 --- a/Zotlabs/Zot6/Zot6Handler.php +++ b/Zotlabs/Zot6/Zot6Handler.php @@ -12,7 +12,7 @@ class Zot6Handler implements IHandler { } function Rekey($sender, $data, $hub) { - return self::reply_rekey_request($sender, $data, $hub); + return self::rekey_request($sender, $data, $hub); } function Refresh($sender, $recipients, $hub, $force) { |