diff --git a/include/enotify.php b/Zotlabs/Lib/Enotify.php similarity index 84% rename from include/enotify.php rename to Zotlabs/Lib/Enotify.php index bd8698606..c6405dac2 100644 --- a/include/enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -1,95 +1,99 @@ $datarray['banner'], - '$notify_icon' => Zotlabs\Lib\System::get_notify_icon(), + '$notify_icon' => \Zotlabs\Lib\System::get_notify_icon(), '$product' => $datarray['product'], '$preamble' => $datarray['preamble'], '$sitename' => $datarray['sitename'], @@ -570,7 +574,7 @@ function notification($params) { // use the EmailNotification library to send the message - enotify::send(array( + self::send(array( 'fromName' => $sender_name, 'fromEmail' => $sender_email, 'replyTo' => $sender_email, @@ -587,12 +591,6 @@ function notification($params) { } -/** - * @brief A class for sending email notifications. - * - * @fixme Class names start mostly with capital letter to distinguish them easier. - */ -class enotify { /** * @brief Send a multipart/alternative message with Text and HTML versions. * @@ -649,4 +647,39 @@ class enotify { ); logger("notification: enotify::send returns " . $res, LOGGER_DEBUG); } + + static public function forma($item) { + + $ret = ''; + + require_once('include/conversation.php'); + + // Call localize_item with the "brief" flag 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) { + $itemem_text = $item['localize']; + } + else { + $itemem_text = (($item['item_thread_top']) + ? t('created a new post') + : sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name'])); + } + + // convert this logic into a json array just like the system notifications + + return array( + 'notify_link' => $item['llink'], + 'name' => $item['author']['xchan_name'], + 'url' => $item['author']['xchan_url'], + 'photo' => $item['author']['xchan_photo_s'], + 'when' => relative_date($item['created']), + 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), + 'message' => strip_tags(bbcode($itemem_text)) + ); + + } + } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index b4f493e5b..041939ad8 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -17,10 +17,10 @@ namespace Zotlabs\Module; */ require_once('include/crypto.php'); -require_once('include/enotify.php'); require_once('include/items.php'); require_once('include/attach.php'); +use \Zotlabs\Lib as Zlib; class Item extends \Zotlabs\Web\Controller { @@ -925,7 +925,7 @@ class Item extends \Zotlabs\Web\Controller { // otherwise it will happen during delivery if(($datarray['owner_xchan'] != $datarray['author_xchan']) && (intval($parent_item['item_wall']))) { - notification(array( + Zlib\Enotify::submit(array( 'type' => NOTIFY_COMMENT, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], @@ -943,7 +943,7 @@ class Item extends \Zotlabs\Web\Controller { $parent = $post_id; if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($datarray['item_type'] == ITEM_TYPE_POST)) { - notification(array( + Zlib\Enotify::submit(array( 'type' => NOTIFY_WALL, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index bea4a08b7..f0caa4373 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -1,12 +1,13 @@ NOTIFY_COMMENT, 'from_xchan' => $item['author_xchan'], 'to_xchan' => $r[0]['channel_hash'], @@ -2378,8 +2380,7 @@ function tag_deliver($uid, $item_id) { $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1)); if($poke_notify) { - require_once('include/enotify.php'); - notification(array( + Zlib\Enotify::submit(array( 'to_xchan' => $u[0]['channel_hash'], 'from_xchan' => $item['author_xchan'], 'type' => NOTIFY_POKE, @@ -2544,8 +2545,7 @@ function tag_deliver($uid, $item_id) { * Kill two birds with one stone. As long as we're here, send a mention notification. */ - require_once('include/enotify.php'); - notification(array( + Zlib\Enotify::submit(array( 'to_xchan' => $u[0]['channel_hash'], 'from_xchan' => $item['author_xchan'], 'type' => NOTIFY_TAGSELF, @@ -3046,7 +3046,6 @@ function mail_store($arr) { ); } else { - require_once('include/enotify.php'); $notif_params = array( 'from_xchan' => $arr['from_xchan'], @@ -3057,7 +3056,7 @@ function mail_store($arr) { 'otype' => 'mail' ); - notification($notif_params); + Zlib\Enotify::submit($notif_params); } call_hooks('post_mail_end',$arr); diff --git a/include/network.php b/include/network.php index 3e5263d3e..9fe0fd9cf 100644 --- a/include/network.php +++ b/include/network.php @@ -1819,8 +1819,6 @@ function service_plink($contact, $guid) { function format_and_send_email($sender,$xchan,$item) { - require_once('include/enotify.php'); - $title = $item['title']; $body = $item['body']; @@ -1885,7 +1883,7 @@ function format_and_send_email($sender,$xchan,$item) { // use the EmailNotification library to send the message - enotify::send(array( + Zotlabs\Lib\Enotify::send(array( 'fromName' => $product, 'fromEmail' => $sender_email, 'replyTo' => $sender_email, diff --git a/include/notify.php b/include/notify.php deleted file mode 100644 index 2b032b56b..000000000 --- a/include/notify.php +++ /dev/null @@ -1,37 +0,0 @@ - $item['llink'], - 'name' => $item['author']['xchan_name'], - 'url' => $item['author']['xchan_url'], - 'photo' => $item['author']['xchan_photo_s'], - 'when' => relative_date($item['created']), - 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), - 'message' => strip_tags(bbcode($itemem_text)) - ); - -} - diff --git a/include/zot.php b/include/zot.php index 8ba03ff5c..64f1c0c0e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -505,8 +505,7 @@ function zot_refresh($them, $channel = null, $force = false) { if($new_connection) { if($new_perms != $previous_perms) Zotlabs\Daemon\Master::Summon(array('Notifier','permission_create',$new_connection[0]['abook_id'])); - require_once('include/enotify.php'); - notification(array( + Zotlabs\Lib\Enotify::submit(array( 'type' => NOTIFY_INTRO, 'from_xchan' => $x['hash'], 'to_xchan' => $channel['channel_hash'],