From 58abf6eb00f861314476e654ab1f8bc5d4a3d748 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Fri, 1 Aug 2025 13:45:52 +0700 Subject: [PATCH] feat: mentions --- .../src/api/routes/integrations.controller.ts | 4 +-- .../integrations/integration.repository.ts | 3 ++ .../integrations/social/threads.provider.ts | 30 +++++++++++++++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/apps/backend/src/api/routes/integrations.controller.ts b/apps/backend/src/api/routes/integrations.controller.ts index d658fa6e..5393f385 100644 --- a/apps/backend/src/api/routes/integrations.controller.ts +++ b/apps/backend/src/api/routes/integrations.controller.ts @@ -278,7 +278,7 @@ export class IntegrationsController { name: p.label, username: p.id, image: p.image, - })) + })).filter((f: any) => f.name) ); } @@ -292,7 +292,7 @@ export class IntegrationsController { ...newList, ], (p) => p.id - ); + ).filter(f => f.label && f.image && f.id); } @Post('/function') diff --git a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts index b432f246..ae576223 100644 --- a/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts +++ b/libraries/nestjs-libraries/src/database/prisma/integrations/integration.repository.ts @@ -54,6 +54,9 @@ export class IntegrationRepository { platform: string, mentions: { name: string; username: string; image: string }[] ) { + if (mentions.length === 0) { + return []; + } return this._mentions.model.mentions.createMany({ data: mentions.map((mention) => ({ platform, diff --git a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts index 37ed96fa..6ae04186 100644 --- a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts @@ -13,6 +13,7 @@ import { capitalize, chunk } from 'lodash'; import { Plug } from '@gitroom/helpers/decorators/plug.decorator'; import { Integration } from '@prisma/client'; import { stripHtmlValidation } from '@gitroom/helpers/utils/strip.html.validation'; +import { TwitterApi } from 'twitter-api-v2'; export class ThreadsProvider extends SocialAbstract implements SocialProvider { identifier = 'threads'; @@ -23,6 +24,7 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider { 'threads_content_publish', 'threads_manage_replies', 'threads_manage_insights', + // 'threads_profile_discovery', ]; editor = 'normal' as const; @@ -413,8 +415,7 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider { { id: makeId(10), media: [], - message: - postDetails?.[0]?.settings?.thread_finisher, + message: postDetails?.[0]?.settings?.thread_finisher, settings: {}, }, lastReplyId, @@ -526,4 +527,29 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider { return false; } + + // override async mention( + // token: string, + // data: { query: string }, + // id: string, + // integration: Integration + // ) { + // const p = await ( + // await fetch( + // `https://graph.threads.net/v1.0/profile_lookup?username=${data.query}&access_token=${integration.token}` + // ) + // ).json(); + // + // return [ + // { + // id: String(p.id), + // label: p.name, + // image: p.profile_picture_url, + // }, + // ]; + // } + // + // mentionFormat(idOrHandle: string, name: string) { + // return `@${idOrHandle}`; + // } }