From f111c5c325fec1139ee7ea36c691de452469fa5a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Dec 2016 17:30:02 -0800 Subject: mail preview (basic functionality) --- Zotlabs/Module/Mail.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Zotlabs/Module/Mail.php') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index c767c8e56..24ab2017c 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -24,6 +24,39 @@ class Mail extends \Zotlabs\Web\Controller { $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); + + + if($preview) { + if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { + $attachments = array(); + foreach($match[2] as $mtch) { + $hash = substr($mtch,0,strpos($mtch,',')); + $rev = intval(substr($mtch,strpos($mtch,','))); + $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); + if($r['success']) { + $attachments[] = array( + 'href' => z_root() . '/attach/' . $r['data']['hash'], + 'length' => $r['data']['filesize'], + 'type' => $r['data']['filetype'], + 'title' => urlencode($r['data']['filename']), + 'revision' => $r['data']['revision'] + ); + } + $body = trim(str_replace($match[1],'',$body)); + } + } +logger('previewing'); + echo json_encode(['preview' => smilies(bbcode($body))]); + killme(); + } + + + + + + + + // If we have a raw string for a recipient which hasn't been auto-filled, // it means they probably aren't in our address book, hence we don't know // if we have permission to send them private messages. -- cgit v1.2.3 From 0394a3e93957b5bb6574ca95e290e414ed049404 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Dec 2016 20:01:38 -0800 Subject: tag and mention handling in private mail (which required refactoring the bbcode cleanup stuff in mod_item) --- Zotlabs/Module/Mail.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'Zotlabs/Module/Mail.php') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 24ab2017c..2a8407910 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -23,10 +23,12 @@ class Mail extends \Zotlabs\Web\Controller { $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); - - if($preview) { + + $body = cleanup_bbcode($body); + $results = linkify_tags($a, $body, local_channel()); + if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { $attachments = array(); foreach($match[2] as $mtch) { @@ -45,18 +47,11 @@ class Mail extends \Zotlabs\Web\Controller { $body = trim(str_replace($match[1],'',$body)); } } -logger('previewing'); + echo json_encode(['preview' => smilies(bbcode($body))]); killme(); } - - - - - - - // If we have a raw string for a recipient which hasn't been auto-filled, // it means they probably aren't in our address book, hence we don't know // if we have permission to send them private messages. -- cgit v1.2.3 From 350627988eb7813dac69450ff97f03a33e70d9f2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 19 Dec 2016 14:35:13 -0800 Subject: zidify private mail --- Zotlabs/Module/Mail.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module/Mail.php') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 2a8407910..459ce5acf 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -47,8 +47,7 @@ class Mail extends \Zotlabs\Web\Controller { $body = trim(str_replace($match[1],'',$body)); } } - - echo json_encode(['preview' => smilies(bbcode($body))]); + echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); killme(); } @@ -110,6 +109,8 @@ class Mail extends \Zotlabs\Web\Controller { require_once('include/text.php'); linkify_tags($a, $body, local_channel()); + // I don't think this is used any more. + if($preview) { $mail = [ 'mailbox' => 'outbox', @@ -118,8 +119,8 @@ class Mail extends \Zotlabs\Web\Controller { 'from_name' => $channel['xchan_name'], 'from_url' => $channel['xchan_url'], 'from_photo' => $channel['xchan_photo_s'], - 'subject' => smilies(bbcode($subject)), - 'body' => smilies(bbcode($body)), + 'subject' => zidify_links(smilies(bbcode($subject))), + 'body' => zidify_links(smilies(bbcode($body))), 'attachments' => '', 'can_recall' => false, 'is_recalled' => '', @@ -369,7 +370,7 @@ class Mail extends \Zotlabs\Web\Controller { 'to_url' => chanlink_hash($message['to_xchan']), 'to_photo' => $message['to']['xchan_photo_s'], 'subject' => $message['title'], - 'body' => smilies(bbcode($message['body'])), + 'body' => zidify_links(smilies(bbcode($message['body']))), 'attachments' => $s, 'delete' => t('Delete message'), 'dreport' => t('Delivery report'), -- cgit v1.2.3