aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Enotify.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib/Enotify.php')
-rw-r--r--Zotlabs/Lib/Enotify.php68
1 files changed, 50 insertions, 18 deletions
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 56c717468..9a8628968 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -70,7 +70,22 @@ class Enotify {
$hostname = substr($hostname,0,strpos($hostname,':'));
// Do not translate 'noreply' as it must be a legal 7-bit email address
- $sender_email = 'noreply' . '@' . $hostname;
+
+ $reply_email = get_config('system','reply_address');
+ if(! $reply_email)
+ $reply_email = 'noreply' . '@' . $hostname;
+
+ $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 = "";
@@ -101,7 +116,7 @@ class Enotify {
if ($params['type'] == NOTIFY_MAIL) {
logger('notification: mail');
- $subject = sprintf( t('[Hubzilla:Notify] New mail received at %s'),$sitename);
+ $subject = sprintf( t('[$Projectname:Notify] New mail received at %s'),$sitename);
$preamble = sprintf( t('%1$s, %2$s sent you a new private message at %3$s.'),$recip['channel_name'], $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 private message') . '[/zrl]');
@@ -116,10 +131,13 @@ class Enotify {
$itemlink = $params['link'];
- // ignore like/unlike activity on posts - they probably require a sepearate notification preference
+ // ignore like/unlike activity on posts - they probably require a separate notification preference
- if (array_key_exists('item',$params) && (! visible_activity($params['item'])))
+ 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'];
@@ -189,7 +207,7 @@ class Enotify {
// Before this we have the name of the replier on the subject rendering
// differents subjects for messages on the same thread.
- $subject = sprintf( t('[Hubzilla:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']);
+ $subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']);
$preamble = sprintf( t('%1$s, %2$s commented on an item/conversation you have been following.'), $recip['channel_name'], $sender['xchan_name']);
$epreamble = $dest_str;
@@ -199,7 +217,7 @@ class Enotify {
}
if($params['type'] == NOTIFY_WALL) {
- $subject = sprintf( t('[Hubzilla:Notify] %s posted to your profile wall') , $sender['xchan_name']);
+ $subject = sprintf( t('[$Projectname:Notify] %s posted to your profile wall') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s, %2$s posted to your profile wall at %3$s') , $recip['channel_name'], $sender['xchan_name'], $sitename);
@@ -227,7 +245,7 @@ class Enotify {
return;
}
- $subject = sprintf( t('[Hubzilla:Notify] %s tagged you') , $sender['xchan_name']);
+ $subject = sprintf( t('[$Projectname:Notify] %s tagged you') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s, %2$s tagged you at %3$s') , $recip['channel_name'], $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s, %2$s [zrl=%3$s]tagged you[/zrl].') ,
$recip['channel_name'],
@@ -241,7 +259,7 @@ class Enotify {
}
if ($params['type'] == NOTIFY_POKE) {
- $subject = sprintf( t('[Hubzilla:Notify] %1$s poked you') , $sender['xchan_name']);
+ $subject = sprintf( t('[$Projectname:Notify] %1$s poked you') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s, %2$s poked you at %3$s') , $recip['channel_name'], $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s, %2$s [zrl=%2$s]poked you[/zrl].') ,
$recip['channel_name'],
@@ -259,7 +277,7 @@ class Enotify {
}
if ($params['type'] == NOTIFY_TAGSHARE) {
- $subject = sprintf( t('[Hubzilla:Notify] %s tagged your post') , $sender['xchan_name']);
+ $subject = sprintf( t('[$Projectname:Notify] %s tagged your post') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s, %2$s tagged your post at %3$s') , $recip['channel_name'],$sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s, %2$s tagged [zrl=%3$s]your post[/zrl]') ,
$recip['channel_name'],
@@ -273,7 +291,7 @@ class Enotify {
}
if ($params['type'] == NOTIFY_INTRO) {
- $subject = sprintf( t('[Hubzilla:Notify] Introduction received'));
+ $subject = sprintf( t('[$Projectname:Notify] Introduction received'));
$preamble = sprintf( t('%1$s, you\'ve received an new connection request from \'%2$s\' at %3$s'), $recip['channel_name'], $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s, you\'ve received [zrl=%2$s]a new connection request[/zrl] from %3$s.'),
$recip['channel_name'],
@@ -288,7 +306,7 @@ class Enotify {
}
if ($params['type'] == NOTIFY_SUGGEST) {
- $subject = sprintf( t('[Hubzilla:Notify] Friend suggestion received'));
+ $subject = sprintf( t('[$Projectname:Notify] Friend suggestion received'));
$preamble = sprintf( t('%1$s, you\'ve received a friend suggestion from \'%2$s\' at %3$s'), $recip['channel_name'], $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s, you\'ve received [zrl=%2$s]a friend suggestion[/zrl] for %3$s from %4$s.'),
$recip['channel_name'],
@@ -386,8 +404,11 @@ class Enotify {
// Mark some notifications as seen right away
// Note! The notification have to be created, because they are used to send emails
// So easiest solution to hide them from Notices is to mark them as seen right away.
- // Another option would be to not add them to the DB, and change how emails are handled (probably would be better that way)
+ // 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;
@@ -459,7 +480,7 @@ class Enotify {
// use $_SESSION['zid_override'] to force zid() to use
// the recipient address instead of the current observer
- $_SESSION['zid_override'] = $recip['channel_address'] . '@' . \App::get_hostname();
+ $_SESSION['zid_override'] = channel_reddress($recip);
$_SESSION['zrl_override'] = z_root() . '/channel/' . $recip['channel_address'];
$textversion = zidify_links($textversion);
@@ -515,7 +536,7 @@ class Enotify {
$private_activity = true;
case NOTIFY_MAIL:
$datarray['textversion'] = $datarray['htmlversion'] = $datarray['title'] = '';
- $datarray['subject'] = preg_replace('/' . preg_quote(t('[Hubzilla:Notify]')) . '/','$0*',$datarray['subject']);
+ $datarray['subject'] = preg_replace('/' . preg_quote(t('[$Projectname:Notify]')) . '/','$0*',$datarray['subject']);
break;
default:
break;
@@ -577,7 +598,7 @@ class Enotify {
self::send(array(
'fromName' => $sender_name,
'fromEmail' => $sender_email,
- 'replyTo' => $sender_email,
+ 'replyTo' => $reply_email,
'toEmail' => $recip['account_email'],
'messageSubject' => $datarray['subject'],
'htmlVersion' => $email_html_body,
@@ -606,6 +627,16 @@ class Enotify {
*/
static public function send($params) {
+ $params['sent'] = false;
+ $params['result'] = false;
+
+ call_hooks('email_send', $params);
+
+ if($params['sent']) {
+ 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');
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
@@ -646,6 +677,7 @@ class Enotify {
$messageHeader // message headers
);
logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
+ return $res;
}
static public function format($item) {
@@ -654,12 +686,12 @@ class Enotify {
require_once('include/conversation.php');
- // Call localize_item with the "brief" flag to get a one line status for activities.
+ // Call localize_item to get a one line status for activities.
// This should set $item['localized'] to indicate we have a brief summary.
localize_item($item);
- if($item_localize) {
+ if($item['localize']) {
$itemem_text = $item['localize'];
}
else {
@@ -671,7 +703,7 @@ class Enotify {
// convert this logic into a json array just like the system notifications
return array(
- 'notify_link' => $item['llink'],
+ 'notify_link' => $item['llink'],
'name' => $item['author']['xchan_name'],
'url' => $item['author']['xchan_url'],
'photo' => $item['author']['xchan_photo_s'],