Merge branch 'dev' into 'dev'

Add signatures processing for private messages

See merge request hubzilla/core!1670
This commit is contained in:
Mario 2019-06-15 23:07:39 +02:00
commit 3bc214e544
5 changed files with 15 additions and 6 deletions

View File

@ -26,6 +26,10 @@ class Mail extends \Zotlabs\Web\Controller {
$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) {
if($raw) {
@ -123,7 +127,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,6 +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' => base64_encode($message['sig'])
);
$seen = $message['seen'];

View File

@ -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);
@ -1517,6 +1518,9 @@ function get_mail_elements($x) {
$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'])) {
$arr['mail_recalled'] = 1;

View File

@ -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;
@ -176,7 +176,6 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
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 )

View File

@ -1,4 +1,4 @@
<div id="mail-{{$mail.id}}" class="mb-2 clearfix mail-conv-outside-wrapper">
<div id="mail-{{$mail.id}}" class="mb-2 clearfix mail-conv-outside-wrapper"{{if $mail.sig}} data-sig="{{$mail.sig}}"{{/if}}>
<div class="mb-2 clearfix wall-item-head">
<div class="wall-item-info" >
<a href="{{$mail.from_url}}"><img class="wall-item-photo" src="{{$mail.from_photo}}" alt="{{$mail.from_name}}" /></a>

View File

@ -11,6 +11,7 @@
<input type="hidden" id="inp-prvmail-expires" name="expires" value="{{$defexpire}}" />
<input type="hidden" name="media_str" id="jot-media" value="" />
<input type="hidden" name="preview" id="mail-preview" value="0" />
<input type="hidden" name="signature" id="mail-sig" value="" />
{{if $new}}
<div class="form-group">
<label for="recip">{{$to}}</label>