Skip to content

Commit

Permalink
fix(next-cloud-node): Fix issue with credential verification and shar…
Browse files Browse the repository at this point in the history
…ing file
  • Loading branch information
michael-radency committed Aug 19, 2022
1 parent 1161761 commit 2b4f5c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/nodes-base/nodes/NextCloud/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export async function nextCloudApiRequest(
headers?: object,
encoding?: null | undefined,
query?: object,
// tslint:disable-next-line:no-any
): Promise<any> {
) {
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
const authenticationMethod = this.getNodeParameter('authentication', 0);
Expand All @@ -49,10 +48,15 @@ export async function nextCloudApiRequest(
}

options.uri = `${credentials.webDavUrl}/${encodeURI(endpoint)}`;

if (resource === 'user' && operation === 'create') {
options.uri = options.uri.replace('/remote.php/webdav', '');
}

if (resource === 'file' && operation === 'share') {
options.uri = options.uri.replace('/remote.php/webdav', '');
}

const credentialType =
authenticationMethod === 'accessToken' ? 'nextCloudApi' : 'nextCloudOAuth2Api';

Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/NextCloud/NextCloud.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IExecuteFunctions } from 'n8n-core';
import { NodeApiError } from 'n8n-workflow';
import { IBinaryKeyData, NodeApiError } from 'n8n-workflow';

import {
IDataObject,
Expand Down Expand Up @@ -1139,7 +1139,7 @@ export class NextCloud implements INodeType {
// Create a shallow copy of the binary data so that the old
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Object.assign(newItem.binary, items[i].binary);
Object.assign(newItem.binary as IBinaryKeyData, items[i].binary);
}

items[i] = newItem;
Expand Down

0 comments on commit 2b4f5c6

Please sign in to comment.