File tree Expand file tree Collapse file tree 5 files changed +25
-1
lines changed
apps/frontend/src/components/launches/providers/x
libraries/nestjs-libraries/src Expand file tree Collapse file tree 5 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { ThreadFinisher } from '@gitroom/frontend/components/launches/finisher/t
33import { Select } from '@gitroom/react/form/select' ;
44import { useT } from '@gitroom/react/translation/get.transation.service.client' ;
55import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values' ;
6+ import { XDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/x.dto' ;
7+ import { Input } from '@gitroom/react/form/input' ;
68
79const whoCanReply = [
810 {
@@ -48,6 +50,8 @@ const SettingsComponent = () => {
4850 ) ) }
4951 </ Select >
5052
53+ < Input label = { 'Post to a community, URL (Ex: https://x.com/i/communities/1493446837214187523)' } { ...register ( 'community' ) } />
54+
5155 < ThreadFinisher />
5256 </ >
5357 ) ;
@@ -56,7 +60,7 @@ const SettingsComponent = () => {
5660export default withProvider (
5761 SettingsComponent ,
5862 undefined ,
59- undefined ,
63+ XDto ,
6064 async ( posts ) => {
6165 if ( posts . some ( ( p ) => p . length > 4 ) ) {
6266 return 'There can be maximum 4 pictures in a post.' ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import { TikTokDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settin
2626import { DiscordDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/discord.dto' ;
2727import { SlackDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/slack.dto' ;
2828import { LemmySettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/lemmy.dto' ;
29+ import { XDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/x.dto' ;
2930
3031export class EmptySettings { }
3132export class Integration {
@@ -85,6 +86,7 @@ export class Post {
8586 { value : TikTokDto , name : 'tiktok' } ,
8687 { value : DiscordDto , name : 'discord' } ,
8788 { value : SlackDto , name : 'slack' } ,
89+ { value : XDto , name : 'x' } ,
8890 ] ,
8991 } ,
9092 } )
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { RedditSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/provider
55import { PinterestSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/pinterest.dto' ;
66import { YoutubeSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/youtube.settings.dto' ;
77import { TikTokDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/tiktok.dto' ;
8+ import { XDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/x.dto' ;
89
910export type AllProvidersSettings =
1011 | DevToSettingsDto
@@ -13,4 +14,5 @@ export type AllProvidersSettings =
1314 | RedditSettingsDto
1415 | YoutubeSettingsDto
1516 | PinterestSettingsDto
17+ | XDto
1618 | TikTokDto ;
Original file line number Diff line number Diff line change 1+ import { IsOptional , Matches } from 'class-validator' ;
2+
3+ export class XDto {
4+ @IsOptional ( )
5+ @Matches ( / ^ ( h t t p s : \/ \/ x \. c o m \/ i \/ c o m m u n i t i e s \/ \d + ) ? $ / , {
6+ message : 'Invalid X community URL. It should be in the format: https://x.com/i/communities/1493446837214187523' ,
7+ } )
8+ community : string ;
9+ }
Original file line number Diff line number Diff line change @@ -241,6 +241,7 @@ export class XProvider extends SocialAbstract implements SocialProvider {
241241 postDetails : PostDetails < {
242242 active_thread_finisher : boolean ;
243243 thread_finisher : string ;
244+ community ?: string ;
244245 who_can_reply_post :
245246 | 'everyone'
246247 | 'following'
@@ -311,6 +312,12 @@ export class XProvider extends SocialAbstract implements SocialProvider {
311312 : {
312313 reply_settings : postDetails ?. [ 0 ] ?. settings ?. who_can_reply_post ,
313314 } ) ,
315+ ...( postDetails ?. [ 0 ] ?. settings ?. community
316+ ? {
317+ community_id :
318+ postDetails ?. [ 0 ] ?. settings ?. community ?. split ( '/' ) . pop ( ) || '' ,
319+ }
320+ : { } ) ,
314321 text : post . message ,
315322 ...( media_ids . length ? { media : { media_ids } } : { } ) ,
316323 ...( ids . length
You can’t perform that action at this time.
0 commit comments