gate group chats for under-18 users
Per the group chats spec, users under 18 cannot be added to or participate in group chats. This wires up the client-side half: - expose isUnder18 flag from the AA context (conservative default when birthdate is unknown) - new restrictGroupChatSettings helper that writes allowGroupInvites: 'none' to the chat actor declaration, called on signup and on birthdate-update when the user is under 18 - hide the 'New group chat' entry in InitiateChatFlow for under-18 users - lock the 'Allow group chat invites from' toggle to 'none' for under-18 in chat settings, with explanatory copy - pass kind: 'direct' to listConvos for under-18 users so groups don't show in the requests inbox or count toward the unread/requests badges
This commit is contained in:
@@ -198,6 +198,7 @@ export function ChatList({
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
const aa = useAgeAssurance()
|
||||
const scrollElRef: ListRef = useAnimatedRef()
|
||||
const {isWithinSplitView} = useIsWithinSplitView()
|
||||
|
||||
@@ -230,6 +231,7 @@ export function ChatList({
|
||||
|
||||
const {refetch: refetchInbox} = useListConvosQuery({
|
||||
status: 'request',
|
||||
kind: aa.flags.isDeclaredUnderAdultAge ? 'direct' : 'all',
|
||||
})
|
||||
|
||||
useRefreshOnFocus(refetch)
|
||||
@@ -449,6 +451,7 @@ export function Header({
|
||||
}) {
|
||||
const {t: l} = useLingui()
|
||||
const {gtMobile} = useBreakpoints()
|
||||
const aa = useAgeAssurance()
|
||||
const requireEmailVerification = useRequireEmailVerification()
|
||||
const leftConvos = useLeftConvos()
|
||||
|
||||
@@ -456,6 +459,7 @@ export function Header({
|
||||
useListConvosQuery({
|
||||
status: 'request',
|
||||
readState: 'unread',
|
||||
kind: aa.flags.isDeclaredUnderAdultAge ? 'direct' : 'all',
|
||||
})
|
||||
|
||||
const inboxAllConvos =
|
||||
|
||||
@@ -43,6 +43,7 @@ import * as Layout from '#/components/Layout'
|
||||
import {ListFooter} from '#/components/Lists'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useAgeAssurance} from '#/ageAssurance'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {RequestListItem} from './components/RequestListItem'
|
||||
import {useIsWithinSplitView} from './components/splitView/context'
|
||||
@@ -63,8 +64,12 @@ export function MessagesInboxScreen(props: Props) {
|
||||
|
||||
export function MessagesInboxScreenInner({}: Props) {
|
||||
const {gtTablet} = useBreakpoints()
|
||||
const aa = useAgeAssurance()
|
||||
|
||||
const listConvosQuery = useListConvosQuery({status: 'request'})
|
||||
const listConvosQuery = useListConvosQuery({
|
||||
status: 'request',
|
||||
kind: aa.flags.isDeclaredUnderAdultAge ? 'direct' : 'all',
|
||||
})
|
||||
const {data} = listConvosQuery
|
||||
|
||||
const leftConvos = useLeftConvos()
|
||||
|
||||
@@ -20,6 +20,7 @@ import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRightIcon} from '#/compon
|
||||
import * as Layout from '#/components/Layout'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useAgeAssurance} from '#/ageAssurance'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_NATIVE} from '#/env'
|
||||
import {useBackgroundNotificationPreferences} from '../../../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider'
|
||||
@@ -45,6 +46,7 @@ export function MessagesSettingsScreenInner({}: Props) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
const aa = useAgeAssurance()
|
||||
const {currentAccount} = useSession()
|
||||
const {data: profile} = useProfileQuery({
|
||||
did: currentAccount!.did,
|
||||
@@ -54,6 +56,7 @@ export function MessagesSettingsScreenInner({}: Props) {
|
||||
const exportCarControl = Dialog.useDialogControl()
|
||||
|
||||
const isGroupChatEnabled = ax.features.enabled(ax.features.GroupChatsEnable)
|
||||
const groupInvitesLocked = aa.flags.isDeclaredUnderAdultAge
|
||||
|
||||
const allowMessagesFromOptions: {name: AllowIncoming; label: string}[] = [
|
||||
{
|
||||
@@ -191,17 +194,26 @@ export function MessagesSettingsScreenInner({}: Props) {
|
||||
a.leading_snug,
|
||||
t.atoms.text_contrast_high,
|
||||
]}>
|
||||
<Trans>
|
||||
You can continue ongoing conversations regardless of which
|
||||
setting you choose.
|
||||
</Trans>
|
||||
{groupInvitesLocked ? (
|
||||
<Trans>
|
||||
Group chats are only available to users 18 and over.
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans>
|
||||
You can continue ongoing conversations regardless of which
|
||||
setting you choose.
|
||||
</Trans>
|
||||
)}
|
||||
</Text>
|
||||
<Toggle.Group
|
||||
disabled={groupInvitesLocked}
|
||||
label={l`Allow group chat invites from`}
|
||||
type="radio"
|
||||
values={[
|
||||
(profile?.associated?.chat
|
||||
?.allowGroupInvites as AllowIncoming) ?? 'following',
|
||||
groupInvitesLocked
|
||||
? 'none'
|
||||
: ((profile?.associated?.chat
|
||||
?.allowGroupInvites as AllowIncoming) ?? 'following'),
|
||||
]}
|
||||
onChange={onSelectGroupInvitesFrom}>
|
||||
<View>
|
||||
|
||||
Reference in New Issue
Block a user