From 4da3933f244d9bb820305d49b0fe09679e297a6e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:52:21 +0200 Subject: Add signatures processing for private messages --- Zotlabs/Module/Mail.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 3202d38a5..c454a2331 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -25,6 +25,7 @@ class Mail extends \Zotlabs\Web\Controller { $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0); $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode'); + $sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : ''); if($preview) { @@ -123,7 +124,7 @@ class Mail extends \Zotlabs\Web\Controller { // We have a local_channel, let send_message use the session channel and save a lookup - $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw); + $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw, $sig); if($ret['success']) { xchan_mail_query($ret['mail']); @@ -396,8 +397,9 @@ class Mail extends \Zotlabs\Web\Controller { 'can_recall' => ($channel['channel_hash'] == $message['from_xchan']), 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''), 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'), + 'sig' => $message['sig'] ); - + $seen = $message['seen']; } -- cgit v1.2.3 From abeb924554cc4a91ed5e420a9f426ced3e2a085a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:53:43 +0200 Subject: Add signatures processing for private messages --- include/message.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/message.php b/include/message.php index 2486beb83..7d05b9ab7 100644 --- a/include/message.php +++ b/include/message.php @@ -19,7 +19,7 @@ function mail_prepare_binary($item) { // send a private message -function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false) { +function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false, $sig = '') { $ret = array('success' => false); $is_reply = false; @@ -175,8 +175,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep $subject = str_rot47(base64url_encode($subject)); if(($body )&& (! $raw)) $body = str_rot47(base64url_encode($body)); - - $sig = ''; // placeholder + $mimetype = ''; //placeholder $r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply, mail_raw ) -- cgit v1.2.3 From 86f4a8d33afbdda7f5f2ace003ad237bde387819 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:54:42 +0200 Subject: Add signatures processing for private messages --- include/items.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/items.php b/include/items.php index 9ceb91519..ed5572233 100755 --- a/include/items.php +++ b/include/items.php @@ -1457,6 +1457,7 @@ function encode_mail($item,$extended = false) { $x['to'] = encode_item_xchan($item['to']); $x['raw'] = $item['mail_raw']; $x['mimetype'] = $item['mail_mimetype']; + $x['sig'] = $item['sig']; if($item['attach']) $x['attach'] = json_decode($item['attach'],true); @@ -1516,6 +1517,9 @@ function get_mail_elements($x) { $arr['expires'] = datetime_convert('UTC','UTC',$x['expires']); $arr['mail_flags'] = 0; + + if(array_key_exists('sig',$x)) + $arr['sig'] = $x['sig']; if($x['flags'] && is_array($x['flags'])) { if(in_array('recalled',$x['flags'])) { -- cgit v1.2.3 From 134dfb8804429ba68c613bb98900d468fdfdba49 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:56:00 +0200 Subject: Formatting --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/items.php b/include/items.php index ed5572233..0af119cc9 100755 --- a/include/items.php +++ b/include/items.php @@ -1457,7 +1457,7 @@ function encode_mail($item,$extended = false) { $x['to'] = encode_item_xchan($item['to']); $x['raw'] = $item['mail_raw']; $x['mimetype'] = $item['mail_mimetype']; - $x['sig'] = $item['sig']; + $x['sig'] = $item['sig']; if($item['attach']) $x['attach'] = json_decode($item['attach'],true); -- cgit v1.2.3 From 75dedb3345a30f0b94a7225a7ee143d61c993024 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:57:28 +0200 Subject: Add signature when send private message --- view/tpl/prv_message.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/view/tpl/prv_message.tpl b/view/tpl/prv_message.tpl index 59472f7d4..b8c81539d 100755 --- a/view/tpl/prv_message.tpl +++ b/view/tpl/prv_message.tpl @@ -11,6 +11,7 @@ + {{if $new}}
-- cgit v1.2.3 From 5315d8fe3f502be7e31a273c4d8006cea113f259 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 20:59:07 +0200 Subject: Add signature when private message displaying --- view/tpl/mail_conv.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/tpl/mail_conv.tpl b/view/tpl/mail_conv.tpl index cd810e999..b0497fe99 100755 --- a/view/tpl/mail_conv.tpl +++ b/view/tpl/mail_conv.tpl @@ -1,4 +1,4 @@ -
+
{{$mail.from_name}} -- cgit v1.2.3 From c9615cc19ccf09873fbc4c18438f110f81ac0864 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 14 Jun 2019 21:08:53 +0200 Subject: Formatting --- Zotlabs/Module/Mail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index c454a2331..4e4c18cae 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -25,7 +25,7 @@ class Mail extends \Zotlabs\Web\Controller { $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0); $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode'); - $sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : ''); + $sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : ''); if($preview) { -- cgit v1.2.3 From 335394aaa110d1fd7cc5804cee1c7b56ccfdd63e Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 15 Jun 2019 15:58:55 +0200 Subject: Add base64 decode if signature encoded --- Zotlabs/Module/Mail.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 4e4c18cae..67d9642b9 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -25,7 +25,10 @@ class Mail extends \Zotlabs\Web\Controller { $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0); $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode'); + $sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : ''); + if(strpos($sig,'b64.') === 0) + $sig = base64_decode(str_replace('b64.', '', $sig)); if($preview) { -- cgit v1.2.3 From 43cec4398d0d035dd9446988134b814513a73080 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 15 Jun 2019 16:03:35 +0200 Subject: base64 encode message signature --- Zotlabs/Module/Mail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 67d9642b9..7c344966b 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -400,7 +400,7 @@ class Mail extends \Zotlabs\Web\Controller { 'can_recall' => ($channel['channel_hash'] == $message['from_xchan']), 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''), 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'), - 'sig' => $message['sig'] + 'sig' => base64_encode($message['sig']) ); $seen = $message['seen']; -- cgit v1.2.3