From 5771ff4b56f235a5f356d55a92dce0b45f7a4679 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 20 May 2024 14:41:24 -0500 Subject: Conditionally set chat declaration (#4122) --- src/state/session/agent.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts index 3de4cad26..972d33425 100644 --- a/src/state/session/agent.ts +++ b/src/state/session/agent.ts @@ -154,15 +154,18 @@ 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', - }, - }) + + if (getAge(birthDate) < 18) { + await agent.api.com.atproto.repo.putRecord({ + repo: account.did, + collection: 'chat.bsky.actor.declaration', + rkey: 'self', + record: { + $type: 'chat.bsky.actor.declaration', + allowIncoming: 'none', + }, + }) + } }) } catch (e: any) { logger.error(e, { -- cgit 1.4.1