about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-05-17 15:38:47 -0500
committerGitHub <noreply@github.com>2024-05-17 15:38:47 -0500
commit1b47ea7367c7d0f37557d8f07329c3b6f97a5e03 (patch)
tree4d738b08b30bbf914855b48ae31ff951faee9fae /src
parentcef243bcf47235b16f0dba54c917fb8c37757c96 (diff)
downloadvoidsky-1b47ea7367c7d0f37557d8f07329c3b6f97a5e03.tar.zst
Set chat declaration upon signup (#4084)
Diffstat (limited to 'src')
-rw-r--r--src/screens/Messages/Settings.tsx2
-rw-r--r--src/state/queries/messages/actor-declaration.ts2
-rw-r--r--src/state/session/agent.ts10
3 files changed, 10 insertions, 4 deletions
diff --git a/src/screens/Messages/Settings.tsx b/src/screens/Messages/Settings.tsx
index 7dbf027f9..7671239ad 100644
--- a/src/screens/Messages/Settings.tsx
+++ b/src/screens/Messages/Settings.tsx
@@ -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 />
diff --git a/src/state/queries/messages/actor-declaration.ts b/src/state/queries/messages/actor-declaration.ts
index 0886af382..d6a86cf69 100644
--- a/src/state/queries/messages/actor-declaration.ts
+++ b/src/state/queries/messages/actor-declaration.ts
@@ -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,
diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts
index 9633dc0e3..3de4cad26 100644
--- a/src/state/session/agent.ts
+++ b/src/state/session/agent.ts
@@ -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,
@@ -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, {