From f85c6d76de5532e62f95de3f4d814109ea3472f9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 Jan 2018 11:54:53 -0800 Subject: better notifications for edit post/comments which may have been originally posted long ago --- Zotlabs/Lib/Enotify.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index a7b4f28e8..5cf4ec31d 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -794,6 +794,20 @@ class Enotify { : sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name'])); } + $edit = false; + + if($item['edited'] > $item['created']) { + if($item['item_thread_top']) { + $itemem_text = sprintf( t('edited a post dated %s'), relative_date($item['created'])); + $edit = true; + } + else { + $itemem_text = sprintf( t('edited a comment dated %s'), relative_date($item['created'])); + $edit = true; + } + } + + // convert this logic into a json array just like the system notifications return array( @@ -801,7 +815,7 @@ class Enotify { 'name' => $item['author']['xchan_name'], 'url' => $item['author']['xchan_url'], 'photo' => $item['author']['xchan_photo_s'], - 'when' => relative_date($item['created']), + 'when' => relative_date(($edit)? $item['edited'] : $item['created']), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), 'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', -- cgit v1.2.3 From b7fb78245aca724248cc721134a360276a9f6d9c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 12 Feb 2018 22:48:53 +0100 Subject: if always_show_in_notices is set to 1 also show likes and dislikes --- Zotlabs/Lib/Enotify.php | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 5cf4ec31d..5820c8b0c 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -112,6 +112,8 @@ class Enotify { } + $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices'); + // e.g. "your post", "David's photo", etc. $possess_desc = t('%s '); @@ -134,12 +136,22 @@ class Enotify { $itemlink = $params['link']; - // ignore like/unlike activity on posts - they probably require a separate notification preference + $action = 'commented on'; + + if(array_key_exists('item',$params) && (! visible_activity($params['item']))) { + + if(! $always_show_in_notices) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); + return; + } + + if(activity_match($params['item']['verb'], ACTIVITY_LIKE)) + $action = 'liked'; + + if(activity_match($params['item']['verb'], ACTIVITY_DISLIKE)) + $action = 'disliked'; - if (array_key_exists('item',$params) && (! visible_activity($params['item']))) { - logger('notification: not a visible activity. Ignoring.'); - pop_lang(); - return; } $parent_mid = $params['parent_mid']; @@ -181,26 +193,29 @@ class Enotify { //$possess_desc = str_replace('',$possess_desc); // "a post" - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]a %4$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]a %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $item_post_type); // "George Bull's post" if($p) - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]%4$s\'s %5$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]%5$s\'s %6$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $p[0]['author']['xchan_name'], $item_post_type); // "your post" if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]your %4$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%3$s]your %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $item_post_type); @@ -231,12 +246,12 @@ class Enotify { $itemlink = $params['link']; - // ignore like/unlike activity on posts - they probably require a separate notification preference - if (array_key_exists('item',$params) && (! activity_match($params['item']['verb'],ACTIVITY_LIKE))) { - logger('notification: not a like activity. Ignoring.'); - pop_lang(); - return; + if(! $always_show_in_notices) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); + return; + } } $parent_mid = $params['parent_mid']; @@ -496,8 +511,6 @@ class Enotify { // Another option would be to not add them to the DB, and change how emails are handled // (probably would be better that way) - $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices'); - if (!$always_show_in_notices) { if (($params['type'] == NOTIFY_WALL) || ($params['type'] == NOTIFY_MAIL) || ($params['type'] == NOTIFY_INTRO)) { $seen = 1; -- cgit v1.2.3 From d2dcb93866ea659ac6fabc34b301656d8d5def8c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 13 Feb 2018 12:04:48 +0100 Subject: match against item verb --- Zotlabs/Lib/Enotify.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 5820c8b0c..f48b694fc 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -130,7 +130,7 @@ class Enotify { } if ($params['type'] == NOTIFY_COMMENT) { -// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); + //logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); $moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false); @@ -138,7 +138,7 @@ class Enotify { $action = 'commented on'; - if(array_key_exists('item',$params) && (! visible_activity($params['item']))) { + if(array_key_exists('item',$params) && in_array($params['item']['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { if(! $always_show_in_notices) { logger('notification: not a visible activity. Ignoring.'); @@ -146,10 +146,10 @@ class Enotify { return; } - if(activity_match($params['item']['verb'], ACTIVITY_LIKE)) + if(activity_match($params['verb'], ACTIVITY_LIKE)) $action = 'liked'; - if(activity_match($params['item']['verb'], ACTIVITY_DISLIKE)) + if(activity_match($params['verb'], ACTIVITY_DISLIKE)) $action = 'disliked'; } -- cgit v1.2.3 From 27baf46eb576002511f188268574aaff9ad16a6b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 13 Feb 2018 12:33:49 +0100 Subject: fix item link in fsprint --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index f48b694fc..c5bc706c2 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -212,7 +212,7 @@ class Enotify { // "your post" if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) - $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%3$s]your %5$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]your %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', $action, -- cgit v1.2.3 From d2ed3a9abbb5c68d1a02eae629bc103aa43a1263 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 25 Feb 2018 21:40:19 -0800 Subject: provide opt-out link and text with notification emails --- Zotlabs/Lib/Enotify.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index c5bc706c2..1461a2e18 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -63,7 +63,9 @@ class Enotify { $thanks = t('Thank You,'); $sitename = get_config('system','sitename'); $site_admin = sprintf( t('%s Administrator'), $sitename); - + $opt_out1 = sprintf( t('This email was sent by %1$s at %2$s.'), t('$Projectname'), \App::get_hostname()); + $opt_out2 = sprintf( t('To stop receiving these messages, please adjust your Notification Settings at %s'), z_root() . '/settings'); + $hopt_out2 = sprintf( t('To stop receiving these messages, please adjust your %s.'), '' . t('Notification Settings') . ''); $sender_name = $product; $hostname = \App::get_hostname(); if(strpos($hostname,':')) @@ -613,6 +615,9 @@ class Enotify { $datarray['titemlink'] = $itemlink; $datarray['thanks'] = $thanks; $datarray['site_admin'] = $site_admin; + $datarray['opt_out1'] = $opt_out1; + $datarray['opt_out2'] = $opt_out2; + $datarray['hopt_out2'] = $hopt_out2; $datarray['title'] = stripslashes($title); $datarray['htmlversion'] = $htmlversion; $datarray['textversion'] = $textversion; @@ -670,6 +675,8 @@ class Enotify { '$hitemlink' => $datarray['hitemlink'], '$thanks' => $datarray['thanks'], '$site_admin' => $datarray['site_admin'], + '$opt_out1' => $datarray['opt_out1'], + '$opt_out2' => $datarray['hopt_out2'], '$title' => $datarray['title'], '$htmlversion' => $datarray['htmlversion'], )); @@ -690,6 +697,8 @@ class Enotify { '$titemlink' => $datarray['titemlink'], '$thanks' => $datarray['thanks'], '$site_admin' => $datarray['site_admin'], + '$opt_out1' => $datarray['opt_out1'], + '$opt_out2' => $datarray['opt_out2'], '$title' => $datarray['title'], '$textversion' => $datarray['textversion'], )); -- cgit v1.2.3 From 90c82e4394240750333358dfad95c3745d7ea6ef Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 28 Feb 2018 08:38:56 +0100 Subject: missed some string for translation - update strings --- Zotlabs/Lib/Enotify.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 1461a2e18..61c98c881 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -138,7 +138,7 @@ class Enotify { $itemlink = $params['link']; - $action = 'commented on'; + $action = t('commented on'); if(array_key_exists('item',$params) && in_array($params['item']['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { @@ -149,10 +149,10 @@ class Enotify { } if(activity_match($params['verb'], ACTIVITY_LIKE)) - $action = 'liked'; + $action = t('liked'); if(activity_match($params['verb'], ACTIVITY_DISLIKE)) - $action = 'disliked'; + $action = t('disliked'); } -- cgit v1.2.3