Skip to content

Commit 967b384

Browse files
committed
fix(files_sharing): phpunit & openapi fixes
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent bc5839e commit 967b384

File tree

18 files changed

+804
-326
lines changed

18 files changed

+804
-326
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,8 +2065,14 @@ private function checkInheritedAttributes(IShare $share): void {
20652065
/**
20662066
* Send a mail notification again for a share.
20672067
* The mail_send option must be enabled for the given share.
2068-
* @param string $id
2068+
* @param string $id the share ID
20692069
* @param string $password optional, the password to check against. Necessary for password protected shares.
2070+
* @throws OCSNotFoundException Share not found
2071+
* @throws OCSForbiddenException You are not allowed to send mail notifications
2072+
* @throws OCSBadRequestException Invalid request or wrong password
2073+
* @throws OCSException Error while sending mail notification
2074+
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
2075+
* 200: The email notification was sent successfully
20702076
*/
20712077
#[NoAdminRequired]
20722078
#[UserRateLimit(limit: 5, period: 120)]
@@ -2110,7 +2116,7 @@ public function sendShareEmail(string $id, $password = ''): DataResponse {
21102116
}
21112117

21122118
$provider->sendMailNotification($share);
2113-
return new DataResponse(['message' => 'ok']);
2119+
return new DataResponse();
21142120
} catch(OCSBadRequestException $e) {
21152121
throw $e;
21162122
} catch (Exception $e) {

apps/files_sharing/openapi.json

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,15 @@
17551755
"type": "string",
17561756
"nullable": true,
17571757
"description": "Additional attributes for the share"
1758+
},
1759+
"sendMail": {
1760+
"type": "string",
1761+
"nullable": true,
1762+
"enum": [
1763+
"false",
1764+
"true"
1765+
],
1766+
"description": "Send a mail to the recipient"
17581767
}
17591768
}
17601769
}
@@ -2256,6 +2265,11 @@
22562265
"type": "string",
22572266
"nullable": true,
22582267
"description": "New additional attributes"
2268+
},
2269+
"sendMail": {
2270+
"type": "string",
2271+
"nullable": true,
2272+
"description": "if the share should be send by mail.\n Considering the share already exists, no mail will be send after the share is updated.\n \t\t\t\t You will have to use the sendMail action to send the mail."
22592273
}
22602274
}
22612275
}
@@ -2523,6 +2537,175 @@
25232537
}
25242538
}
25252539
},
2540+
"/ocs/v2.php/apps/files_sharing/api/v1/shares/{id}/send-email": {
2541+
"post": {
2542+
"operationId": "shareapi-send-share-email",
2543+
"summary": "Send a mail notification again for a share. The mail_send option must be enabled for the given share.",
2544+
"tags": [
2545+
"shareapi"
2546+
],
2547+
"security": [
2548+
{
2549+
"bearer_auth": []
2550+
},
2551+
{
2552+
"basic_auth": []
2553+
}
2554+
],
2555+
"requestBody": {
2556+
"required": false,
2557+
"content": {
2558+
"application/json": {
2559+
"schema": {
2560+
"type": "object",
2561+
"properties": {
2562+
"password": {
2563+
"type": "string",
2564+
"default": "",
2565+
"description": "optional, the password to check against. Necessary for password protected shares."
2566+
}
2567+
}
2568+
}
2569+
}
2570+
}
2571+
},
2572+
"parameters": [
2573+
{
2574+
"name": "id",
2575+
"in": "path",
2576+
"description": "the share ID",
2577+
"required": true,
2578+
"schema": {
2579+
"type": "string"
2580+
}
2581+
},
2582+
{
2583+
"name": "OCS-APIRequest",
2584+
"in": "header",
2585+
"description": "Required to be true for the API request to pass",
2586+
"required": true,
2587+
"schema": {
2588+
"type": "boolean",
2589+
"default": true
2590+
}
2591+
}
2592+
],
2593+
"responses": {
2594+
"404": {
2595+
"description": "Share not found",
2596+
"content": {
2597+
"application/json": {
2598+
"schema": {
2599+
"type": "object",
2600+
"required": [
2601+
"ocs"
2602+
],
2603+
"properties": {
2604+
"ocs": {
2605+
"type": "object",
2606+
"required": [
2607+
"meta",
2608+
"data"
2609+
],
2610+
"properties": {
2611+
"meta": {
2612+
"$ref": "#/components/schemas/OCSMeta"
2613+
},
2614+
"data": {}
2615+
}
2616+
}
2617+
}
2618+
}
2619+
}
2620+
}
2621+
},
2622+
"403": {
2623+
"description": "You are not allowed to send mail notifications",
2624+
"content": {
2625+
"application/json": {
2626+
"schema": {
2627+
"type": "object",
2628+
"required": [
2629+
"ocs"
2630+
],
2631+
"properties": {
2632+
"ocs": {
2633+
"type": "object",
2634+
"required": [
2635+
"meta",
2636+
"data"
2637+
],
2638+
"properties": {
2639+
"meta": {
2640+
"$ref": "#/components/schemas/OCSMeta"
2641+
},
2642+
"data": {}
2643+
}
2644+
}
2645+
}
2646+
}
2647+
}
2648+
}
2649+
},
2650+
"400": {
2651+
"description": "Invalid request or wrong password",
2652+
"content": {
2653+
"application/json": {
2654+
"schema": {
2655+
"type": "object",
2656+
"required": [
2657+
"ocs"
2658+
],
2659+
"properties": {
2660+
"ocs": {
2661+
"type": "object",
2662+
"required": [
2663+
"meta",
2664+
"data"
2665+
],
2666+
"properties": {
2667+
"meta": {
2668+
"$ref": "#/components/schemas/OCSMeta"
2669+
},
2670+
"data": {}
2671+
}
2672+
}
2673+
}
2674+
}
2675+
}
2676+
}
2677+
},
2678+
"200": {
2679+
"description": "The email notification was sent successfully",
2680+
"content": {
2681+
"application/json": {
2682+
"schema": {
2683+
"type": "object",
2684+
"required": [
2685+
"ocs"
2686+
],
2687+
"properties": {
2688+
"ocs": {
2689+
"type": "object",
2690+
"required": [
2691+
"meta",
2692+
"data"
2693+
],
2694+
"properties": {
2695+
"meta": {
2696+
"$ref": "#/components/schemas/OCSMeta"
2697+
},
2698+
"data": {}
2699+
}
2700+
}
2701+
}
2702+
}
2703+
}
2704+
}
2705+
}
2706+
}
2707+
}
2708+
},
25262709
"/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/{id}": {
25272710
"post": {
25282711
"operationId": "shareapi-accept-share",

apps/files_sharing/src/components/NewFileRequestDialog.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<FileRequestFinish v-if="share"
4242
v-show="currentStep === STEP.LAST"
4343
:emails="emails"
44-
:isShareByMailEnabled="isShareByMailEnabled"
44+
:is-share-by-mail-enabled="isShareByMailEnabled"
4545
:share="share"
4646
@add-email="email => emails.push(email)"
4747
@remove-email="onRemoveEmail" />
@@ -103,18 +103,20 @@
103103
</template>
104104

105105
<script lang="ts">
106+
// eslint-disable-next-line n/no-extraneous-import
106107
import type { AxiosError } from 'axios'
107-
import { Permission, type Folder, type Node } from '@nextcloud/files'
108+
import type { Folder, Node } from '@nextcloud/files'
108109
import type { OCSResponse } from '@nextcloud/typings/ocs'
109110
import type { PropType } from 'vue'
110111
111112
import { defineComponent } from 'vue'
112113
import { emit } from '@nextcloud/event-bus'
113114
import { generateOcsUrl } from '@nextcloud/router'
114115
import { getCapabilities } from '@nextcloud/capabilities'
116+
import { Permission } from '@nextcloud/files'
117+
import { ShareType } from '@nextcloud/sharing'
115118
import { showError, showSuccess } from '@nextcloud/dialogs'
116119
import { translate, translatePlural } from '@nextcloud/l10n'
117-
import { Type } from '@nextcloud/sharing'
118120
import axios from '@nextcloud/axios'
119121
120122
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
@@ -170,7 +172,7 @@ export default defineComponent({
170172
n: translatePlural,
171173
t: translate,
172174
173-
isShareByMailEnabled: getCapabilities()?.files_sharing?.sharebymail?.enabled === true
175+
isShareByMailEnabled: getCapabilities()?.files_sharing?.sharebymail?.enabled === true,
174176
}
175177
},
176178
@@ -254,9 +256,9 @@ export default defineComponent({
254256
const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')
255257
try {
256258
const request = await axios.post<OCSResponse>(shareUrl, {
257-
shareType: Type.SHARE_TYPE_EMAIL,
259+
shareType: ShareType.Email,
258260
permissions: Permission.CREATE,
259-
261+
260262
label: this.label,
261263
path: this.destination,
262264
note: this.note,
@@ -331,7 +333,7 @@ export default defineComponent({
331333
}
332334
},
333335
334-
async sendEmails () {
336+
async sendEmails() {
335337
this.loading = true
336338
337339
// This should never happen™
@@ -358,7 +360,7 @@ export default defineComponent({
358360
}
359361
},
360362
361-
onEmailSendError(error: AxiosError<OCSResponse>|any) {
363+
onEmailSendError(error: AxiosError<OCSResponse>) {
362364
const errorMessage = error.response?.data?.ocs?.meta?.message
363365
showError(
364366
errorMessage

apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogDatePassword.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
:value="expirationDate"
3838
name="expirationDate"
3939
type="date"
40-
@update:value="$emit('update:expirationDate', $event)"/>
40+
@update:value="$emit('update:expirationDate', $event)" />
4141
</fieldset>
4242

4343
<!-- Password -->
@@ -96,7 +96,7 @@ import GeneratePassword from '../../utils/GeneratePassword'
9696
const sharingConfig = new Config()
9797
9898
export default defineComponent({
99-
name: 'FileRequestDatePassword',
99+
name: 'NewFileRequestDialogDatePassword',
100100
101101
components: {
102102
IconPasswordGen,
@@ -207,7 +207,6 @@ export default defineComponent({
207207
this.$emit('update:password', null)
208208
},
209209
210-
211210
async onGeneratePassword() {
212211
await this.generatePassword()
213212
this.showPassword()

apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogFinish.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import IconCheck from 'vue-material-design-icons/Check.vue'
7373
import IconClipboard from 'vue-material-design-icons/Clipboard.vue'
7474
7575
export default defineComponent({
76-
name: 'FileRequestFinish',
76+
name: 'NewFileRequestDialogFinish',
7777
7878
components: {
7979
IconCheck,

apps/files_sharing/src/components/NewFileRequestDialog/NewFileRequestDialogIntro.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ import NcTextArea from '@nextcloud/vue/dist/Components/NcTextArea.js'
7373
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
7474
7575
export default defineComponent({
76-
name: 'FileRequestIntro',
76+
name: 'NewFileRequestDialogIntro',
7777
7878
components: {
7979
IconFolder,

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ export default {
564564
},
565565
566566
canChangeHideDownload() {
567-
const hasDisabledDownload = (shareAttribute) => shareAttribute.scope === 'permissions' && shareAttribute.key === 'download'&& shareAttribute.value === false
567+
const hasDisabledDownload = (shareAttribute) => shareAttribute.scope === 'permissions' && shareAttribute.key === 'download' && shareAttribute.value === false
568568
return this.fileInfo.shareAttributes.some(hasDisabledDownload)
569569
},
570570

apps/files_sharing/src/components/SharingInput.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import debounce from 'debounce'
3535
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
3636
3737
import Config from '../services/ConfigService.ts'
38-
import GeneratePassword from '../utils/GeneratePassword.ts'
3938
import Share from '../models/Share.js'
4039
import ShareRequests from '../mixins/ShareRequests.js'
4140
import ShareTypes from '../mixins/ShareTypes.js'

apps/files_sharing/src/models/Share.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ export default class Share {
552552
return this.attributes.some(isFileRequest)
553553
}
554554

555-
556555
set hasDownloadPermission(enabled) {
557556
this.setAttribute('permissions', 'download', !!enabled)
558557
}

0 commit comments

Comments
 (0)