mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
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:
parent
9c55702661
commit
e6d3d1a4c2
|
@ -167,6 +167,30 @@ export class LinkedIn implements INodeType {
|
||||||
},
|
},
|
||||||
commentary: text,
|
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);
|
Object.assign(body, articleBody);
|
||||||
if (description === '') {
|
if (description === '') {
|
||||||
delete body.description;
|
delete body.description;
|
||||||
|
|
|
@ -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',
|
displayName: 'Title',
|
||||||
name: 'title',
|
name: 'title',
|
||||||
|
|
Loading…
Reference in a new issue