Skip to content

Commit

Permalink
fix(LinkedIn Node): Fix LinkedIn image preview (#3528)
Browse files Browse the repository at this point in the history
* Fixed issue with Preview not being generated when description and title is blank

* Nodelinter fixes

* Fixed lint issue... build should work

Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
  • Loading branch information
Joffcom and janober authored Jun 23, 2022
1 parent 3ee384f commit 32f245d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export class LinkedIn implements INodeType {
description: INodeTypeDescription = {
displayName: 'LinkedIn',
name: 'linkedIn',
// eslint-disable-next-line n8n-nodes-base/node-class-description-icon-not-svg
icon: 'file:linkedin.png',
icon: 'file:linkedin.svg',
group: ['input'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume LinkedIn API',
defaults: {
name: 'LinkedIn',
Expand Down Expand Up @@ -76,7 +76,8 @@ export class LinkedIn implements INodeType {
let responseData;
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
let body = {};

let body:any = {};// tslint:disable-line:no-any

for (let i = 0; i < items.length; i++) {
try {
Expand Down Expand Up @@ -220,6 +221,15 @@ export class LinkedIn implements INodeType {
'com.linkedin.ugc.MemberNetworkVisibility': visibility,
},
};

if (description === '') {
delete body.specificContent['com.linkedin.ugc.ShareContent'].media[0].description;
}

if (title === '') {
delete body.specificContent['com.linkedin.ugc.ShareContent'].media[0].title;
}

} else {
body = {
author: authorUrn,
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/LinkedIn/PostDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const postFields: INodeProperties[] = [
displayName: 'Post As',
name: 'postAs',
type: 'options',
default: '',
default: 'person',
description: 'If to post on behalf of a user or an organization',
options: [
{
Expand Down
Binary file removed packages/nodes-base/nodes/LinkedIn/linkedin.png
Binary file not shown.
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/LinkedIn/linkedin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 32f245d

Please sign in to comment.