Skip to content

Commit

Permalink
Treat send attempt unsuccessful when there is a message.
Browse files Browse the repository at this point in the history
  • Loading branch information
VicDeo committed May 14, 2019
1 parent 7e920e3 commit b9c9eb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions apps/files_sharing/lib/Controller/Share20OcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/js/sharedialogshareelistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions core/js/tests/specs/sharedialogshareelistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand Down

0 comments on commit b9c9eb5

Please sign in to comment.