feat: small fixes

This commit is contained in:
Nevo David 2024-03-14 18:45:36 +07:00
parent 9f199c06f1
commit 3faf34d31c
4 changed files with 33 additions and 27 deletions

View File

@ -32,6 +32,7 @@ const RenderRedditComponent: FC<{
<MDEditor.Markdown
style={{ whiteSpace: 'pre-wrap', fontSize: '14px' }}
skipHtml={true}
disallowedElements={['img']}
source={firstPost?.content}
/>
);
@ -130,10 +131,8 @@ const RedditPreview: FC = (props) => {
style={{ whiteSpace: 'pre-wrap' }}
skipHtml={true}
source={p.text}
disallowedElements={['img']}
/>
<pre className="font-['Inter'] text-[14px] mt-[8px] font-[400] text-white">
{p.text}
</pre>
</div>
</div>
))}

View File

@ -7,6 +7,7 @@ import { IntegrationManager } from '@gitroom/nestjs-libraries/integrations/integ
import { Integration, Post, Media } from '@prisma/client';
import { GetPostsDto } from '@gitroom/nestjs-libraries/dtos/posts/get.posts.dto';
import { NotificationService } from '@gitroom/nestjs-libraries/database/prisma/notifications/notification.service';
import {capitalize} from "lodash";
type PostWithConditionals = Post & {
integration?: Integration;
@ -161,8 +162,8 @@ export class PostsService {
await this._notificationService.inAppNotification(
integration.organizationId,
`Your social media post on ${integration.providerIdentifier} has been posted`,
`Your article has been posted at ${publishedPosts[0].releaseURL}`,
`Your post has been published on ${capitalize(integration.providerIdentifier)}`,
`Your post has been published at ${publishedPosts[0].releaseURL}`,
true
);
}
@ -185,8 +186,8 @@ export class PostsService {
await this._notificationService.inAppNotification(
integration.organizationId,
`Your article on ${integration.providerIdentifier} has been posted`,
`Your article has been posted at ${releaseURL}`,
`Your article has been published on ${capitalize(integration.providerIdentifier)}`,
`Your article has been published at ${releaseURL}`,
true
);
await this._postRepository.updatePost(newPosts[0].id, postId, releaseURL);

View File

@ -8,6 +8,7 @@ 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 removeMd from "remove-markdown";
export class LinkedinProvider implements SocialProvider {
identifier = 'linkedin';
@ -202,30 +203,34 @@ export class LinkedinProvider implements SocialProvider {
},
body: JSON.stringify({
author: `urn:li:person:${id}`,
commentary: firstPost.message,
commentary: removeMd(firstPost.message.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace('𝔫𝔢𝔴𝔩𝔦𝔫𝔢', '\n'),
visibility: 'PUBLIC',
distribution: {
feedDistribution: 'MAIN_FEED',
targetEntities: [],
thirdPartyDistributionChannels: [],
},
content: {
...(media_ids.length === 0
? {}
: media_ids.length === 1
? {
media: {
id: media_ids[0],
},
}
: {
multiImage: {
images: media_ids.map((id) => ({
id,
})),
},
}),
},
...(media_ids.length > 0
? {
content: {
...(media_ids.length === 0
? {}
: media_ids.length === 1
? {
media: {
id: media_ids[0],
},
}
: {
multiImage: {
images: media_ids.map((id) => ({
id,
})),
},
}),
},
}
: {}),
lifecycleState: 'PUBLISHED',
isReshareDisabledByAuthor: false,
}),
@ -256,7 +261,7 @@ export class LinkedinProvider implements SocialProvider {
actor: `urn:li:person:${id}`,
object: topPostId,
message: {
text: post.message,
text: removeMd(post.message.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace('𝔫𝔢𝔴𝔩𝔦𝔫𝔢', '\n'),
},
}),
}

View File

@ -8,6 +8,7 @@ import {
import { lookup } from 'mime-types';
import sharp from 'sharp';
import { readOrFetch } from '@gitroom/helpers/utils/read.or.fetch';
import removeMd from "remove-markdown";
export class XProvider implements SocialProvider {
identifier = 'x';
@ -145,7 +146,7 @@ export class XProvider implements SocialProvider {
const media_ids = (uploadAll[post.id] || []).filter((f) => f);
const { data }: { data: { id: string } } = await client.v2.tweet({
text: post.message,
text: removeMd(post.message.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace('𝔫𝔢𝔴𝔩𝔦𝔫𝔢', '\n'),
...(media_ids.length ? { media: { media_ids } } : {}),
...(ids.length
? { reply: { in_reply_to_tweet_id: ids[ids.length - 1].postId } }