From b9c9eb5576a66335594783579ca571d53beb7445 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Tue, 14 May 2019 13:24:06 +0300 Subject: [PATCH] Treat send attempt unsuccessful when there is a message. --- .../lib/Controller/Share20OcsController.php | 14 +++++++++----- core/js/sharedialogshareelistview.js | 2 +- core/js/tests/specs/sharedialogshareelistview.js | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/files_sharing/lib/Controller/Share20OcsController.php b/apps/files_sharing/lib/Controller/Share20OcsController.php index 4d3ebe75f847..aa44fb48443f 100644 --- a/apps/files_sharing/lib/Controller/Share20OcsController.php +++ b/apps/files_sharing/lib/Controller/Share20OcsController.php @@ -967,13 +967,17 @@ public function notifyRecipients($itemSource, $itemType, $shareType, $recipient) Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, true); } - $message = empty($result) - ? null - : $this->l->t( + if (empty($result)) { + $message = null; + $data = ['status' => 'success']; + } else { + $message = $this->l->t( "Couldn't send mail to following recipient(s): %s ", \implode(', ', $result) ); - return new Result([], 200, $message); + $data = ['status' => 'error']; + } + return new Result($data, 200, $message); } /** @@ -992,7 +996,7 @@ public function notifyRecipients($itemSource, $itemType, $shareType, $recipient) public function notifyRecipientsDisabled($itemSource, $itemType, $shareType, $recipient) { // FIXME: migrate to a new share API Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, true); - return new Result(); + return new Result(['status' => 'success']); } /** diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index f0bf569a732e..29583d284a5a 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -369,7 +369,7 @@ $loading.removeClass('hidden'); this.model.sendNotificationForShare(shareType, shareWith, true).then(function(result) { - if (result.ocs.meta.status === 'ok') { + if (result.ocs.data.status === 'success') { OC.Notification.showTemporary(t('core', 'Email notification was sent!')); $target.remove(); } else { diff --git a/core/js/tests/specs/sharedialogshareelistview.js b/core/js/tests/specs/sharedialogshareelistview.js index b304e4a27cd1..c89d2d220cac 100644 --- a/core/js/tests/specs/sharedialogshareelistview.js +++ b/core/js/tests/specs/sharedialogshareelistview.js @@ -221,7 +221,7 @@ describe('OC.Share.ShareDialogShareeListView', function () { expect(notificationStub.called).toEqual(true); notificationStub.restore(); - deferred.resolve({ ocs: { meta: {status: 'ok' }}}); + deferred.resolve({ ocs: { data : { status: 'success'}, meta: {message: null }}}); expect(notifStub.calledOnce).toEqual(true); notifStub.restore(); @@ -247,7 +247,7 @@ describe('OC.Share.ShareDialogShareeListView', function () { expect(notificationStub.called).toEqual(true); notificationStub.restore(); - deferred.resolve({ ocs: { meta: {status: 'error', message: 'message'}}}); + deferred.resolve({ ocs: { data: {status: 'error'}, meta: {message: 'message'}}}); expect(notifStub.calledOnce).toEqual(true); notifStub.restore();