feat(LinkedIn Node): Add support for Article thumbnails (#7489)

Github issue / Community forum post (link here to close automatically):
https://community.n8n.io/t/linkedin-post-not-showing-image-for-url/10789/


![image](https://github.com/n8n-io/n8n/assets/4688521/5142b984-f531-4731-8510-c7136087861e)

This adds a new property to add a thumbnail binary property for articles
this fixes the previews no longer working because of the LinkedIn API
change.

![image](https://github.com/n8n-io/n8n/assets/4688521/76271525-5791-4bdc-ae73-1fdbb3986694)
This commit is contained in:
Jon 2023-11-03 09:50:28 +00:00 committed by GitHub
parent 9c55702661
commit e6d3d1a4c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View file

@ -167,6 +167,30 @@ export class LinkedIn implements INodeType {
},
commentary: text,
};
if (additionalFields.thumbnailBinaryPropertyName) {
const registerRequest = {
initializeUploadRequest: {
owner: authorUrn,
},
};
const registerObject = await linkedInApiRequest.call(
this,
'POST',
'/images?action=initializeUpload',
registerRequest,
);
const binaryPropertyName = additionalFields.thumbnailBinaryPropertyName as string;
this.helpers.assertBinaryData(i, binaryPropertyName);
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
const { uploadUrl, image } = registerObject.value;
await linkedInApiRequest.call(this, 'POST', uploadUrl as string, buffer, true);
Object.assign(articleBody.content.article, { thumbnail: image });
}
Object.assign(body, articleBody);
if (description === '') {
delete body.description;

View file

@ -172,6 +172,18 @@ export const postFields: INodeProperties[] = [
},
},
},
{
displayName: 'Thumbnail Binary Property',
name: 'thumbnailBinaryPropertyName',
type: 'string',
default: 'data',
description: 'Object property name which holds binary data for the article thumbnail',
displayOptions: {
show: {
'/shareMediaCategory': ['ARTICLE'],
},
},
},
{
displayName: 'Title',
name: 'title',