2022-01-03 13:42:42 -08:00
|
|
|
import { IExecuteFunctions } from 'n8n-core';
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
import {
|
|
|
|
IDataObject,
|
|
|
|
ILoadOptionsFunctions,
|
2020-10-01 05:01:39 -07:00
|
|
|
INodeExecutionData,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
INodePropertyOptions,
|
2020-10-01 05:01:39 -07:00
|
|
|
INodeType,
|
|
|
|
INodeTypeDescription,
|
2021-04-16 09:33:36 -07:00
|
|
|
NodeOperationError,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
import { linkedInApiRequest } from './GenericFunctions';
|
2022-08-17 08:50:24 -07:00
|
|
|
import { postFields, postOperations } from './PostDescription';
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
|
|
|
export class LinkedIn implements INodeType {
|
2022-04-22 09:29:51 -07:00
|
|
|
// eslint-disable-next-line n8n-nodes-base/node-class-description-missing-subtitle
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
description: INodeTypeDescription = {
|
|
|
|
displayName: 'LinkedIn',
|
|
|
|
name: 'linkedIn',
|
2022-06-23 14:15:29 -07:00
|
|
|
icon: 'file:linkedin.svg',
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
group: ['input'],
|
|
|
|
version: 1,
|
2022-06-23 14:15:29 -07:00
|
|
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
2021-07-03 05:40:16 -07:00
|
|
|
description: 'Consume LinkedIn API',
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
defaults: {
|
|
|
|
name: 'LinkedIn',
|
|
|
|
},
|
|
|
|
inputs: ['main'],
|
|
|
|
outputs: ['main'],
|
|
|
|
credentials: [
|
|
|
|
{
|
|
|
|
name: 'linkedInOAuth2Api',
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
properties: [
|
|
|
|
{
|
|
|
|
displayName: 'Resource',
|
|
|
|
name: 'resource',
|
|
|
|
type: 'options',
|
2022-05-20 14:47:24 -07:00
|
|
|
noDataExpression: true,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Post',
|
|
|
|
value: 'post',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'post',
|
|
|
|
},
|
|
|
|
//POST
|
|
|
|
...postOperations,
|
|
|
|
...postFields,
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
methods = {
|
|
|
|
loadOptions: {
|
|
|
|
// Get Person URN which has to be used with other LinkedIn API Requests
|
|
|
|
// https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin
|
|
|
|
async getPersonUrn(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
|
|
|
const returnData: INodePropertyOptions[] = [];
|
|
|
|
const person = await linkedInApiRequest.call(this, 'GET', '/me', {});
|
2022-08-17 08:50:24 -07:00
|
|
|
returnData.push({
|
|
|
|
name: `${person.localizedFirstName} ${person.localizedLastName}`,
|
|
|
|
value: person.id,
|
|
|
|
});
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
return returnData;
|
|
|
|
},
|
2020-10-22 06:46:03 -07:00
|
|
|
},
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
const items = this.getInputData();
|
|
|
|
const returnData: IDataObject[] = [];
|
|
|
|
let responseData;
|
|
|
|
const resource = this.getNodeParameter('resource', 0) as string;
|
|
|
|
const operation = this.getNodeParameter('operation', 0) as string;
|
2022-06-23 14:15:29 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
let body: any = {}; // tslint:disable-line:no-any
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
2021-07-19 23:58:54 -07:00
|
|
|
try {
|
|
|
|
if (resource === 'post') {
|
|
|
|
if (operation === 'create') {
|
|
|
|
const text = this.getNodeParameter('text', i) as string;
|
|
|
|
const shareMediaCategory = this.getNodeParameter('shareMediaCategory', i) as string;
|
|
|
|
const postAs = this.getNodeParameter('postAs', i) as string;
|
2022-11-18 07:29:44 -08:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
let authorUrn = '';
|
|
|
|
let visibility = 'PUBLIC';
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (postAs === 'person') {
|
|
|
|
const personUrn = this.getNodeParameter('person', i) as string;
|
|
|
|
// Only if posting as a person can user decide if post visible by public or connections
|
2022-08-17 08:50:24 -07:00
|
|
|
visibility = (additionalFields.visibility as string) || 'PUBLIC';
|
2021-07-19 23:58:54 -07:00
|
|
|
authorUrn = `urn:li:person:${personUrn}`;
|
|
|
|
} else {
|
|
|
|
const organizationUrn = this.getNodeParameter('organization', i) as string;
|
|
|
|
authorUrn = `urn:li:organization:${organizationUrn}`;
|
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
let description = '';
|
|
|
|
let title = '';
|
|
|
|
let originalUrl = '';
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (shareMediaCategory === 'IMAGE') {
|
|
|
|
if (additionalFields.description) {
|
|
|
|
description = additionalFields.description as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.title) {
|
|
|
|
title = additionalFields.title as string;
|
|
|
|
}
|
|
|
|
// Send a REQUEST to prepare a register of a media image file
|
|
|
|
const registerRequest = {
|
|
|
|
registerUploadRequest: {
|
2022-08-17 08:50:24 -07:00
|
|
|
recipes: ['urn:li:digitalmediaRecipe:feedshare-image'],
|
2021-07-19 23:58:54 -07:00
|
|
|
owner: authorUrn,
|
|
|
|
serviceRelationships: [
|
|
|
|
{
|
|
|
|
relationshipType: 'OWNER',
|
|
|
|
identifier: 'urn:li:userGeneratedContent',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
const registerObject = await linkedInApiRequest.call(
|
|
|
|
this,
|
|
|
|
'POST',
|
|
|
|
'/assets?action=registerUpload',
|
|
|
|
registerRequest,
|
|
|
|
);
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
// Response provides a specific upload URL that is used to upload the binary image file
|
2022-08-17 08:50:24 -07:00
|
|
|
const uploadUrl = registerObject.value.uploadMechanism[
|
|
|
|
'com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest'
|
|
|
|
].uploadUrl as string;
|
2021-07-19 23:58:54 -07:00
|
|
|
const asset = registerObject.value.asset as string;
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
// Prepare binary file upload
|
|
|
|
const item = items[i];
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (item.binary === undefined) {
|
2022-08-17 08:50:24 -07:00
|
|
|
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
|
|
|
itemIndex: i,
|
|
|
|
});
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string;
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (item.binary[propertyNameUpload] === undefined) {
|
2022-08-17 08:50:24 -07:00
|
|
|
throw new NodeOperationError(
|
|
|
|
this.getNode(),
|
|
|
|
`No binary data property "${propertyNameUpload}" does not exists on item!`,
|
|
|
|
{ itemIndex: i },
|
|
|
|
);
|
2021-07-19 23:58:54 -07:00
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
// Buffer binary data
|
2022-01-03 13:42:42 -08:00
|
|
|
const buffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload);
|
2021-07-19 23:58:54 -07:00
|
|
|
// Upload image
|
|
|
|
await linkedInApiRequest.call(this, 'POST', uploadUrl, buffer, true);
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
body = {
|
|
|
|
author: authorUrn,
|
|
|
|
lifecycleState: 'PUBLISHED',
|
|
|
|
specificContent: {
|
|
|
|
'com.linkedin.ugc.ShareContent': {
|
|
|
|
shareCommentary: {
|
|
|
|
text,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
},
|
2021-07-19 23:58:54 -07:00
|
|
|
shareMediaCategory: 'IMAGE',
|
|
|
|
media: [
|
|
|
|
{
|
|
|
|
status: 'READY',
|
|
|
|
description: {
|
|
|
|
text: description,
|
|
|
|
},
|
|
|
|
media: asset,
|
|
|
|
title: {
|
|
|
|
text: title,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
visibility: {
|
|
|
|
'com.linkedin.ugc.MemberNetworkVisibility': visibility,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
},
|
2021-07-19 23:58:54 -07:00
|
|
|
};
|
|
|
|
} else if (shareMediaCategory === 'ARTICLE') {
|
2022-11-18 07:29:44 -08:00
|
|
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (additionalFields.description) {
|
|
|
|
description = additionalFields.description as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.title) {
|
|
|
|
title = additionalFields.title as string;
|
|
|
|
}
|
|
|
|
if (additionalFields.originalUrl) {
|
|
|
|
originalUrl = additionalFields.originalUrl as string;
|
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
body = {
|
|
|
|
author: `${authorUrn}`,
|
|
|
|
lifecycleState: 'PUBLISHED',
|
|
|
|
specificContent: {
|
|
|
|
'com.linkedin.ugc.ShareContent': {
|
|
|
|
shareCommentary: {
|
|
|
|
text,
|
2020-10-22 06:46:03 -07:00
|
|
|
},
|
2021-07-19 23:58:54 -07:00
|
|
|
shareMediaCategory,
|
|
|
|
media: [
|
|
|
|
{
|
|
|
|
status: 'READY',
|
|
|
|
description: {
|
|
|
|
text: description,
|
|
|
|
},
|
|
|
|
originalUrl,
|
|
|
|
title: {
|
|
|
|
text: title,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
visibility: {
|
|
|
|
'com.linkedin.ugc.MemberNetworkVisibility': visibility,
|
2020-10-22 06:46:03 -07:00
|
|
|
},
|
2021-07-19 23:58:54 -07:00
|
|
|
};
|
2022-06-23 14:15:29 -07:00
|
|
|
|
|
|
|
if (description === '') {
|
|
|
|
delete body.specificContent['com.linkedin.ugc.ShareContent'].media[0].description;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (title === '') {
|
|
|
|
delete body.specificContent['com.linkedin.ugc.ShareContent'].media[0].title;
|
|
|
|
}
|
2021-07-19 23:58:54 -07:00
|
|
|
} else {
|
|
|
|
body = {
|
|
|
|
author: authorUrn,
|
|
|
|
lifecycleState: 'PUBLISHED',
|
|
|
|
specificContent: {
|
|
|
|
'com.linkedin.ugc.ShareContent': {
|
|
|
|
shareCommentary: {
|
|
|
|
text,
|
|
|
|
},
|
|
|
|
shareMediaCategory,
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
},
|
|
|
|
},
|
2021-07-19 23:58:54 -07:00
|
|
|
visibility: {
|
|
|
|
'com.linkedin.ugc.MemberNetworkVisibility': visibility,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
const endpoint = '/ugcPosts';
|
|
|
|
responseData = await linkedInApiRequest.call(this, 'POST', endpoint, body);
|
|
|
|
}
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:58:54 -07:00
|
|
|
if (Array.isArray(responseData)) {
|
|
|
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
|
|
|
} else {
|
|
|
|
returnData.push(responseData as IDataObject);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
if (this.continueOnFail()) {
|
|
|
|
returnData.push({ error: error.message });
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
throw error;
|
:sparkles: Add LinkedIn Integration (#942)
* :construction: node logic, request logic, authentication, logo, descriptions
* :construction: Posting image, article and text finished.
* :construction: Posting image, article and text in post finished
* :zap: Post creation (image, articles, text)
* :zap: Added post creation by organization, fixed up descriptions, credentials, indentation
* :zap: Fix issues on LinkedIn-Node
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
2020-09-17 14:32:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [this.helpers.returnJsonArray(returnData)];
|
|
|
|
}
|
|
|
|
}
|