aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2024-10-19 20:50:48 +0200
committerMario Vavti <mario@mariovavti.com>2024-10-19 20:50:48 +0200
commit168ec536866b16c5d9bad6551ebf4a38b11e440f (patch)
tree1cf6608d1df56d87d5853df9ca80840d4a58d750
parente8f816a9817a36b688b0ecafb53bc33c12aaef13 (diff)
parent4d1be3aea583c26c6e24e88b464d5a366a4d2ef3 (diff)
downloadvolse-hubzilla-168ec536866b16c5d9bad6551ebf4a38b11e440f.tar.gz
volse-hubzilla-168ec536866b16c5d9bad6551ebf4a38b11e440f.tar.bz2
volse-hubzilla-168ec536866b16c5d9bad6551ebf4a38b11e440f.zip
Merge branch 'dev' into containers
-rw-r--r--Zotlabs/Module/Hq.php1
-rw-r--r--Zotlabs/Widget/Messages.php61
-rw-r--r--include/features.php10
-rw-r--r--view/js/main.js2
-rw-r--r--view/tpl/messages_widget.tpl55
5 files changed, 111 insertions, 18 deletions
diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index c8e6efe38..51caa179c 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -230,6 +230,7 @@ class Hq extends \Zotlabs\Web\Controller {
$options['offset'] = $_REQUEST['offset'] ?? 0;
$options['type'] = $_REQUEST['type'] ?? '';
$options['author'] = ((isset($_REQUEST['author'])) ? urldecode($_REQUEST['author']) : '');
+ $options['file'] = ((isset($_REQUEST['file'])) ? urldecode($_REQUEST['file']) : '');
$ret = Messages::get_messages_page($options);
diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php
index 294a982b1..f90b4f99e 100644
--- a/Zotlabs/Widget/Messages.php
+++ b/Zotlabs/Widget/Messages.php
@@ -23,20 +23,35 @@ class Messages {
$_SESSION['messages_loadtime'] = datetime_convert();
+ $r = q("SELECT DISTINCT(term) FROM term WHERE uid = %d AND ttype = %d ORDER BY term",
+ intval(local_channel()),
+ intval(TERM_FILE)
+ );
+
+ if ($r) {
+ foreach($r as $rr) {
+ $file_tags[] = $rr['term'];
+ }
+ }
+
$tpl = get_markup_template('messages_widget.tpl');
$o = replace_macros($tpl, [
'$entries' => $page['entries'] ?? [],
'$offset' => $page['offset'] ?? 0,
'$feature_star' => feature_enabled(local_channel(), 'star_posts'),
+ '$feature_file' => feature_enabled(local_channel(), 'filing'),
+ '$file_tags' => $file_tags,
'$strings' => [
'messages_title' => t('Public and restricted messages'),
'direct_messages_title' => t('Direct messages'),
'starred_messages_title' => t('Starred messages'),
+ 'filed_messages_title' => t('Filed messages'),
'notice_messages_title' => t('Notices'),
'loading' => t('Loading'),
'empty' => t('No messages'),
'unseen_count' => t('Unseen'),
- 'filter' => t('Filter by name or address')
+ 'filter' => t('Filter by name or address'),
+ 'file_filter' => t('Filter by file name')
]
]);
@@ -50,6 +65,7 @@ class Messages {
$offset = $options['offset'] ?? 0;
$type = $options['type'] ?? '';
$author = $options['author'] ?? '';
+ $file = $options['file'] ?? '';
if ($offset == -1) {
return;
@@ -67,8 +83,9 @@ class Messages {
$item_normal_c = str_replace('item.', 'c.', $item_normal);
$entries = [];
$limit = 30;
+ $order_sql = 'i.created DESC';
$dummy_order_sql = '';
- $author_sql = '';
+ $filter_sql = '';
$loadtime = (($offset) ? $_SESSION['messages_loadtime'] : datetime_convert());
$vnotify = get_pconfig(local_channel(), 'system', 'vnotify', -1);
@@ -84,43 +101,55 @@ class Messages {
$vnotify_sql_i = " AND i.verb NOT IN ('Dislike', '" . dbesc(ACTIVITY_DISLIKE) . "') ";
}
- if($author) {
- $author_sql = " AND (i.owner_xchan = '" . protect_sprintf(dbesc($author)) . "') ";
+ if($type !== 'filed' && $author) {
+ $filter_sql = " AND (i.owner_xchan = '" . protect_sprintf(dbesc($author)) . "') ";
+ }
+
+ if($type === 'filed' && $file) {
+ $filed_filter_sql = " AND (term.term = '" . protect_sprintf(dbesc($file)) . "') ";
}
switch($type) {
case 'direct':
- $type_sql = ' AND i.item_private = 2 ';
+ $type_sql = ' AND i.item_private = 2 AND i.item_thread_top = 1 ';
// $dummy_order_sql has no other meaning but to trick
// some mysql backends into using the right index.
$dummy_order_sql = ', i.received DESC ';
break;
case 'starred':
- $type_sql = ' AND i.item_starred = 1 ';
+ $type_sql = ' AND i.item_starred = 1 AND i.item_thread_top = 1 ';
+ break;
+ case 'filed':
+ $type_sql = ' AND i.id IN (SELECT term.oid FROM term WHERE term.ttype = ' . TERM_FILE . ' AND term.uid = i.uid ' . $filed_filter_sql . ')';
break;
default:
- $type_sql = ' AND i.item_private IN (0, 1) ';
+ $type_sql = ' AND i.item_private IN (0, 1) AND i.item_thread_top = 1 ';
}
$items = q("SELECT *,
(SELECT count(*) FROM item c WHERE c.uid = %d AND c.parent = i.parent AND c.item_unseen = 1 AND c.item_thread_top = 0 $item_normal_c $vnotify_sql_c) AS unseen_count
- FROM item i WHERE i.uid = %d
+ FROM item i
+ WHERE i.uid = %d
AND i.created <= '%s'
$type_sql
- AND i.item_thread_top = 1
- $author_sql
+ $filter_sql
$item_normal_i
- ORDER BY i.created DESC $dummy_order_sql
+ ORDER BY $order_sql $dummy_order_sql
LIMIT $limit OFFSET $offset",
intval(local_channel()),
intval(local_channel()),
dbescdate($loadtime)
);
+ if ($type === 'filed') {
+ $items = fetch_post_tags($items);
+ }
+
xchan_query($items, false);
$i = 0;
$entries = [];
+ $ids = [];
foreach($items as $item) {
@@ -149,6 +178,16 @@ class Messages {
$info .= t('via') . ' ' . $item['source']['xchan_name'];
}
+ if ($type == 'filed') {
+ $info = '';
+ foreach ($item['term'] as $t) {
+ if ($t['ttype'] !== TERM_FILE) {
+ continue;
+ }
+ $info .= '<span class="badge rounded-pill bg-danger me-1"><i class="bi bi-folder"></i>&nbsp;' . $t['term'] . '</span>';
+ }
+ }
+
$summary = $item['title'];
if (!$summary) {
$summary = $item['summary'];
diff --git a/include/features.php b/include/features.php
index d527f60e6..65ead6604 100644
--- a/include/features.php
+++ b/include/features.php
@@ -170,12 +170,20 @@ function get_features($filtered = true, $level = (-1)) {
[
'star_posts',
t('Star Posts'),
- t('Ability to mark special posts with a star indicator'),
+ t('Ability to mark conversations with a star'),
false,
Config::Get('feature_lock','star_posts'),
],
[
+ 'filing',
+ t('File Posts'),
+ t('Ability to file posts'),
+ false,
+ Config::Get('feature_lock','filing'),
+ ],
+
+ [
'reply_to',
t('Reply on comment'),
t('Ability to reply on selected comment'),
diff --git a/view/js/main.js b/view/js/main.js
index f52720693..87025a1c8 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -212,7 +212,7 @@ $(document).ready(function() {
prepareLiveUpdate(b64mid, notify_id);
$('.message').removeClass('active');
$('[data-b64mid="' + b64mid + '"].message').addClass('active');
- $('[data-b64mid="' + b64mid + '"].message .badge').remove();
+ $('[data-b64mid="' + b64mid + '"].message .unseen_count').remove();
}
}
}
diff --git a/view/tpl/messages_widget.tpl b/view/tpl/messages_widget.tpl
index 52a9b96f4..df91a05ef 100644
--- a/view/tpl/messages_widget.tpl
+++ b/view/tpl/messages_widget.tpl
@@ -16,6 +16,13 @@
</a>
</li>
{{/if}}
+ {{if $feature_file}}
+ <li class="nav-item">
+ <a class="nav-link messages-type" href="#" title="{{$strings.filed_messages_title}}" data-messages_type="filed">
+ <i class="bi bi-folder generic-icons"></i>
+ </a>
+ </li>
+ {{/if}}
<li class="nav-item">
<a class="nav-link messages-type" href="#" title="{{$strings.notice_messages_title}}" data-messages_type="notification">
<i class="bi bi-exclamation-circle generic-icons"></i>
@@ -53,6 +60,18 @@
<input id="messages-author" type="text" class="form-control form-control-sm" placeholder="{{$strings.filter}}">
<div id="messages-author-input-clear" class="text-muted notifications-textinput-clear d-none"><i class="bi bi-x-lg"></i></div>
</div>
+ {{if $feature_file}}
+ <div id="messages-file-container" class="list-group-item notifications-textinput d-none">
+ <div class="text-muted notifications-textinput-filter"><i class="bi bi-filter"></i></div>
+ <input id="messages-file" type="text" list="data_filetags" class="form-control form-control-sm" placeholder="{{$strings.file_filter}}">
+ <datalist id="data_filetags">
+ {{foreach $file_tags as $opt=>$val}}
+ <option value="{{$val}}">
+ {{/foreach}}
+ </datalist>
+ <div id="messages-file-input-clear" class="text-muted notifications-textinput-clear d-none"><i class="bi bi-x-lg"></i></div>
+ </div>
+ {{/if}}
{{foreach $entries as $e}}
<a href="{{$e.href}}" class="list-group-item list-group-item-action message" data-b64mid="{{$e.b64mid}}">
<div class="mb-2 align-middle">
@@ -75,7 +94,7 @@
</div>
<small class="opacity-75">{{$e.info}}</small>
{{if $e.unseen_count}}
- <span class="badge bg-transparent border border-{{$e.unseen_class}} text-{{$e.unseen_class}} rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen_count}}">{{$e.unseen_count}}</span>
+ <span class="badge bg-transparent border border-{{$e.unseen_class}} text-{{$e.unseen_class}} rounded-pill position-absolute bottom-0 end-0 m-2 unseen_count" title="{{$strings.unseen_count}}">{{$e.unseen_count}}</span>
{{/if}}
</a>
{{/foreach}}
@@ -94,6 +113,7 @@
let author_hash;
let author_url;
let author;
+ let file;
$(document).ready(function () {
$('.messages-timeago').timeago();
@@ -109,6 +129,7 @@
$('#messages-container .message').remove();
$('#messages-author-container').addClass('active sticky-top');
$('#messages-author-input-clear').removeClass('d-none');
+
author_hash = data.xid;
author_url = data.url;
author = messages_type === 'notification' ? author_url : author_hash;
@@ -116,14 +137,27 @@
get_messages_page();
});
- $(document).on('click', '#messages-author-input-clear', function() {
- $('#messages-author').val('');
+ $("#messages-file").on('change', function(data) {
+ file = $("#messages-file").val();
+
+ $('#messages-container .message').remove();
+ $('#messages-file-container').addClass('active sticky-top');
+ $('#messages-file-input-clear').removeClass('d-none');
+
+ messages_offset = 0;
+ get_messages_page();
+ });
+
+ $(document).on('click', '#messages-author-input-clear, #messages-file-input-clear', function() {
+ $('#messages-author, #messages-file').val('');
$("#messages-author").attr('placeholder', '{{$strings.filter}}');
+ $("#messages-file").attr('placeholder', '{{$strings.file_filter}}');
$('#messages-author-container').removeClass('active sticky-top');
$('#messages-author-input-clear').addClass('d-none');
$('#messages-container .message').remove();
author = '';
+ file = '';
author_hash = '';
author_url = '';
messages_offset = 0;
@@ -145,6 +179,16 @@
messages_offset = 0;
messages_type = $(this).data('messages_type');
author = messages_type === 'notification' ? author_url : author_hash;
+
+ if (messages_type === 'filed') {
+ $('#messages-author-container').addClass('d-none');
+ $('#messages-file-container').removeClass('d-none');
+ }
+ else {
+ $('#messages-author-container').removeClass('d-none');
+ $('#messages-file-container').addClass('d-none');
+ }
+
$('#messages-container .message').remove();
get_messages_page();
});
@@ -167,7 +211,8 @@
data: {
offset: messages_offset,
type: messages_type,
- author: author
+ author: author,
+ file: file
}
}).done(function(obj) {
get_messages_page_active = false;
@@ -185,7 +230,7 @@
e.author_addr,
e.href,
e.icon,
- e.unseen_count ? '<span class="badge bg-transparent border border-' + e.unseen_class + ' text-' + e.unseen_class + ' rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen_count}}">' + e.unseen_count + '</span>' : '',
+ e.unseen_count ? '<span class="badge bg-transparent border border-' + e.unseen_class + ' text-' + e.unseen_class + ' rounded-pill position-absolute bottom-0 end-0 m-2 unseen_count" title="{{$strings.unseen_count}}">' + e.unseen_count + '</span>' : '',
e.author_img
);
$('#messages-loading').before(html);