feat: linkedin repost
This commit is contained in:
parent
c23061d793
commit
16e41794aa
|
|
@ -83,6 +83,15 @@ export class LinkedinPageProvider
|
|||
};
|
||||
}
|
||||
|
||||
override async repostPostUsers(
|
||||
integration: Integration,
|
||||
originalIntegration: Integration,
|
||||
postId: string,
|
||||
information: any
|
||||
) {
|
||||
return super.repostPostUsers(integration, originalIntegration, postId, information, false);
|
||||
}
|
||||
|
||||
override async generateAuthUrl() {
|
||||
const state = makeId(6);
|
||||
const codeVerifier = makeId(30);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,10 @@ import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
|
|||
import sharp from 'sharp';
|
||||
import { lookup } from 'mime-types';
|
||||
import { readOrFetch } from '@gitroom/helpers/utils/read.or.fetch';
|
||||
import { removeMarkdown } from '@gitroom/helpers/utils/remove.markdown';
|
||||
import {
|
||||
BadBody,
|
||||
SocialAbstract,
|
||||
} from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract';
|
||||
import { Integration } from '@prisma/client';
|
||||
import { PostPlug } from '@gitroom/helpers/decorators/post.plug';
|
||||
|
||||
export class LinkedinProvider extends SocialAbstract implements SocialProvider {
|
||||
identifier = 'linkedin';
|
||||
name = 'LinkedIn';
|
||||
|
|
@ -458,4 +456,50 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
|
|||
|
||||
return ids;
|
||||
}
|
||||
|
||||
@PostPlug({
|
||||
identifier: 'linkedin-repost-post-users',
|
||||
title: 'Add Re-posters',
|
||||
description: 'Add accounts to repost your post',
|
||||
pickIntegration: ['linkedin', 'linkedin-page'],
|
||||
fields: [],
|
||||
})
|
||||
async repostPostUsers(
|
||||
integration: Integration,
|
||||
originalIntegration: Integration,
|
||||
postId: string,
|
||||
information: any,
|
||||
isPersonal = true
|
||||
) {
|
||||
try {
|
||||
await this.fetch(`https://api.linkedin.com/rest/posts`, {
|
||||
body: JSON.stringify({
|
||||
author:
|
||||
(isPersonal ? 'urn:li:person:' : `urn:li:organization:`) +
|
||||
`${integration.internalId}`,
|
||||
commentary: '',
|
||||
visibility: 'PUBLIC',
|
||||
distribution: {
|
||||
feedDistribution: 'MAIN_FEED',
|
||||
targetEntities: [],
|
||||
thirdPartyDistributionChannels: [],
|
||||
},
|
||||
lifecycleState: 'PUBLISHED',
|
||||
isReshareDisabledByAuthor: false,
|
||||
reshareContext: {
|
||||
parent: postId,
|
||||
},
|
||||
}),
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-Restli-Protocol-Version': '2.0.0',
|
||||
'Content-Type': 'application/json',
|
||||
'LinkedIn-Version': '202402',
|
||||
Authorization: `Bearer ${integration.token}`,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ export class XProvider extends SocialAbstract implements SocialProvider {
|
|||
try {
|
||||
await client.v2.retweet(id, postId);
|
||||
} catch (err) {
|
||||
/** nothing **/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue