feat: who can reply to the post

This commit is contained in:
Nevo David 2025-06-17 22:28:11 +07:00
parent 375002ca73
commit c892cb0ef2
3 changed files with 63 additions and 2 deletions

View File

@ -1,8 +1,56 @@
import { withProvider } from '@gitroom/frontend/components/launches/providers/high.order.provider'; import { withProvider } from '@gitroom/frontend/components/launches/providers/high.order.provider';
import { ThreadFinisher } from '@gitroom/frontend/components/launches/finisher/thread.finisher'; import { ThreadFinisher } from '@gitroom/frontend/components/launches/finisher/thread.finisher';
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';
const whoCanReply = [
{
label: 'Everyone',
value: 'everyone',
},
{
label: 'Accounts you follow',
value: 'following',
},
{
label: 'Mentioned accounts',
value: 'mentionedUsers',
},
{
label: 'Subscribers',
value: 'subscribers',
},
{
label: 'verified accounts',
value: 'verified',
}
]
const SettingsComponent = () => { const SettingsComponent = () => {
return <ThreadFinisher />; const t = useT();
const { register, watch, setValue } = useSettings();
return (
<>
<Select
label={t('label_who_can_reply_to_this_post', 'Who can reply to this post?')}
className="mb-5"
hideErrors={true}
{...register('who_can_reply_post', {
value: 'everyone',
})}
>
{whoCanReply.map((item) => (
<option key={item.value} value={item.value}>
{item.label}
</option>
))}
</Select>
<ThreadFinisher />
</>
);
}; };
export default withProvider( export default withProvider(

View File

@ -241,6 +241,12 @@ export class XProvider extends SocialAbstract implements SocialProvider {
postDetails: PostDetails<{ postDetails: PostDetails<{
active_thread_finisher: boolean; active_thread_finisher: boolean;
thread_finisher: string; thread_finisher: string;
who_can_reply_post:
| 'everyone'
| 'following'
| 'mentionedUsers'
| 'subscribers'
| 'verified';
}>[] }>[]
): Promise<PostResponse[]> { ): Promise<PostResponse[]> {
const [accessTokenSplit, accessSecretSplit] = accessToken.split(':'); const [accessTokenSplit, accessSecretSplit] = accessToken.split(':');
@ -299,6 +305,12 @@ export class XProvider extends SocialAbstract implements SocialProvider {
// @ts-ignore // @ts-ignore
const { data }: { data: { id: string } } = await client.v2.tweet({ const { data }: { data: { id: string } } = await client.v2.tweet({
...(!postDetails?.[0]?.settings?.who_can_reply_post ||
postDetails?.[0]?.settings?.who_can_reply_post === 'everyone'
? {}
: {
reply_settings: postDetails?.[0]?.settings?.who_can_reply_post,
}),
text: post.message, text: post.message,
...(media_ids.length ? { media: { media_ids } } : {}), ...(media_ids.length ? { media: { media_ids } } : {}),
...(ids.length ...(ids.length

View File

@ -485,5 +485,6 @@
"that_a_wrap": "That's a wrap!\n\nIf you enjoyed this thread:\n\n1. Follow me @{{username}} for more of these\n2. RT the tweet below to share this thread with your audience\n", "that_a_wrap": "That's a wrap!\n\nIf you enjoyed this thread:\n\n1. Follow me @{{username}} for more of these\n2. RT the tweet below to share this thread with your audience\n",
"post_as_images_carousel": "Post as images carousel", "post_as_images_carousel": "Post as images carousel",
"save_set": "Save Set", "save_set": "Save Set",
"separate_post": "Separate post to multiple posts" "separate_post": "Separate post to multiple posts",
"label_who_can_reply_to_this_post": "Who can reply to this post?"
} }