Skip to content

Commit c892cb0

Browse files
committed
feat: who can reply to the post
1 parent 375002c commit c892cb0

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

apps/frontend/src/components/launches/providers/x/x.provider.tsx

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,56 @@
11
import { withProvider } from '@gitroom/frontend/components/launches/providers/high.order.provider';
22
import { ThreadFinisher } from '@gitroom/frontend/components/launches/finisher/thread.finisher';
3+
import { Select } from '@gitroom/react/form/select';
4+
import { useT } from '@gitroom/react/translation/get.transation.service.client';
5+
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
6+
7+
const whoCanReply = [
8+
{
9+
label: 'Everyone',
10+
value: 'everyone',
11+
},
12+
{
13+
label: 'Accounts you follow',
14+
value: 'following',
15+
},
16+
{
17+
label: 'Mentioned accounts',
18+
value: 'mentionedUsers',
19+
},
20+
{
21+
label: 'Subscribers',
22+
value: 'subscribers',
23+
},
24+
{
25+
label: 'verified accounts',
26+
value: 'verified',
27+
}
28+
]
329

430
const SettingsComponent = () => {
5-
return <ThreadFinisher />;
31+
const t = useT();
32+
const { register, watch, setValue } = useSettings();
33+
34+
return (
35+
<>
36+
<Select
37+
label={t('label_who_can_reply_to_this_post', 'Who can reply to this post?')}
38+
className="mb-5"
39+
hideErrors={true}
40+
{...register('who_can_reply_post', {
41+
value: 'everyone',
42+
})}
43+
>
44+
{whoCanReply.map((item) => (
45+
<option key={item.value} value={item.value}>
46+
{item.label}
47+
</option>
48+
))}
49+
</Select>
50+
51+
<ThreadFinisher />
52+
</>
53+
);
654
};
755

856
export default withProvider(

libraries/nestjs-libraries/src/integrations/social/x.provider.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ export class XProvider extends SocialAbstract implements SocialProvider {
241241
postDetails: PostDetails<{
242242
active_thread_finisher: boolean;
243243
thread_finisher: string;
244+
who_can_reply_post:
245+
| 'everyone'
246+
| 'following'
247+
| 'mentionedUsers'
248+
| 'subscribers'
249+
| 'verified';
244250
}>[]
245251
): Promise<PostResponse[]> {
246252
const [accessTokenSplit, accessSecretSplit] = accessToken.split(':');
@@ -299,6 +305,12 @@ export class XProvider extends SocialAbstract implements SocialProvider {
299305

300306
// @ts-ignore
301307
const { data }: { data: { id: string } } = await client.v2.tweet({
308+
...(!postDetails?.[0]?.settings?.who_can_reply_post ||
309+
postDetails?.[0]?.settings?.who_can_reply_post === 'everyone'
310+
? {}
311+
: {
312+
reply_settings: postDetails?.[0]?.settings?.who_can_reply_post,
313+
}),
302314
text: post.message,
303315
...(media_ids.length ? { media: { media_ids } } : {}),
304316
...(ids.length

libraries/react-shared-libraries/src/translation/locales/en/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,5 +485,6 @@
485485
"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",
486486
"post_as_images_carousel": "Post as images carousel",
487487
"save_set": "Save Set",
488-
"separate_post": "Separate post to multiple posts"
488+
"separate_post": "Separate post to multiple posts",
489+
"label_who_can_reply_to_this_post": "Who can reply to this post?"
489490
}

0 commit comments

Comments
 (0)