From dd23b6708e1931d05f720805aa9500d0de797c6f Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 10 Nov 2021 12:33:29 -0800 Subject: [PATCH] implement reshare notifications and fix "unable to preserve categories in edited posts" --- Zotlabs/Lib/Enotify.php | 3 ++- Zotlabs/Module/Editpost.php | 7 +++++-- Zotlabs/Module/Settings/Channel.php | 3 +++ Zotlabs/Update/_1254.php | 20 ++++++++++++++++++++ boot.php | 3 ++- include/items.php | 10 +++++++--- view/tpl/settings.tpl | 1 + 7 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 Zotlabs/Update/_1254.php diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index ac402467b..a028d6e74 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -147,7 +147,7 @@ class Enotify { $itemlink = z_root() . '/display/' . gen_link_id($params['item']['mid']); } - if ($params['type'] == NOTIFY_COMMENT) { + if (in_array(intval($params['type']), [ NOTIFY_COMMENT, NOTIFY_RESHARE ] ) { // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); $moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false); @@ -695,6 +695,7 @@ class Enotify { case NOTIFY_WALL: case NOTIFY_TAGSELF: case NOTIFY_POKE: + case NOTIFY_RESHARE: case NOTIFY_COMMENT: if (! $private) break; diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 8525c710d..6e9754689 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -61,10 +61,13 @@ class Editpost extends Controller { $collections = []; $catsenabled = ((Apps::system_app_installed($owner_uid,'Categories')) ? 'categories' : ''); - $item = fetch_post_tags($item); + // we have a single item, but fetch_post_tags expects an array. Convert it before and after. + + $item = array_shift(fetch_post_tags([$item])); if ($catsenabled) { $cats = get_terms_oftype($item['term'], TERM_CATEGORY); + if ($cats) { foreach ($cats as $cat) { if (strlen($category)) { @@ -74,7 +77,7 @@ class Editpost extends Controller { } } } - + $clcts = get_terms_oftype($item['term'], TERM_PCATEGORY); if ($clcts) { foreach ($clcts as $clct) { diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index ca9271d35..5cdc15418 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -214,6 +214,8 @@ class Channel { $notify += intval($_POST['notify7']); if(x($_POST,'notify8')) $notify += intval($_POST['notify8']); + if(x($_POST,'notify10')) + $notify += intval($_POST['notify10']); $vnotify = 0; @@ -658,6 +660,7 @@ class Channel { // '$notify2' => array('notify2', t('Your connections are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, '', $yes_no), '$notify3' => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, '', $yes_no), '$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, '', $yes_no), + '$notify10' => array('notify10', t('Someone shares a followed conversation'), ($notify & NOTIFY_RESHARE), NOTIFY_RESHARE, '', $yes_no), '$notify5' => array('notify5', t('You receive a direct (private) message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, '', $yes_no), // '$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, '', $yes_no), '$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, '', $yes_no), diff --git a/Zotlabs/Update/_1254.php b/Zotlabs/Update/_1254.php new file mode 100644 index 000000000..460642861 --- /dev/null +++ b/Zotlabs/Update/_1254.php @@ -0,0 +1,20 @@ +