Set chat declaration upon signup (#4084)
parent
cef243bcf4
commit
1b47ea7367
|
@ -49,8 +49,6 @@ export function MessagesSettingsScreen({}: Props) {
|
||||||
const gate = useGate()
|
const gate = useGate()
|
||||||
if (!gate('dms')) return <ClipClopGate />
|
if (!gate('dms')) return <ClipClopGate />
|
||||||
|
|
||||||
console.log(profile?.associated?.chat?.allowIncoming)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CenteredView sideBorders style={a.h_full_vh}>
|
<CenteredView sideBorders style={a.h_full_vh}>
|
||||||
<ViewHeader title={_(msg`Settings`)} showOnDesktop showBorder />
|
<ViewHeader title={_(msg`Settings`)} showOnDesktop showBorder />
|
||||||
|
|
|
@ -19,12 +19,10 @@ export function useUpdateActorDeclaration({
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (allowIncoming: 'all' | 'none' | 'following') => {
|
mutationFn: async (allowIncoming: 'all' | 'none' | 'following') => {
|
||||||
if (!currentAccount) throw new Error('Not logged in')
|
if (!currentAccount) throw new Error('Not logged in')
|
||||||
// TODO(sam): remove validate: false once PDSes have the new lexicon
|
|
||||||
const result = await getAgent().api.com.atproto.repo.putRecord({
|
const result = await getAgent().api.com.atproto.repo.putRecord({
|
||||||
repo: currentAccount.did,
|
repo: currentAccount.did,
|
||||||
collection: 'chat.bsky.actor.declaration',
|
collection: 'chat.bsky.actor.declaration',
|
||||||
rkey: 'self',
|
rkey: 'self',
|
||||||
validate: false,
|
|
||||||
record: {
|
record: {
|
||||||
$type: 'chat.bsky.actor.declaration',
|
$type: 'chat.bsky.actor.declaration',
|
||||||
allowIncoming,
|
allowIncoming,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {
|
||||||
TIMELINE_SAVED_FEED,
|
TIMELINE_SAVED_FEED,
|
||||||
} from '#/lib/constants'
|
} from '#/lib/constants'
|
||||||
import {tryFetchGates} from '#/lib/statsig/statsig'
|
import {tryFetchGates} from '#/lib/statsig/statsig'
|
||||||
|
import {getAge} from '#/lib/strings/time'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {
|
import {
|
||||||
configureModerationForAccount,
|
configureModerationForAccount,
|
||||||
|
@ -153,6 +154,15 @@ export async function createAgentAndCreateAccount(
|
||||||
id: TID.nextStr(),
|
id: TID.nextStr(),
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
await agent.api.com.atproto.repo.putRecord({
|
||||||
|
repo: account.did,
|
||||||
|
collection: 'chat.bsky.actor.declaration',
|
||||||
|
rkey: 'self',
|
||||||
|
record: {
|
||||||
|
$type: 'chat.bsky.actor.declaration',
|
||||||
|
allowIncoming: getAge(birthDate) < 18 ? 'none' : 'following',
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.error(e, {
|
logger.error(e, {
|
||||||
|
|
Loading…
Reference in New Issue