diff --git a/apps/frontend/src/components/launches/helpers/use.formatting.ts b/apps/frontend/src/components/launches/helpers/use.formatting.ts
index 5f2cc553..549d547d 100644
--- a/apps/frontend/src/components/launches/helpers/use.formatting.ts
+++ b/apps/frontend/src/components/launches/helpers/use.formatting.ts
@@ -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');
diff --git a/apps/frontend/src/components/launches/providers/linkedin/linkedin.provider.tsx b/apps/frontend/src/components/launches/providers/linkedin/linkedin.provider.tsx
index cd40533f..a1e9c079 100644
--- a/apps/frontend/src/components/launches/providers/linkedin/linkedin.provider.tsx
+++ b/apps/frontend/src/components/launches/providers/linkedin/linkedin.provider.tsx
@@ -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) => {
-
- {firstPost?.text}
-
+
{!!firstPost?.images?.length && (
diff --git a/apps/workers/src/app/stars.controller.ts b/apps/workers/src/app/stars.controller.ts
index 9deaa261..d70c7d8a 100644
--- a/apps/workers/src/app/stars.controller.ts
+++ b/apps/workers/src/app/stars.controller.ts
@@ -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 })
diff --git a/libraries/helpers/src/utils/linkedin.company.prevent.remove.ts b/libraries/helpers/src/utils/linkedin.company.prevent.remove.ts
new file mode 100644
index 00000000..55ac62ae
--- /dev/null
+++ b/libraries/helpers/src/utils/linkedin.company.prevent.remove.ts
@@ -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, "@$1");
+}
\ No newline at end of file
diff --git a/libraries/nestjs-libraries/src/database/prisma/stars/stars.repository.ts b/libraries/nestjs-libraries/src/database/prisma/stars/stars.repository.ts
index 99f54732..305beac8 100644
--- a/libraries/nestjs-libraries/src/database/prisma/stars/stars.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/stars/stars.repository.ts
@@ -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,
},
diff --git a/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts b/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
index a3a939a2..e43179bc 100644
--- a/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
@@ -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'
+ ),
},
}),
}