Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-07-30 02:01:43 +0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-07-30 18:07:20 +0400
commitb9bd54bd981b63b986571b8e90f9809bf8de67dc (patch)
tree5403d8f481c00bccdbe91b3a686ebcb639bd291c
parentdab708b6255f5ca064c7471f74fa8cd795f093d6 (diff)
Add additional error handling for emailing private links
-rw-r--r--apps/files_sharing/ajax/email.php7
-rw-r--r--apps/files_sharing/js/share.js18
-rw-r--r--lib/mail.php3
3 files changed, 21 insertions, 7 deletions
diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php
index e931e5f77e6..2a81e6f9827 100644
--- a/apps/files_sharing/ajax/email.php
+++ b/apps/files_sharing/ajax/email.php
@@ -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())));
+}
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index afe31a75d0b..1ad51873540 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -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(/\/[^\/]*$/, '');
diff --git a/lib/mail.php b/lib/mail.php
index a4e3a39feeb..0ecee0f01c8 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -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);
}
}