Skip to content

Commit

Permalink
Set chat declaration upon signup (#4084)
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey authored May 17, 2024
1 parent cef243b commit 1b47ea7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/screens/Messages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export function MessagesSettingsScreen({}: Props) {
const gate = useGate()
if (!gate('dms')) return <ClipClopGate />

console.log(profile?.associated?.chat?.allowIncoming)

return (
<CenteredView sideBorders style={a.h_full_vh}>
<ViewHeader title={_(msg`Settings`)} showOnDesktop showBorder />
Expand Down
2 changes: 0 additions & 2 deletions src/state/queries/messages/actor-declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ export function useUpdateActorDeclaration({
return useMutation({
mutationFn: async (allowIncoming: 'all' | 'none' | 'following') => {
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({
repo: currentAccount.did,
collection: 'chat.bsky.actor.declaration',
rkey: 'self',
validate: false,
record: {
$type: 'chat.bsky.actor.declaration',
allowIncoming,
Expand Down
10 changes: 10 additions & 0 deletions src/state/session/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TIMELINE_SAVED_FEED,
} from '#/lib/constants'
import {tryFetchGates} from '#/lib/statsig/statsig'
import {getAge} from '#/lib/strings/time'
import {logger} from '#/logger'
import {
configureModerationForAccount,
Expand Down Expand Up @@ -153,6 +154,15 @@ export async function createAgentAndCreateAccount(
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) {
logger.error(e, {
Expand Down

0 comments on commit 1b47ea7

Please sign in to comment.