aboutsummaryrefslogtreecommitdiffstats
path: root/include/notifier.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/notifier.php')
-rw-r--r--include/notifier.php91
1 files changed, 89 insertions, 2 deletions
diff --git a/include/notifier.php b/include/notifier.php
index 9d74f8b9b..80f0e67c7 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -72,7 +72,7 @@ function notifier_run($argv, $argc){
else {
// find ancestors
- $r = q("SELECT `parent`, `uid`, `edited` FROM `item` WHERE `id` = %d LIMIT 1",
+ $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
intval($item_id)
);
@@ -80,6 +80,7 @@ function notifier_run($argv, $argc){
return;
}
+ $parent_item = $r[0];
$parent_id = intval($r[0]['parent']);
$uid = $r[0]['uid'];
$updated = $r[0]['edited'];
@@ -267,12 +268,25 @@ function notifier_run($argv, $argc){
logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA);
+ // If this is a public message and pubmail is set on the parent, include all your email contacts
+
+ if((! strlen($parent_item['allow_cid'])) && (! strlen($parent_item['allow_gid'])) && (! strlen($parent_item['deny_cid'])) && (! strlen($parent_item['deny_gid']))
+ && (intval($parent_item['pubmail']))) {
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `network` = '%s'",
+ intval($uid),
+ dbesc(NETWORK_MAIL)
+ );
+ if(count($r)) {
+ foreach($r as $rr)
+ $recipients[] = $rr['id'];
+ }
+ }
+
if($followup)
$recip_str = $parent['contact-id'];
else
$recip_str = implode(', ', $recipients);
-
$r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ",
dbesc($recip_str)
);
@@ -352,6 +366,79 @@ function notifier_run($argv, $argc){
}
break;
case 'mail':
+
+ // WARNING: does not currently convert to RFC2047 header encodings, etc.
+
+ $addr = $contact['addr'];
+ if(! strlen($addr))
+ break;
+
+ if($cmd === 'wall-new' || $cmd === 'comment-new') {
+
+ $it = null;
+ if($cmd === 'wall-new')
+ $it = $items[0];
+ else {
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($argv[2]),
+ intval($uid)
+ );
+ if(count($r))
+ $it = $r[0];
+ }
+ if(! $it)
+ break;
+
+
+
+ $local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+ if(! count($local_user))
+ break;
+
+ $reply_to = '';
+ $r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+ if($r1 && $r1[0]['reply_to'])
+ $reply_to = $r1[0]['reply_to'];
+
+ $subject = (($it['title']) ? $it['title'] : t("\x28no subject\x29")) ;
+ $headers = 'From: ' . $local_user[0]['username'] . ' <' . $local_user[0]['email'] . '>' . "\n";
+
+ if($reply_to)
+ $headers .= 'Reply-to: ' . $reply_to . "\n";
+
+ $headers .= 'Message-id: <' . $it['uri'] . '>' . "\n";
+
+ if($it['uri'] !== $it['parent-uri']) {
+ $header .= 'References: <' . $it['parent-uri'] . '>' . "\n";
+ if(! strlen($it['title'])) {
+ $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
+ dbesc($it['parent-uri'])
+ );
+ if(count($r)) {
+ $subtitle = $r[0]['title'];
+ if($subtitle) {
+ if(strncasecmp($subtitle,'RE:',3))
+ $subject = $subtitle;
+ else
+ $subject = 'Re: ' . $subtitle;
+ }
+ }
+ }
+ }
+
+ $headers .= 'MIME-Version: 1.0' . "\n";
+ $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
+ $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
+ $html = prepare_body($it);
+ $message = '<html><body>' . $html . '</body></html>';
+ logger('notifier: email delivery to ' . $addr);
+ mail($addr, $subject, $message, $headers);
+ }
+ break;
case 'dspr':
case 'feed':
case 'face':