@@ -8,12 +8,10 @@ import { makeId } from '@gitroom/nestjs-libraries/services/make.is';
88import sharp from 'sharp' ;
99import { lookup } from 'mime-types' ;
1010import { readOrFetch } from '@gitroom/helpers/utils/read.or.fetch' ;
11- import { removeMarkdown } from '@gitroom/helpers/utils/remove.markdown' ;
12- import {
13- BadBody ,
14- SocialAbstract ,
15- } from '@gitroom/nestjs-libraries/integrations/social.abstract' ;
11+ import { SocialAbstract } from '@gitroom/nestjs-libraries/integrations/social.abstract' ;
1612import { Integration } from '@prisma/client' ;
13+ import { PostPlug } from '@gitroom/helpers/decorators/post.plug' ;
14+
1715export class LinkedinProvider extends SocialAbstract implements SocialProvider {
1816 identifier = 'linkedin' ;
1917 name = 'LinkedIn' ;
@@ -458,4 +456,50 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
458456
459457 return ids ;
460458 }
459+
460+ @PostPlug ( {
461+ identifier : 'linkedin-repost-post-users' ,
462+ title : 'Add Re-posters' ,
463+ description : 'Add accounts to repost your post' ,
464+ pickIntegration : [ 'linkedin' , 'linkedin-page' ] ,
465+ fields : [ ] ,
466+ } )
467+ async repostPostUsers (
468+ integration : Integration ,
469+ originalIntegration : Integration ,
470+ postId : string ,
471+ information : any ,
472+ isPersonal = true
473+ ) {
474+ try {
475+ await this . fetch ( `https://api.linkedin.com/rest/posts` , {
476+ body : JSON . stringify ( {
477+ author :
478+ ( isPersonal ? 'urn:li:person:' : `urn:li:organization:` ) +
479+ `${ integration . internalId } ` ,
480+ commentary : '' ,
481+ visibility : 'PUBLIC' ,
482+ distribution : {
483+ feedDistribution : 'MAIN_FEED' ,
484+ targetEntities : [ ] ,
485+ thirdPartyDistributionChannels : [ ] ,
486+ } ,
487+ lifecycleState : 'PUBLISHED' ,
488+ isReshareDisabledByAuthor : false ,
489+ reshareContext : {
490+ parent : postId ,
491+ } ,
492+ } ) ,
493+ method : 'POST' ,
494+ headers : {
495+ 'X-Restli-Protocol-Version' : '2.0.0' ,
496+ 'Content-Type' : 'application/json' ,
497+ 'LinkedIn-Version' : '202402' ,
498+ Authorization : `Bearer ${ integration . token } ` ,
499+ } ,
500+ } ) ;
501+ } catch ( err ) {
502+ return ;
503+ }
504+ }
461505}
0 commit comments