Skip to content

Commit 06ae2ca

Browse files
Add companyUrl parameter to post actions
1 parent 36327c5 commit 06ae2ca

5 files changed

Lines changed: 68 additions & 12 deletions

File tree

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
1-
import type { IExecuteFunctions } from 'n8n-workflow';
1+
import type { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
22
import {
33
createParameterWithDisplayOptions,
44
postUrlParameter,
55
commentTextParameter,
6+
postCompanyUrlParameter,
67
} from '../../shared/SharedParameters';
78
import { StandardLinkedApiOperation } from '../../shared/LinkedApiOperation';
89
import { AVAILABLE_ACTION } from '../../shared/AvailableActions';
910

1011
export class CommentOnPost extends StandardLinkedApiOperation {
1112
operationName = AVAILABLE_ACTION.commentOnPost;
1213

13-
fields = [
14+
fields: INodeProperties[] = [
1415
createParameterWithDisplayOptions(postUrlParameter, this.show),
1516
createParameterWithDisplayOptions(commentTextParameter, this.show),
17+
{
18+
displayName: 'Additional Parameters',
19+
name: 'additionalParameters',
20+
type: 'collection',
21+
placeholder: 'Add Field',
22+
default: {},
23+
displayOptions: {
24+
show: this.show,
25+
},
26+
options: [postCompanyUrlParameter],
27+
},
1628
];
1729

1830
public body(context: IExecuteFunctions): Record<string, any> {
19-
return {
31+
const additionalParameters = context.getNodeParameter('additionalParameters', 0, {}) as {
32+
postCompanyUrl?: string;
33+
};
34+
35+
const body: Record<string, any> = {
2036
postUrl: this.stringParameter(context, 'postUrl'),
2137
text: this.stringParameter(context, 'commentText'),
2238
};
39+
40+
if (additionalParameters.postCompanyUrl) {
41+
body.companyUrl = additionalParameters.postCompanyUrl;
42+
}
43+
44+
return body;
2345
}
2446
}

nodes/LinkedApi/operations/webhook/CreatePost.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class CreatePost extends StandardLinkedApiOperation {
1212

1313
fields: INodeProperties[] = [
1414
createParameterWithDisplayOptions(postTextParameter, this.show),
15-
createParameterWithDisplayOptions(postCompanyUrlParameter, this.show),
1615
{
1716
displayName: 'Attachments',
1817
name: 'attachments',
@@ -80,19 +79,32 @@ export class CreatePost extends StandardLinkedApiOperation {
8079
},
8180
],
8281
},
82+
{
83+
displayName: 'Additional Parameters',
84+
name: 'additionalParameters',
85+
type: 'collection',
86+
placeholder: 'Add Field',
87+
default: {},
88+
displayOptions: {
89+
show: this.show,
90+
},
91+
options: [postCompanyUrlParameter],
92+
},
8393
];
8494

8595
public body(context: IExecuteFunctions): Record<string, any> {
8696
const text = this.stringParameter(context, 'postText');
87-
const companyUrl = this.stringParameter(context, 'postCompanyUrl');
97+
const additionalParameters = context.getNodeParameter('additionalParameters', 0, {}) as {
98+
postCompanyUrl?: string;
99+
};
88100
const attachmentsData = context.getNodeParameter('attachments', 0, {}) as {
89101
attachment?: Array<{ type: string; url: string; name?: string }>;
90102
};
91103

92104
const body: Record<string, any> = { text };
93105

94-
if (companyUrl) {
95-
body.companyUrl = companyUrl;
106+
if (additionalParameters.postCompanyUrl) {
107+
body.companyUrl = additionalParameters.postCompanyUrl;
96108
}
97109

98110
if (attachmentsData.attachment && attachmentsData.attachment.length > 0) {
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
1-
import type { IExecuteFunctions } from 'n8n-workflow';
1+
import type { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
22
import {
33
createParameterWithDisplayOptions,
44
postUrlParameter,
55
reactionTypeParameter,
6+
postCompanyUrlParameter,
67
} from '../../shared/SharedParameters';
78
import { StandardLinkedApiOperation } from '../../shared/LinkedApiOperation';
89
import { AVAILABLE_ACTION } from '../../shared/AvailableActions';
910

1011
export class ReactToPost extends StandardLinkedApiOperation {
1112
operationName = AVAILABLE_ACTION.reactToPost;
1213

13-
fields = [
14+
fields: INodeProperties[] = [
1415
createParameterWithDisplayOptions(postUrlParameter, this.show),
1516
createParameterWithDisplayOptions(reactionTypeParameter, this.show),
17+
{
18+
displayName: 'Additional Parameters',
19+
name: 'additionalParameters',
20+
type: 'collection',
21+
placeholder: 'Add Field',
22+
default: {},
23+
displayOptions: {
24+
show: this.show,
25+
},
26+
options: [postCompanyUrlParameter],
27+
},
1628
];
1729

1830
public body(context: IExecuteFunctions): Record<string, any> {
19-
return {
31+
const additionalParameters = context.getNodeParameter('additionalParameters', 0, {}) as {
32+
postCompanyUrl?: string;
33+
};
34+
35+
const body: Record<string, any> = {
2036
postUrl: this.stringParameter(context, 'postUrl'),
2137
type: this.stringParameter(context, 'reactionType'),
2238
};
39+
40+
if (additionalParameters.postCompanyUrl) {
41+
body.companyUrl = additionalParameters.postCompanyUrl;
42+
}
43+
44+
return body;
2345
}
2446
}

nodes/LinkedApi/shared/SharedParameters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ export const postCompanyUrlParameter: INodeProperties = {
454454
type: 'string',
455455
default: '',
456456
placeholder: 'https://www.linkedin.com/company/acme-corp',
457-
description: 'LinkedIn company page URL. If specified, the post will be created on the company page.',
457+
description: 'LinkedIn company page URL. If specified, the action will be performed on behalf of the company page.',
458458
};
459459

460460
// Custom Workflow Parameters

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "n8n-nodes-linked-api",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Connect your LinkedIn accounts to n8n's automation platform.",
55
"keywords": [
66
"n8n-community-node-package",

0 commit comments

Comments
 (0)