feat: add comment from another user

This commit is contained in:
Nevo David 2026-01-09 15:04:16 +07:00
parent 631d7c15e8
commit 46b1263304
4 changed files with 111 additions and 20 deletions

View File

@ -7,6 +7,8 @@ import { PickPlatforms } from '@gitroom/frontend/components/launches/helpers/pic
import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration';
import { Select } from '@gitroom/react/form/select';
import { Slider } from '@gitroom/react/form/slider';
import { Input } from '@gitroom/react/form/input';
import { Textarea } from '@gitroom/react/form/textarea';
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
import clsx from 'clsx';
import { useT } from '@gitroom/react/translation/get.transation.service.client';
@ -68,6 +70,37 @@ export const InternalChannels: FC<{
</div>
);
};
const PlugField: FC<{
plugIdentifier: string;
field: {
name: string;
description: string;
type: string;
placeholder: string;
validation?: RegExp;
};
}> = ({ plugIdentifier, field }) => {
const fieldName = `plug--${plugIdentifier}--${field.name}`;
if (field.type === 'textarea') {
return (
<Textarea
label={field.description}
name={fieldName}
placeholder={field.placeholder}
/>
);
}
return (
<Input
label={field.description}
name={fieldName}
placeholder={field.placeholder}
/>
);
};
const Plug: FC<{
plug: {
identifier: string;
@ -151,6 +184,17 @@ const Plug: FC<{
</option>
))}
</Select>
{plug.fields.length > 0 && (
<div className="flex flex-col gap-[10px]">
{plug.fields.map((field) => (
<PlugField
key={field.name}
plugIdentifier={plug.identifier}
field={field}
/>
))}
</div>
)}
<div>
{t('accounts_that_will_engage', 'Accounts that will engage:')}
</div>

View File

@ -5,6 +5,8 @@ dayjs.extend(utc);
import { NestFactory } from '@nestjs/core';
import { AppModule } from '@gitroom/orchestrator/app.module';
import * as dns from 'node:dns';
dns.setDefaultResultOrder('ipv4first');
async function bootstrap() {
// some comment again

View File

@ -90,6 +90,21 @@ export class LinkedinPageProvider
};
}
override async addComment(
integration: Integration,
originalIntegration: Integration,
postId: string,
information: any,
) {
return super.addComment(
integration,
originalIntegration,
postId,
information,
false
);
}
override async repostPostUsers(
integration: Integration,
originalIntegration: Integration,
@ -293,7 +308,7 @@ export class LinkedinPageProvider
{
headers: {
Authorization: `Bearer ${accessToken}`,
'Linkedin-Version': '202405',
'Linkedin-Version': '202511',
'X-Restli-Protocol-Version': '2.0.0',
},
}
@ -308,7 +323,7 @@ export class LinkedinPageProvider
{
headers: {
Authorization: `Bearer ${accessToken}`,
'Linkedin-Version': '202405',
'Linkedin-Version': '202511',
'X-Restli-Protocol-Version': '2.0.0',
},
}
@ -323,7 +338,7 @@ export class LinkedinPageProvider
{
headers: {
Authorization: `Bearer ${accessToken}`,
'Linkedin-Version': '202405',
'Linkedin-Version': '202511',
'X-Restli-Protocol-Version': '2.0.0',
},
}

View File

@ -188,7 +188,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
headers: {
'Content-Type': 'application/json',
'X-Restli-Protocol-Version': '2.0.0',
'LinkedIn-Version': '202501',
'LinkedIn-Version': '202511',
Authorization: `Bearer ${token}`,
},
}
@ -233,7 +233,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
headers: {
'Content-Type': 'application/json',
'X-Restli-Protocol-Version': '2.0.0',
'LinkedIn-Version': '202501',
'LinkedIn-Version': '202511',
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
@ -266,7 +266,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
method: 'PUT',
headers: {
'X-Restli-Protocol-Version': '2.0.0',
'LinkedIn-Version': '202501',
'LinkedIn-Version': '202511',
Authorization: `Bearer ${accessToken}`,
...(isVideo
? { 'Content-Type': 'application/octet-stream' }
@ -298,7 +298,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
}),
headers: {
'X-Restli-Protocol-Version': '2.0.0',
'LinkedIn-Version': '202501',
'LinkedIn-Version': '202511',
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
@ -554,21 +554,10 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
isPdf
);
console.log({
const response = await this.fetch(`https://api.linkedin.com/rest/posts`, {
method: 'POST',
headers: {
'LinkedIn-Version': '202501',
'X-Restli-Protocol-Version': '2.0.0',
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify(postPayload),
});
const response = await this.fetch('https://api.linkedin.com/rest/posts', {
method: 'POST',
headers: {
'LinkedIn-Version': '202501',
'LinkedIn-Version': '202511',
'X-Restli-Protocol-Version': '2.0.0',
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
@ -703,6 +692,47 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
return [this.createPostResponse(commentPostId, commentPost.id, false)];
}
@PostPlug({
identifier: 'linkedin-add-comment',
title: 'Add comments by a different account',
description: 'Add accounts to comment on your post',
pickIntegration: ['linkedin', 'linkedin-page'],
fields: [
{
name: 'comment',
description: 'The comment to add to the post',
type: 'textarea',
placeholder: 'Enter your comment here',
},
],
})
async addComment(
integration: Integration,
originalIntegration: Integration,
postId: string,
information: any,
isPersonal = true
) {
return this.comment(
integration.internalId,
postId,
undefined,
integration.token,
[
{
id: makeId(10),
message: information.comment,
media: [],
settings: {
post_as_images_carousel: false,
},
},
],
integration,
isPersonal ? 'personal' : 'company'
);
}
@PostPlug({
identifier: 'linkedin-repost-post-users',
title: 'Add Re-posters',