diff options
Diffstat (limited to 'Zotlabs/Lib/Enotify.php')
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 6820091d5..6d5e249ef 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -95,8 +95,8 @@ class Enotify { if (array_key_exists('verb', $params['item'])) { // localize_item() alters the original item so make a copy first $i = $params['item']; - logger('calling localize'); - localize_item($i); + // logger('calling localize'); + // localize_item($i); $title = $i['title']; $body = $i['body']; $private = (($i['item_private']) || intval($i['item_obscured'])); @@ -131,9 +131,9 @@ class Enotify { logger('notification: mail'); $subject = sprintf( t('[$Projectname:Notify] New direct message received at %s'), $sitename); - $preamble = sprintf( t('%1$s sent you a new direct message at %2$s'), $sender['xchan_name'], $sitename); + $preamble = sprintf( t('%1$s sent you a new private message at %2$s'), $sender['xchan_name'], $sitename); $epreamble = sprintf( t('%1$s sent you %2$s.'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a direct message') . '[/zrl]'); - $sitelink = t('Please visit %s to view and/or reply to your direct messages.'); + $sitelink = t('Please visit %s to view and/or reply to your private messages.'); $tsitelink = sprintf( $sitelink, $siteurl . '/hq/' . gen_link_id($params['item']['mid'])); $hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/hq/' . gen_link_id($params['item']['mid']) . '">' . $sitename . '</a>'); $itemlink = $siteurl . '/hq/' . gen_link_id($params['item']['mid']); @@ -146,7 +146,7 @@ class Enotify { $itemlink = $params['link']; - $action = (($moderated) ? t('requested to comment on') : t('commented on')); + $action = (($moderated) ? t('requested to post in') : t('posted in')); if(array_key_exists('item',$params)) { @@ -164,8 +164,8 @@ class Enotify { if(activity_match($params['verb'], ['Dislike', ACTIVITY_DISLIKE])) $action = (($moderated) ? t('requested to dislike') : t('disliked')); - if(activity_match($params['verb'], ACTIVITY_SHARE)) - $action = t('repeated'); + if(activity_match($params['verb'], [ACTIVITY_SHARE])) + $action = (($moderated) ? t('requested to repeat') : t('repeated')); } @@ -271,7 +271,7 @@ class Enotify { $itemlink = $params['link']; - if (array_key_exists('item',$params) && (activity_match($params['item']['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE]))) { + if (array_key_exists('item',$params) && (activity_match($params['item']['verb'], ['Like', 'Dislike', ACTIVITY_LIKE, ACTIVITY_DISLIKE, 'Announce']))) { if(! $always_show_in_notices || !($vnotify & VNOTIFY_LIKE) || !feature_enabled($recip['channel_id'], 'dislike')) { logger('notification: not a visible activity. Ignoring.'); pop_lang(); @@ -327,6 +327,9 @@ class Enotify { if(activity_match($params['item']['verb'], ['Dislike', ACTIVITY_DISLIKE])) $verb = (($moderated) ? t('requested to dislike') : t('disliked')); + if(activity_match($params['item']['verb'], [ACTIVITY_SHARE])) + $verb = (($moderated) ? t('requested to repeat') : t('repeated')); + // "your post" if ($parent_item['author']['xchan_hash'] === $recip['channel_hash']) { $dest_str = sprintf(t('%1$s %2$s [zrl=%3$s]your %4$s[/zrl]'), @@ -508,9 +511,14 @@ class Enotify { */ + $hash = ((in_array($params['verb'], ['Create', 'Update'])) ? $params['item']['uuid'] : $params['item']['thr_parent_uuid']); + + if (!$hash) { + $hash = new_uuid(); + } $datarray = []; - $datarray['hash'] = $params['item']['uuid'] ?? new_uuid(); + $datarray['hash'] = $hash; $datarray['sender_hash'] = $sender['xchan_hash']; $datarray['xname'] = $sender['xchan_name']; $datarray['url'] = $sender['xchan_url']; @@ -569,8 +577,9 @@ class Enotify { dbesc($datarray['otype']) ); - $r = q("select id from notify where hash = '%s' and ntype = %d and uid = %d limit 1", + $r = q("select id from notify where hash = '%s' and link = '%s' and ntype = %d and uid = %d limit 1", dbesc($datarray['hash']), + dbesc($itemlink), intval($datarray['ntype']), intval($recip['channel_id']) ); @@ -848,8 +857,8 @@ class Enotify { } else { $itemem_text = (($item['item_thread_top']) - ? (($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]')) + ? (($item['obj_type'] === 'Question') ? t('started a poll') : t('started a conversation')) + : (($item['obj_type'] === 'Answer') ? sprintf( t('voted on %s\'s poll'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]') : sprintf( t('posted in %s\'s conversation'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]')) ); if(in_array($item['obj_type'], ['Document', 'Video', 'Audio', 'Image'])) { @@ -861,12 +870,7 @@ class Enotify { if($item['edited'] > $item['created']) { $edit = true; - if($item['item_thread_top']) { - $itemem_text = sprintf( t('edited a post dated %s'), relative_date($item['created'])); - } - else { - $itemem_text = sprintf( t('edited a comment dated %s'), relative_date($item['created'])); - } + $itemem_text = sprintf( t('edited a message dated %s'), relative_date($item['created'])); } @@ -886,7 +890,7 @@ class Enotify { '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' => (($item['mid']) ? gen_link_id($item['mid']) : ''), - 'b64mid' => (($item['uuid']) ? $item['uuid'] : ''), + 'b64mid' => ((in_array($item['verb'] , ['Like', 'Dislike', 'Announce']) && !empty($item['thr_parent_uuid'])) ? $item['thr_parent_uuid'] : $item['uuid'] ?? ''), //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? gen_link_id($item['thr_parent']) : gen_link_id($item['mid'])), 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => bbcode(escape_tags($itemem_text)), @@ -906,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['ntype'] === NOTIFY_MAIL) ? $tt['link'] : z_root() . '/notify/view/' . $tt['id']), + 'notify_link' => (($tt['ntype'] === NOTIFY_INTRO) ? z_root() . '/notify/view/' . $tt['id'] : $tt['link']), 'name' => $tt['xname'], 'url' => $tt['url'], 'photo' => $tt['photo'], @@ -925,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'], |