From f01538a54f68c172e09aabed90e2651ca2305675 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 17:31:49 -0700 Subject: content expiration --- include/notifier.php | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 648a07062..ca2304845 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -40,6 +40,7 @@ function notifier_run($argv, $argc){ break; } + $expire = false; $top_level = false; $recipients = array(); $url_recipients = array(); @@ -57,6 +58,17 @@ function notifier_run($argv, $argc){ $item = $message[0]; } + elseif($cmd === 'expire') { + $expire = true; + $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1 + AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP - INTERVAL 10 MINUTE", + intval($item_id) + ); + $uid = $item_id; + $item_id = 0; + if(! count($items)) + return; + } else { // find ancestors @@ -76,11 +88,10 @@ function notifier_run($argv, $argc){ intval($parent_id) ); - if(! count($items)){ + if(! count($items)) { return; } - // avoid race condition with deleting entries if($items[0]['deleted']) { @@ -98,11 +109,11 @@ function notifier_run($argv, $argc){ intval($uid) ); - if(count($r)) - $owner = $r[0]; - else { + if(! count($r)) return; - } + + $owner = $r[0]; + $hub = get_config('system','huburl'); // If this is a public conversation, notify the feed hub @@ -117,7 +128,7 @@ function notifier_run($argv, $argc){ $parent = $items[0]; - if($parent['type'] === 'remote') { + if($parent['type'] === 'remote' && (! $expire)) { // local followup to remote post $followup = true; $notify_hub = false; // not public @@ -235,6 +246,7 @@ function notifier_run($argv, $argc){ } else { foreach($items as $item) { + if(! $item['parent']) continue; @@ -242,9 +254,9 @@ function notifier_run($argv, $argc){ if(! $contact) continue; - $atom .= atom_entry($item,'text',$contact,$owner,true); + $atom .= atom_entry($item,'text',$contact,$owner,true); - if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link'])) + if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link']) && (! $expire)) $slaps[] = atom_entry($item,'html',$contact,$owner,true); } } @@ -319,7 +331,7 @@ function notifier_run($argv, $argc){ // only send salmon if public - e.g. if it's ok to notify // a public hub, it's ok to send a salmon - if(count($slaps) && $notify_hub) { + if((count($slaps)) && ($notify_hub) && (! $expire)) { logger('notifier: slapdelivery: ' . $contact['name']); foreach($slaps as $slappy) { if($contact['notify']) { @@ -350,7 +362,7 @@ function notifier_run($argv, $argc){ // send additional slaps to mentioned remote tags (@foo@example.com) - if($slap && count($url_recipients) && $followup && $notify_hub) { + if($slap && count($url_recipients) && $followup && $notify_hub && (! $expire)) { foreach($url_recipients as $url) { if($url) { logger('notifier: urldelivery: ' . $url); -- cgit v1.2.3 From c8f32536ff77193689efe69702f91122f97c1f36 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 11 Apr 2011 03:22:09 -0700 Subject: pull in new 'writable' dfrn flag --- include/notifier.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index ca2304845..9d74f8b9b 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -354,6 +354,7 @@ function notifier_run($argv, $argc){ case 'mail': case 'dspr': case 'feed': + case 'face': default: break; } -- cgit v1.2.3 From ab099e91028122dfb6b10cf9510b1b061f6f547f Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 17 Apr 2011 23:27:11 -0700 Subject: email integration, cont. --- include/notifier.php | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 2 deletions(-) (limited to 'include/notifier.php') 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 . ''; + logger('notifier: email delivery to ' . $addr); + mail($addr, $subject, $message, $headers); + } + break; case 'dspr': case 'feed': case 'face': -- cgit v1.2.3 From a0179235d2d4672ba9dc79b33505555766b3228a Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 18 Apr 2011 20:20:04 -0700 Subject: provide a way to disable mailbox integration --- include/notifier.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 80f0e67c7..4cc6d7a99 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -270,15 +270,20 @@ function notifier_run($argv, $argc){ // 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']; + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + + if(! $mail_disabled) { + 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']; + } } } -- cgit v1.2.3 From 245a56f0c1c7db884d0bbd4265f6f74a20442748 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 26 Apr 2011 04:39:27 -0700 Subject: lots of facebook fixes --- include/notifier.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 4cc6d7a99..b009cc870 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -20,6 +20,8 @@ function notifier_run($argv, $argc){ require_once('include/items.php'); require_once('include/bbcode.php'); + load_hooks(); + if($argc < 3) return; -- cgit v1.2.3 From c052d688284fda76c612325b237d8352f2abb5d4 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 10 May 2011 16:12:50 -0700 Subject: don't use load_view_file() except in email templates and install of htconfig - to avoid getting wrong file when package is updated by copying over an older version. --- include/notifier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index b009cc870..bd061a0c6 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -191,8 +191,8 @@ function notifier_run($argv, $argc){ $contacts = $r; } - $feed_template = load_view_file('view/atom_feed.tpl'); - $mail_template = load_view_file('view/atom_mail.tpl'); + $feed_template = file_get_contents('view/atom_feed.tpl'); + $mail_template = file_get_contents('view/atom_mail.tpl'); $atom = ''; $slaps = array(); -- cgit v1.2.3 From b2e92e0af32f86212d15748c6d432d658905d4b6 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 11 May 2011 04:37:13 -0700 Subject: deprecate load_view_file --- include/notifier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index bd061a0c6..db2542849 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -191,8 +191,8 @@ function notifier_run($argv, $argc){ $contacts = $r; } - $feed_template = file_get_contents('view/atom_feed.tpl'); - $mail_template = file_get_contents('view/atom_mail.tpl'); + $feed_template = get_markup_template('atom_feed.tpl'); + $mail_template = get_markup_template('atom_mail.tpl'); $atom = ''; $slaps = array(); -- cgit v1.2.3