Skip to content

Commit

Permalink
[ext-256] migrate linkedin logic from helper (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannylwe committed Dec 13, 2024
1 parent a43ecff commit 14b3ef2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
4 changes: 2 additions & 2 deletions integrations/google-drive/syncs/documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
- **Description:** Sync the metadata of a specified file or folders from Google Drive,
handling both individual files and nested folders.
Metadata required to filter on a particular folder, or file(s). Metadata
fields should be {"files": ["<some-id>"]} OR
{"folders": ["<some-id>"]}. The ID should be able to be provided
fields should be `{"files": ["<some-id>"]}` OR
`{"folders": ["<some-id>"]}`. The ID should be able to be provided
by using the Google Picker API
(https://developers.google.com/drive/picker/guides/overview)
and using the ID field provided by the response
Expand Down
49 changes: 45 additions & 4 deletions integrations/linkedin/actions/post.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CreateLinkedInPostWithVideoResponse, NangoAction, LinkedinVideoPost } from '../../models';
import { createPostWithVideo } from '../helpers/post-video.js';
import type { CreateLinkedInPostWithVideoResponse, LinkedinVideoPost, NangoAction, ProxyConfiguration } from '../../models';
import { userInfo } from '../helpers/user-info.js';
import type { LinkedinCreatePost } from '../types';

export default async function runAction(nango: NangoAction, input: LinkedinVideoPost): Promise<CreateLinkedInPostWithVideoResponse> {
const videoURN = input?.videoURN;
Expand All @@ -17,7 +17,48 @@ export default async function runAction(nango: NangoAction, input: LinkedinVideo
});
}

const resp = await createPostWithVideo(nango, ownerId, input.text, input.videoTitle, videoURN);
const postData: LinkedinCreatePost = {
author: `urn:li:person:${ownerId}`,
commentary: input.postText,
visibility: 'PUBLIC',
distribution: {
feedDistribution: 'MAIN_FEED',
targetEntities: [],
thirdPartyDistributionChannels: []
},
lifecycleState: 'PUBLISHED',
isReshareDisabledByAuthor: false
};

return resp;
if (videoURN) {
postData.content = {
media: {
title: input.videoTitle,
// video that is already uploaded to linkedin api. this id can be video, image or document urn.
id: videoURN
}
};
}

const config: ProxyConfiguration = {
// https://learn.microsoft.com/en-us/linkedin/marketing/community-management/shares/posts-api?view=li-lms-2024-10&tabs=http
endpoint: `/rest/posts`,
retries: 10,
data: postData,
headers: {
'LinkedIn-Version': '202405'
}
};

const response = await nango.post(config);

if (response.status !== 200) {
throw new nango.ActionError({
message: `failed to create post with video urn ${videoURN}`
});
}

return {
succcess: response.status == 200 ? true : false
};
}

0 comments on commit 14b3ef2

Please sign in to comment.