Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/files_sharing/src/mixins/ShareRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
*
* @param {object} data destructuring object
* @param {string} data.path path to the file/folder which should be shared
* @param {string} data.sendMail send a mail to the recipient can be 'true' or 'false'
* @param {number} data.shareType 0 = user; 1 = group; 3 = public link; 6 = federated cloud share
* @param {string} data.shareWith user/group id with which the file should be shared (optional for shareType > 1)
* @param {boolean} [data.publicUpload] allow public upload to a public shared folder
Expand All @@ -35,9 +36,9 @@ export default {
* @return {Share} the new share
* @throws {Error}
*/
async createShare({ path, permissions, shareType, shareWith, publicUpload, password, sendPasswordByTalk, expireDate, label, note, attributes }) {
async createShare({ path, permissions, sendMail, shareType, shareWith, publicUpload, password, sendPasswordByTalk, expireDate, label, note, attributes }) {
try {
const request = await axios.post(shareUrl, { path, permissions, shareType, shareWith, publicUpload, password, sendPasswordByTalk, expireDate, label, note, attributes })
const request = await axios.post(shareUrl, { path, permissions, sendMail, shareType, shareWith, publicUpload, password, sendPasswordByTalk, expireDate, label, note, attributes })
if (!request?.data?.ocs) {
throw request
}
Expand Down
23 changes: 17 additions & 6 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
</NcCheckboxRadioSwitch>
</div>
</div>
<div v-if="isNewShare && isUserShare" class="sharingTabDetailsView__general-control">
<NcCheckboxRadioSwitch type="switch"
:checked.sync="sendNotificationMailOnCreation">
{{ t('settings', 'Send email notification') }}
</NcCheckboxRadioSwitch>
</div>
<div class="sharingTabDetailsView__advanced-control">
<NcButton id="advancedSectionAccordionAdvancedControl"
type="tertiary"
Expand Down Expand Up @@ -353,6 +359,7 @@ export default {
data() {
return {
writeNoteToRecipientIsChecked: false,
sendNotificationMailOnCreation: true,
sharingPermission: BUNDLED_PERMISSIONS.ALL.toString(),
revertSharingPermission: BUNDLED_PERMISSIONS.ALL.toString(),
setCustomPermissions: false,
Expand Down Expand Up @@ -1027,6 +1034,13 @@ export default {
}
}

if (this.sendNotificationMailOnCreation) {
incomingShare.sendMail = 'true'
}

this.creating = true
share = await this.addShare(incomingShare)
this.creating = false
this.share = share
this.creating = false
this.$emit('add:share', this.share)
Expand Down Expand Up @@ -1069,6 +1083,7 @@ export default {
attributes: JSON.stringify(share.attributes),
...(share.note ? { note: share.note } : {}),
...(share.password ? { password: share.password } : {}),
...(share.sendMail ? { sendMail: share.sendMail } : {}),
})
return resultingShare
} catch (error) {
Expand Down Expand Up @@ -1229,13 +1244,9 @@ export default {
}
}

&__advanced-control {
&__advanced-control, &__general-control {
width: 100%;

button {
margin-top: 0.5em;
}

margin-top: 0.5em;
}

&__advanced {
Expand Down
97 changes: 97 additions & 0 deletions apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down Expand Up @@ -5233,4 +5234,100 @@ public function testPopulateTags(): void {
['file_source' => 42, 'x' => 'y', 'tags' => ['tag1', 'tag2']],
], $result);
}

public function testCreateShareWithMailNotificationEnabled(): void {
$share = $this->createMock(IShare::class);
$node = $this->getMockBuilder(File::class)->getMock();
$userFolder = $this->getMockBuilder(Folder::class)->getMock();

$storage = $this->createMock(\OCP\Files\Storage\IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
[\OCA\Files_Sharing\External\Storage::class, false],
[\OCA\Files_Sharing\SharedStorage::class, false],
]);

$node->method('getPath')->willReturn('/testfile.txt');
$node->method('getId')->willReturn(1);
$node->method('getStorage')->willReturn($storage);
$userFolder->method('get')
->with('/testfile.txt')
->willReturn($node);
$userFolder->method('getById')
->with(1)
->willReturn([]);
$this->rootFolder->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
$this->userManager->method('userExists')->with('recipient')->willReturn(true);
$this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->with($share)->willReturn($share);
$share->method('getNode')->willReturn($node);

$share->expects($this->once())
->method('setMailSend')
->with(true);

$formattedShare = ['id' => '123'];
$controller = $this->mockFormatShare();
$controller->method('formatShare')
->with($share)
->willReturn($formattedShare);

$result = $controller->createShare(
'/testfile.txt', 1, IShare::TYPE_USER, 'recipient',
null, '', null, null, '', '', null, 'true'
);

$this->assertEquals(\OCP\AppFramework\Http::STATUS_OK, $result->getStatus());
$this->assertEquals($formattedShare, $result->getData());
}

public function testCreateShareWithMailNotificationDisabled(): void {
$share = $this->createMock(IShare::class);
$node = $this->getMockBuilder(File::class)->getMock();
$userFolder = $this->getMockBuilder(Folder::class)->getMock();

$storage = $this->createMock(\OCP\Files\Storage\IStorage::class);
$storage->method('instanceOfStorage')
->willReturnMap([
[\OCA\Files_Sharing\External\Storage::class, false],
[\OCA\Files_Sharing\SharedStorage::class, false],
]);

$node->method('getPath')->willReturn('/testfile.txt');
$node->method('getId')->willReturn(1);
$node->method('getStorage')->willReturn($storage);
$userFolder->method('get')
->with('/testfile.txt')
->willReturn($node);
$userFolder->method('getById')
->with(1)
->willReturn([]);
$this->rootFolder->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
$this->userManager->method('userExists')->with('recipient')->willReturn(true);
$this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->with($share)->willReturn($share);
$share->method('getNode')->willReturn($node);

$share->expects($this->once())
->method('setMailSend')
->with(false);

$formattedShare = ['id' => '123'];
$controller = $this->mockFormatShare();
$controller->method('formatShare')
->with($share)
->willReturn($formattedShare);

$result = $controller->createShare(
'/testfile.txt', 1, IShare::TYPE_USER, 'recipient',
null, '', null, null, '', '', null, 'false'
);

$this->assertEquals(\OCP\AppFramework\Http::STATUS_OK, $result->getStatus());
$this->assertEquals($formattedShare, $result->getData());
}
}
2 changes: 0 additions & 2 deletions dist/3982-3982.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/3982-3982.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/3982-3982.js.map.license

This file was deleted.

2 changes: 2 additions & 0 deletions dist/9544-9544.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/9544-9544.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/9544-9544.js.map.license
4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

Loading