feat: post to a community
This commit is contained in:
parent
438f7b27cb
commit
ce60edb053
|
|
@ -3,6 +3,8 @@ import { ThreadFinisher } from '@gitroom/frontend/components/launches/finisher/t
|
|||
import { Select } from '@gitroom/react/form/select';
|
||||
import { useT } from '@gitroom/react/translation/get.transation.service.client';
|
||||
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
|
||||
import { XDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/x.dto';
|
||||
import { Input } from '@gitroom/react/form/input';
|
||||
|
||||
const whoCanReply = [
|
||||
{
|
||||
|
|
@ -48,6 +50,8 @@ const SettingsComponent = () => {
|
|||
))}
|
||||
</Select>
|
||||
|
||||
<Input label={'Post to a community, URL (Ex: https://x.com/i/communities/1493446837214187523)'} {...register('community')} />
|
||||
|
||||
<ThreadFinisher />
|
||||
</>
|
||||
);
|
||||
|
|
@ -56,7 +60,7 @@ const SettingsComponent = () => {
|
|||
export default withProvider(
|
||||
SettingsComponent,
|
||||
undefined,
|
||||
undefined,
|
||||
XDto,
|
||||
async (posts) => {
|
||||
if (posts.some((p) => p.length > 4)) {
|
||||
return 'There can be maximum 4 pictures in a post.';
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import { TikTokDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settin
|
|||
import { DiscordDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/discord.dto';
|
||||
import { SlackDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/slack.dto';
|
||||
import { LemmySettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/lemmy.dto';
|
||||
import { XDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/x.dto';
|
||||
|
||||
export class EmptySettings {}
|
||||
export class Integration {
|
||||
|
|
@ -85,6 +86,7 @@ export class Post {
|
|||
{ value: TikTokDto, name: 'tiktok' },
|
||||
{ value: DiscordDto, name: 'discord' },
|
||||
{ value: SlackDto, name: 'slack' },
|
||||
{ value: XDto, name: 'x' },
|
||||
],
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { RedditSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/provider
|
|||
import { PinterestSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/pinterest.dto';
|
||||
import { YoutubeSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/youtube.settings.dto';
|
||||
import { TikTokDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/tiktok.dto';
|
||||
import { XDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/x.dto';
|
||||
|
||||
export type AllProvidersSettings =
|
||||
| DevToSettingsDto
|
||||
|
|
@ -13,4 +14,5 @@ export type AllProvidersSettings =
|
|||
| RedditSettingsDto
|
||||
| YoutubeSettingsDto
|
||||
| PinterestSettingsDto
|
||||
| XDto
|
||||
| TikTokDto;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
import { IsOptional, Matches } from 'class-validator';
|
||||
|
||||
export class XDto {
|
||||
@IsOptional()
|
||||
@Matches(/^(https:\/\/x\.com\/i\/communities\/\d+)?$/, {
|
||||
message: 'Invalid X community URL. It should be in the format: https://x.com/i/communities/1493446837214187523',
|
||||
})
|
||||
community: string;
|
||||
}
|
||||
|
|
@ -241,6 +241,7 @@ export class XProvider extends SocialAbstract implements SocialProvider {
|
|||
postDetails: PostDetails<{
|
||||
active_thread_finisher: boolean;
|
||||
thread_finisher: string;
|
||||
community?: string;
|
||||
who_can_reply_post:
|
||||
| 'everyone'
|
||||
| 'following'
|
||||
|
|
@ -311,6 +312,12 @@ export class XProvider extends SocialAbstract implements SocialProvider {
|
|||
: {
|
||||
reply_settings: postDetails?.[0]?.settings?.who_can_reply_post,
|
||||
}),
|
||||
...(postDetails?.[0]?.settings?.community
|
||||
? {
|
||||
community_id:
|
||||
postDetails?.[0]?.settings?.community?.split('/').pop() || '',
|
||||
}
|
||||
: {}),
|
||||
text: post.message,
|
||||
...(media_ids.length ? { media: { media_ids } } : {}),
|
||||
...(ids.length
|
||||
|
|
|
|||
Loading…
Reference in New Issue