aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-05 18:08:06 -0800
committerfriendica <info@friendica.com>2013-01-05 18:08:06 -0800
commit529451a4e535abb015589149c01b1e9f6d5a0ce2 (patch)
tree183c58e3df61c36c2111ccda7747cad8bc13ab2c /include
parent22ceb7c048c94cd11ad68652e44234e601df3ee9 (diff)
downloadvolse-hubzilla-529451a4e535abb015589149c01b1e9f6d5a0ce2.tar.gz
volse-hubzilla-529451a4e535abb015589149c01b1e9f6d5a0ce2.tar.bz2
volse-hubzilla-529451a4e535abb015589149c01b1e9f6d5a0ce2.zip
start rewrite of notification system delivery backend
Diffstat (limited to 'include')
-rw-r--r--include/enotify.php112
-rwxr-xr-xinclude/items.php15
-rw-r--r--include/zot.php1
3 files changed, 82 insertions, 46 deletions
diff --git a/include/enotify.php b/include/enotify.php
index 5780d1836..8957fb3bc 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -6,10 +6,28 @@ function notification($params) {
$a = get_app();
- // from here on everything is in the recipients language
- push_lang($params['language']);
+ if($params['from_xchan']) {
+ $x = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($params['from_xchan'])
+ );
+ }
+ if($params['to_xchan']) {
+ $y = q("select channel.*, account.* from channel left join account on channel_account_id = account_id
+ where channel_hash = '%s' limit 1",
+ dbesc($params['to_xchan'])
+ );
+ }
+ if($x & $y) {
+ $sender = $x[0];
+ $recip = $y[0];
+ }
+ else
+ return;
+
+ // from here on everything is in the recipients language
+ push_lang($recip['account_language']); // should probably have a channel language
$banner = t('Red Notification');
$product = FRIENDICA_PLATFORM;
@@ -23,7 +41,9 @@ function notification($params) {
if(strpos($hostname,':'))
$hostname = substr($hostname,0,strpos($hostname,':'));
- $sender_email = t('noreply') . '@' . $hostname;
+ // Do not translate 'noreply' as it must be a legal 7-bit email address
+ $sender_email = 'noreply' . '@' . $hostname;
+
$additional_mail_header = "";
if(array_key_exists('item',$params)) {
@@ -41,8 +61,8 @@ function notification($params) {
$subject = sprintf( t('[Red:Notify] New mail received at %s'),$sitename);
- $preamble = sprintf( t('%1$s sent you a new private message at %2$s.'),$params['source_name'],$sitename);
- $epreamble = sprintf( t('%1$s sent you %2$s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
+ $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.'),'[url=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
$sitelink = t('Please visit %s to view and/or reply to your private messages.');
$tsitelink = sprintf( $sitelink, $siteurl . '/message/' . $params['item']['id'] );
$hsitelink = sprintf( $sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
@@ -255,17 +275,17 @@ function notification($params) {
$datarray = array();
- $datarray['hash'] = $hash;
- $datarray['name'] = $params['source_name'];
- $datarray['url'] = $params['source_link'];
- $datarray['photo'] = $params['source_photo'];
- $datarray['date'] = datetime_convert();
- $datarray['uid'] = $params['uid'];
- $datarray['link'] = $itemlink;
+ $datarray['hash'] = $hash;
+ $datarray['name'] = $sender['xchan_name'];
+ $datarray['url'] = $sender['xchan_url'];
+ $datarray['photo'] = $sender['xchan_photo_s'];
+ $datarray['date'] = datetime_convert();
+ $datarray['uid'] = $params['uid'];
+ $datarray['link'] = $itemlink;
$datarray['parent'] = $parent_id;
- $datarray['type'] = $params['type'];
- $datarray['verb'] = $params['verb'];
- $datarray['otype'] = $params['otype'];
+ $datarray['type'] = $params['type'];
+ $datarray['verb'] = $params['verb'];
+ $datarray['otype'] = $params['otype'];
call_hooks('enotify_store', $datarray);
@@ -309,7 +329,7 @@ function notification($params) {
// send email notification if notification preferences permit
require_once('bbcode.php');
- if((intval($params['notify_flags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM) {
+ if((intval($recip['channel_notifyflags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM) {
logger('notification: sending notification email');
@@ -354,29 +374,29 @@ intval($params['uid']), LOGGER_DEBUG);
"<br />\n",$body))));
$datarray = array();
- $datarray['banner'] = $banner;
- $datarray['product'] = $product;
- $datarray['preamble'] = $preamble;
- $datarray['sitename'] = $sitename;
- $datarray['siteurl'] = $siteurl;
- $datarray['type'] = $params['type'];
- $datarray['parent'] = $params['parent'];
- $datarray['source_name'] = $params['source_name'];
- $datarray['source_link'] = $params['source_link'];
- $datarray['source_photo'] = $params['source_photo'];
- $datarray['uid'] = $params['uid'];
- $datarray['username'] = $params['to_name'];
- $datarray['hsitelink'] = $hsitelink;
- $datarray['tsitelink'] = $tsitelink;
- $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
- $datarray['titemlink'] = $itemlink;
- $datarray['thanks'] = $thanks;
- $datarray['site_admin'] = $site_admin;
- $datarray['title'] = stripslashes($title);
- $datarray['htmlversion'] = $htmlversion;
- $datarray['textversion'] = $textversion;
- $datarray['subject'] = $subject;
- $datarray['headers'] = $additional_mail_header;
+ $datarray['banner'] = $banner;
+ $datarray['product'] = $product;
+ $datarray['preamble'] = $preamble;
+ $datarray['sitename'] = $sitename;
+ $datarray['siteurl'] = $siteurl;
+ $datarray['type'] = $params['type'];
+ $datarray['parent'] = $params['parent'];
+ $datarray['source_name'] = $sender['xchan_name'];
+ $datarray['source_link'] = $sender['xchan_url'];
+ $datarray['source_photo'] = $sender['xchan_photo_s'];
+ $datarray['uid'] = $params['uid'];
+ $datarray['username'] = $recip['channel_name'];
+ $datarray['hsitelink'] = $hsitelink;
+ $datarray['tsitelink'] = $tsitelink;
+ $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
+ $datarray['titemlink'] = $itemlink;
+ $datarray['thanks'] = $thanks;
+ $datarray['site_admin'] = $site_admin;
+ $datarray['title'] = stripslashes($title);
+ $datarray['htmlversion'] = $htmlversion;
+ $datarray['textversion'] = $textversion;
+ $datarray['subject'] = $subject;
+ $datarray['headers'] = $additional_mail_header;
call_hooks('enotify_mail', $datarray);
@@ -425,13 +445,13 @@ intval($params['uid']), LOGGER_DEBUG);
// use the EmailNotification library to send the message
enotify::send(array(
- 'fromName' => $sender_name,
- 'fromEmail' => $sender_email,
- 'replyTo' => $sender_email,
- 'toEmail' => $params['to_email'],
- 'messageSubject' => $datarray['subject'],
- 'htmlVersion' => $email_html_body,
- 'textVersion' => $email_text_body,
+ 'fromName' => $sender_name,
+ 'fromEmail' => $sender_email,
+ 'replyTo' => $sender_email,
+ 'toEmail' => $recip['account_email'],
+ 'messageSubject' => $datarray['subject'],
+ 'htmlVersion' => $email_html_body,
+ 'textVersion' => $email_text_body,
'additionalMailHeader' => $datarray['headers'],
));
}
diff --git a/include/items.php b/include/items.php
index 8e4e2dd8d..de441c6b7 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1727,6 +1727,7 @@ function mail_store($arr) {
if($r) {
$current_post = $r[0]['id'];
logger('mail_store: created item ' . $current_post, LOGGER_DEBUG);
+ $arr['id'] = $current_post; // for notification
}
else {
logger('mail_store: could not locate created item');
@@ -1740,6 +1741,20 @@ function mail_store($arr) {
intval($current_post)
);
}
+ else {
+ require_once('include/enotify.php');
+
+ $notif_params = array(
+ 'from_xchan' => $arr['from_xchan'],
+ 'to_xchan' => $arr['to_xchan'],
+ 'type' => NOTIFY_MAIL,
+ 'item' => $arr,
+ 'verb' => ACTIVITY_POST,
+ 'otype' => 'mail'
+ );
+
+ notification($notif_params);
+ }
call_hooks('post_mail_end',$arr);
return $current_post;
diff --git a/include/zot.php b/include/zot.php
index e134ac428..2752fc2e4 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -987,6 +987,7 @@ function process_mail_delivery($sender,$arr,$deliveries) {
$arr['account_id'] = $channel['channel_account_id'];
$arr['channel_id'] = $channel['channel_id'];
$item_id = mail_store($arr);
+
}
}
}