From b7559c1df60bc3c0a16ce3ed32c9e8578d8d668e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 2 Oct 2016 10:36:04 +0200 Subject: missing backslash --- 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 d6fe73717..1e2d9d3aa 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -77,7 +77,7 @@ class Enotify { $sender_email = get_config('system','from_email'); if(! $sender_email) - $sender_email = 'Administrator' . '@' . App::get_hostname(); + $sender_email = 'Administrator' . '@' . \App::get_hostname(); $sender_name = get_config('system','from_email_name'); -- cgit v1.2.3 From 816802774dc0d9ecf49d3c1e4f064332508bb429 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 2 Oct 2016 10:47:25 +0200 Subject: another missing backslash --- 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 1e2d9d3aa..a6527ae71 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -82,7 +82,7 @@ class Enotify { $sender_name = get_config('system','from_email_name'); if(! $sender_name) - $sender_name = Zotlabs\Lib\System::get_site_name(); + $sender_name = \Zotlabs\Lib\System::get_site_name(); -- cgit v1.2.3 From 5b10db6f91f4bb876bbadbc9602c68762a3c9b71 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 3 Oct 2016 15:58:54 -0700 Subject: return the email_sent status --- Zotlabs/Lib/Enotify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index a6527ae71..9a8628968 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -633,8 +633,8 @@ class Enotify { call_hooks('email_send', $params); if($params['sent']) { - logger("notification: enotify::send returns " . $params['result'], LOGGER_DEBUG); - return; + logger("notification: enotify::send (addon) returns " . $params['result'], LOGGER_DEBUG); + return $params['result']; } $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); -- cgit v1.2.3 From bad5057a7414eba7f7133538dd671a1413be00e3 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 3 Oct 2016 19:47:36 -0700 Subject: start removing db backticks --- 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 9a8628968..ccb014255 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -364,7 +364,7 @@ class Enotify { do { $dups = false; $hash = random_string(); - $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1", + $r = q("SELECT id FROM notify WHERE hash = '%s' LIMIT 1", dbesc($hash)); if ($r) $dups = true; -- cgit v1.2.3 From daaefed61bc6a38a102ce2c357278158535a2b27 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 13 Oct 2016 16:47:45 -0700 Subject: provide text log results of email success/failure rather than 1 and 0. --- Zotlabs/Lib/Enotify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index ccb014255..9b4117b9c 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -633,7 +633,7 @@ class Enotify { call_hooks('email_send', $params); if($params['sent']) { - logger("notification: enotify::send (addon) returns " . $params['result'], LOGGER_DEBUG); + logger("notification: enotify::send (addon) returns " . (($params['result']) ? 'success' : 'failure'), LOGGER_DEBUG); return $params['result']; } @@ -676,7 +676,7 @@ class Enotify { $multipartMessageBody, // message body $messageHeader // message headers ); - logger("notification: enotify::send returns " . $res, LOGGER_DEBUG); + logger("notification: enotify::send returns " . (($res) ? 'success' : 'failure'), LOGGER_DEBUG); return $res; } -- cgit v1.2.3 From 17091bd38c4e4e5d8b1812dd1d9efeffe0046d02 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 17 Oct 2016 22:09:41 -0700 Subject: add get_photo hook to go along with get_profile_photo hook. This allows a plugin to over-ride the permissions for cover photos or insert a different photo in place of that requested --- Zotlabs/Lib/Enotify.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 9b4117b9c..ffe2f0950 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -78,15 +78,12 @@ class Enotify { $sender_email = get_config('system','from_email'); if(! $sender_email) $sender_email = 'Administrator' . '@' . \App::get_hostname(); - $sender_name = get_config('system','from_email_name'); if(! $sender_name) $sender_name = \Zotlabs\Lib\System::get_site_name(); - - $additional_mail_header = ""; if(array_key_exists('item', $params)) { -- cgit v1.2.3 From 640d15dba548533fbda5d73d04db8f6896197026 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 12 Nov 2016 14:09:33 -0800 Subject: don't send notification for posts/comments on old conversations that were refetched after having expired. We'll accomplish this by limiting notifications to items posted within the last month. --- Zotlabs/Lib/Enotify.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index ffe2f0950..b6f4d3351 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -102,6 +102,10 @@ class Enotify { $title = $params['item']['title']; $body = $params['item']['body']; } + if($item['created'] < datetime_convert('UTC','UTC','now - 1 month')) { + logger('notification invoked for an old item which may have been refetched.',LOGGER_DEBUG,LOG_INFO); + return; + } } else { $title = $body = ''; -- cgit v1.2.3 From a6d47ca77294b8fc4c2538b95d772b3be505fcf1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 22 Nov 2016 14:24:38 -0800 Subject: notification issue --- 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 b6f4d3351..c64ff9868 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -102,7 +102,7 @@ class Enotify { $title = $params['item']['title']; $body = $params['item']['body']; } - if($item['created'] < datetime_convert('UTC','UTC','now - 1 month')) { + if($params['item']['created'] < datetime_convert('UTC','UTC','now - 1 month')) { logger('notification invoked for an old item which may have been refetched.',LOGGER_DEBUG,LOG_INFO); return; } -- cgit v1.2.3 From e06647b54e707f023911ee68d59205c1e85df67a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Dec 2016 17:54:03 -0800 Subject: some preliminary work for email notification of likes - potentially destabilising so disabled until after next release --- Zotlabs/Lib/Enotify.php | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'Zotlabs/Lib/Enotify.php') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index c64ff9868..257687567 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -217,6 +217,85 @@ class Enotify { $hsitelink = sprintf( $sitelink, '' . $sitename . ''); } + if ($params['type'] == NOTIFY_LIKE) { +// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); + + $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; + } + + $parent_mid = $params['parent_mid']; + + // Check to see if there was already a notify for this post. + // If so don't create a second notification + + $p = null; + $p = q("select id from notify where link = '%s' and uid = %d limit 1", + dbesc($params['link']), + intval($recip['channel_id']) + ); + if ($p) { + logger('notification: like already notified'); + pop_lang(); + return; + } + + + // if it's a post figure out who's post it is. + + $p = null; + + if($params['otype'] === 'item' && $parent_mid) { + $p = q("select * from item where mid = '%s' and uid = %d limit 1", + dbesc($parent_mid), + intval($recip['channel_id']) + ); + } + + xchan_query($p); + + + $item_post_type = item_post_type($p[0]); +// $private = $p[0]['item_private']; + $parent_id = $p[0]['id']; + + $parent_item = $p[0]; + + + // "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 liked [zrl=%3$s]your %4$s[/zrl]'), + $recip['channel_name'], + '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $itemlink, + $item_post_type); + else { + pop_lang(); + return; + } + + // Some mail softwares relies on subject field for threading. + // So, we cannot have different subjects for notifications of the same thread. + // Before this we have the name of the replier on the subject rendering + // differents subjects for messages on the same thread. + + $subject = sprintf( t('[$Projectname:Notify] Like received to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); + $preamble = sprintf( t('%1$s, %2$s liked an item/conversation you created.'), $recip['channel_name'], $sender['xchan_name']); + $epreamble = $dest_str; + + $sitelink = t('Please visit %s to view and/or reply to the conversation.'); + $tsitelink = sprintf( $sitelink, $siteurl ); + $hsitelink = sprintf( $sitelink, '' . $sitename . ''); + } + + + if($params['type'] == NOTIFY_WALL) { $subject = sprintf( t('[$Projectname:Notify] %s posted to your profile wall') , $sender['xchan_name']); -- cgit v1.2.3