Add additional error handling for emailing private links

This commit is contained in:
Michael Gapczynski 2012-07-29 18:01:43 -04:00
parent dab708b625
commit b9bd54bd98
3 changed files with 21 additions and 7 deletions

View File

@ -9,4 +9,9 @@ $subject = $user.' shared a '.$type.' with you';
$link = $_POST['link'];
$text = $user.' shared the '.$type.' '.$_POST['file'].' with you. It is available for download here: '.$link;
$fromaddress = OCP\Config::getUserValue($user, 'settings', 'email', 'sharing-noreply@'.OCP\Util::getServerHost());
OCP\Util::sendMail($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user);
try {
OCP\Util::sendMail($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user);
OCP\JSON::success();
} catch (Exception $exception) {
OCP\JSON::error(array('data' => array('message' => $exception->getMessage())));
}

View File

@ -202,11 +202,19 @@ OC.Share={
emailPrivateLink:function() {
var link = $('#privateLinkText').val();
var file = link.substr(link.lastIndexOf('/') + 1).replace(/%20/g, ' ');
$.post(OC.filePath('files_sharing', 'ajax', 'email.php'), { toaddress: $('#email').val(), link: link, file: file } );
$('#email').css('font-weight', 'bold');
$('#email').animate({ fontWeight: 'normal' }, 2000, function() {
$(this).val('');
}).val('Email sent');
var email = $('#email').val();
if (email != '') {
$.post(OC.filePath('files_sharing', 'ajax', 'email.php'), { toaddress: email, link: link, file: file }, function(result) {
if (result && result.status == 'success') {
$('#email').css('font-weight', 'bold');
$('#email').animate({ fontWeight: 'normal' }, 2000, function() {
$(this).val('');
}).val('Email sent');
} else {
OC.dialogs.alert(result.data.message, 'Error while sharing');
}
});
}
},
dirname:function(path) {
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');

View File

@ -83,7 +83,8 @@ class OC_Mail {
unset($mailo);
OC_Log::write('mail', 'Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject, OC_Log::DEBUG);
} catch (Exception $exception) {
OC_Log::write('mail', $exception->getMessage(), OC_Log::DEBUG);
OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR);
throw($exception);
}
}