From b54f30c4b467d77e18c5307081c425d4a2365008 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 37616cb0409c..5ae97d70df00 100644 --- a/apps/files_sharing/lib/Controller/Share20OcsController.php +++ b/apps/files_sharing/lib/Controller/Share20OcsController.php @@ -963,13 +963,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); } /** @@ -988,7 +992,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 ee2fc72b4bfe..05ce4405dbb7 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();