aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2025-05-08 10:27:57 +0000
committerMario <mario@mariovavti.com>2025-05-08 10:27:57 +0000
commit918377a67b2e46f983281d6dec4f9732b977d6b5 (patch)
treee2477c5429baf2eb434413d62a02785b6c9690c4
parent25e29ec544757d376c0eab4445c2450feec18101 (diff)
downloadvolse-hubzilla-918377a67b2e46f983281d6dec4f9732b977d6b5.tar.gz
volse-hubzilla-918377a67b2e46f983281d6dec4f9732b977d6b5.tar.bz2
volse-hubzilla-918377a67b2e46f983281d6dec4f9732b977d6b5.zip
provide commentable state and minor cleanup
-rw-r--r--Zotlabs/Lib/ThreadItem.php10
-rw-r--r--Zotlabs/Module/Request.php6
-rw-r--r--include/conversation.php3
-rw-r--r--include/html2plain.php4
-rw-r--r--include/items.php25
5 files changed, 23 insertions, 25 deletions
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 6e81d6f44..afa341d45 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -114,7 +114,7 @@ class ThreadItem {
$locktype = intval($item['item_private']);
if ($locktype === 2) {
- $lock = t('Direct message');
+ $lock = t('Private message');
}
// 0 = limited based on public policy
@@ -285,14 +285,10 @@ class ThreadItem {
if((in_array($item['obj_type'], ['Event', ACTIVITY_OBJ_EVENT])) && $conv->get_profile_owner() == local_channel())
$has_event = true;
- $like = [];
- $dislike = [];
$reply_to = [];
$reactions_allowed = false;
if($this->is_commentable() && $observer) {
- $like = array( t("I like this \x28toggle\x29"), t("like"));
- $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
$reply_to = array( t("Reply to this message"), t("reply"), t("Reply to"));
$reactions_allowed = true;
}
@@ -439,8 +435,6 @@ class ThreadItem {
'reactions' => $this->reactions,
// Item toolbar buttons
'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''),
- 'like' => $like,
- 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''),
'reply_to' => ((feature_enabled($conv->get_profile_owner(),'reply_to')) ? $reply_to : ''),
'top_hint' => t("Go to previous comment"),
'share' => $share,
@@ -465,7 +459,7 @@ class ThreadItem {
'list_unseen_txt' => $list_unseen_txt,
'markseen' => t('Mark all comments seen'),
'responses' => $responses,
- 'my_responses' => $my_responses,
+ // 'my_responses' => $my_responses,
'modal_dismiss' => t('Close'),
'comment' => ($item['item_delayed'] ? '' : $this->get_comment_box()),
'comment_hidden' => feature_enabled($conv->get_profile_owner(),'reply_to'),
diff --git a/Zotlabs/Module/Request.php b/Zotlabs/Module/Request.php
index daf063b5c..527ab0055 100644
--- a/Zotlabs/Module/Request.php
+++ b/Zotlabs/Module/Request.php
@@ -61,8 +61,10 @@ class Request extends Controller
$ret['result'] = item_activity_xchans($mid, $parent, $verb);
- // TODO: check permission to like
- if ($observer_hash) {
+ $commentable = $ret['result']['is_commentable'];
+ unset($ret['result']['is_commentable']);
+
+ if ($commentable) {
$ret['action'] = (($verb === 'Announce') ? 'jotShare' : 'dolike');
$ret['action_label'] = ((find_xchan_in_array($observer_hash, $ret['result'])) ? t('- Remove yours') : t('+ Add yours'));
}
diff --git a/include/conversation.php b/include/conversation.php
index 75b38a21d..d083d3a0f 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1540,10 +1540,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
}
$ret[$v]['count'] = $item[$v . '_count'] ?? 0;
- $ret[$v]['list'] = ''; // ((isset($conv_responses[$v][$item['mid']])) ? $conv_responses[$v][$item['mid'] . '-l'] : '');
$ret[$v]['button'] = get_response_button_text($v, $ret[$v]['count']);
- $ret[$v]['title'] = $conv_responses[$v]['title'] ?? '';
- $ret[$v]['modal'] = false; // (($ret[$v]['count'] > MAX_LIKERS) ? true : false);
}
//logger('ret: ' . print_r($ret,true));
diff --git a/include/html2plain.php b/include/html2plain.php
index 69fb5193a..6d580becf 100644
--- a/include/html2plain.php
+++ b/include/html2plain.php
@@ -120,6 +120,10 @@ function collecturls($message) {
function html2plain($html, $wraplength = 75, $compact = false)
{
+ if (!$html) {
+ return '';
+ }
+
$message = str_replace("\r", "", $html);
// mb_convert_encoding() is deprecated
diff --git a/include/items.php b/include/items.php
index 12c2a52c9..1dac18ec0 100644
--- a/include/items.php
+++ b/include/items.php
@@ -5386,12 +5386,12 @@ function item_activity_sql($prefix = 'c') {
}
$sql .= <<<SQL
- COUNT(CASE $prefix.verb WHEN 'Like' THEN 1 END) AS like_count,
- COUNT(CASE $prefix.verb WHEN 'Dislike' THEN 1 END) AS dislike_count,
- COUNT(CASE $prefix.verb WHEN 'Announce' THEN 1 END) AS announce_count,
- COUNT(CASE $prefix.verb WHEN 'Accept' THEN 1 END) AS attendyes_count,
- COUNT(CASE $prefix.verb WHEN 'Reject' THEN 1 END) AS attendno_count,
- COUNT(CASE $prefix.verb WHEN 'TentativeAccept' THEN 1 END) AS attendmaybe_count
+ COUNT(CASE WHEN $prefix.verb = 'Like' $item_normal_c THEN 1 END) AS like_count,
+ COUNT(CASE WHEN $prefix.verb = 'Dislike' $item_normal_c THEN 1 END) AS dislike_count,
+ COUNT(CASE WHEN $prefix.verb = 'Announce' $item_normal_c THEN 1 END) AS announce_count,
+ COUNT(CASE WHEN $prefix.verb = 'Accept' $item_normal_c THEN 1 END) AS attendyes_count,
+ COUNT(CASE WHEN $prefix.verb = 'Reject' $item_normal_c THEN 1 END) AS attendno_count,
+ COUNT(CASE WHEN $prefix.verb = 'TentativeAccept' $item_normal_c THEN 1 END) AS attendmaybe_count
SQL;
return $sql;
@@ -5523,6 +5523,10 @@ function item_activity_xchans($mid, $parent, $verb) {
$observer_hash = get_observer_hash();
$item_normal = item_normal();
+ $parent_item = q("SELECT * FROM item WHERE id = %d",
+ intval($parent)
+ );
+
if (local_channel()) {
$ret = q("SELECT xchan.xchan_hash, xchan.xchan_name as name, xchan.xchan_url as url, xchan.xchan_photo_s as photo FROM item
LEFT JOIN xchan ON item.author_xchan = xchan.xchan_hash
@@ -5541,12 +5545,7 @@ function item_activity_xchans($mid, $parent, $verb) {
}
if (!$ret) {
- $x = q("SELECT uid FROM item WHERE id = %d",
- intval($parent)
- );
-
- $item_uid = $x[0]['uid'];
-
+ $item_uid = $parent_item[0]['uid'];
$sql_extra = item_permissions_sql($item_uid, $observer_hash);
$ret = q("SELECT xchan.xchan_hash, xchan.xchan_name as name, xchan.xchan_url as url, xchan.xchan_photo_s as photo FROM item
@@ -5564,6 +5563,8 @@ function item_activity_xchans($mid, $parent, $verb) {
);
}
+ $ret['is_commentable'] = can_comment_on_post($observer_hash, $parent_item[0]);
+
return $ret;
}