feat: sync stars anyway
This commit is contained in:
parent
3faf34d31c
commit
a99b6c09df
|
|
@ -11,16 +11,20 @@ export const useFormatting = (
|
|||
removeMarkdown?: boolean;
|
||||
saveBreaklines?: boolean;
|
||||
specialFunc?: (text: string) => string;
|
||||
beforeSpecialFunc?: (text: string) => string;
|
||||
}
|
||||
) => {
|
||||
return useMemo(() => {
|
||||
return text.map((value) => {
|
||||
let newText = value.content;
|
||||
if (params.beforeSpecialFunc) {
|
||||
newText = params.beforeSpecialFunc(newText);
|
||||
}
|
||||
if (params.saveBreaklines) {
|
||||
newText = newText.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢');
|
||||
}
|
||||
if (params.removeMarkdown) {
|
||||
newText = removeMd(value.content);
|
||||
newText = removeMd(newText);
|
||||
}
|
||||
if (params.saveBreaklines) {
|
||||
newText = newText.replace('𝔫𝔢𝔴𝔩𝔦𝔫𝔢', '\n');
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { withProvider } from '@gitroom/frontend/components/launches/providers/hi
|
|||
import { useIntegration } from '@gitroom/frontend/components/launches/helpers/use.integration';
|
||||
import { useFormatting } from '@gitroom/frontend/components/launches/helpers/use.formatting';
|
||||
import { useMediaDirectory } from '@gitroom/react/helpers/use.media.directory';
|
||||
import {afterLinkedinCompanyPreventRemove, linkedinCompanyPreventRemove} from "@gitroom/helpers/utils/linkedin.company.prevent.remove";
|
||||
|
||||
const LinkedinPreview: FC = (props) => {
|
||||
const { value: topValue, integration } = useIntegration();
|
||||
|
|
@ -10,8 +11,11 @@ const LinkedinPreview: FC = (props) => {
|
|||
const newValues = useFormatting(topValue, {
|
||||
removeMarkdown: true,
|
||||
saveBreaklines: true,
|
||||
beforeSpecialFunc: (text: string) => {
|
||||
return linkedinCompanyPreventRemove(text);
|
||||
},
|
||||
specialFunc: (text: string) => {
|
||||
return text.slice(0, 280);
|
||||
return afterLinkedinCompanyPreventRemove(text.slice(0, 280));
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -39,9 +43,7 @@ const LinkedinPreview: FC = (props) => {
|
|||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<pre className="font-['helvetica'] text-[14px] font-[400] text-wrap">
|
||||
{firstPost?.text}
|
||||
</pre>
|
||||
<pre className="font-['helvetica'] text-[14px] font-[400] text-wrap" dangerouslySetInnerHTML={{__html: firstPost?.text}} />
|
||||
|
||||
{!!firstPost?.images?.length && (
|
||||
<div className="-ml-[16px] -mr-[40px] flex-1 h-[555px] flex overflow-hidden mt-[12px] gap-[2px]">
|
||||
|
|
|
|||
|
|
@ -43,16 +43,14 @@ export class StarsController {
|
|||
}
|
||||
|
||||
// if there is stars in the database, sync the new stars
|
||||
if (totalNewsStars > 0) {
|
||||
return this._starsService.createStars(
|
||||
data.login,
|
||||
totalNewsStars,
|
||||
totalStars,
|
||||
totalNewsForks,
|
||||
totalForks,
|
||||
new Date()
|
||||
);
|
||||
}
|
||||
return this._starsService.createStars(
|
||||
data.login,
|
||||
totalNewsStars,
|
||||
totalStars,
|
||||
totalNewsForks,
|
||||
totalForks,
|
||||
new Date()
|
||||
);
|
||||
}
|
||||
|
||||
@EventPattern('sync_all_stars', Transport.REDIS, { concurrency: 1 })
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
export const linkedinCompanyPreventRemove = (text: string) => {
|
||||
const regex = /@\[(.*?)]\(urn:li:organization:(\d+)\)/g;
|
||||
|
||||
return text.replace(regex, `[bold]@$1[/bold]`);
|
||||
}
|
||||
|
||||
export const afterLinkedinCompanyPreventRemove = (text: string) => {
|
||||
const regex = /\[bold]@([^[]+)\[\/bold]/g;
|
||||
return text.replace(regex, "<strong>@$1</strong>");
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ export class StarsRepository {
|
|||
}
|
||||
|
||||
async getStarsByLogin(login: string) {
|
||||
return await this._stars.model.star.findMany({
|
||||
return this._stars.model.star.findMany({
|
||||
where: {
|
||||
login,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,7 +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";
|
||||
import removeMd from 'remove-markdown';
|
||||
|
||||
export class LinkedinProvider implements SocialProvider {
|
||||
identifier = 'linkedin';
|
||||
|
|
@ -203,7 +203,9 @@ export class LinkedinProvider implements SocialProvider {
|
|||
},
|
||||
body: JSON.stringify({
|
||||
author: `urn:li:person:${id}`,
|
||||
commentary: removeMd(firstPost.message.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace('𝔫𝔢𝔴𝔩𝔦𝔫𝔢', '\n'),
|
||||
commentary: removeMd(
|
||||
firstPost.message.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')
|
||||
).replace('𝔫𝔢𝔴𝔩𝔦𝔫𝔢', '\n'),
|
||||
visibility: 'PUBLIC',
|
||||
distribution: {
|
||||
feedDistribution: 'MAIN_FEED',
|
||||
|
|
@ -261,7 +263,10 @@ export class LinkedinProvider implements SocialProvider {
|
|||
actor: `urn:li:person:${id}`,
|
||||
object: topPostId,
|
||||
message: {
|
||||
text: removeMd(post.message.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace('𝔫𝔢𝔴𝔩𝔦𝔫𝔢', '\n'),
|
||||
text: removeMd(post.message.replace('\n', '𝔫𝔢𝔴𝔩𝔦𝔫𝔢')).replace(
|
||||
'𝔫𝔢𝔴𝔩𝔦𝔫𝔢',
|
||||
'\n'
|
||||
),
|
||||
},
|
||||
}),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue