Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(app): remove the UK age check, region blocks stay in place

Hampus885d8f161064
diff --git a/fluxer_app/src/features/channel/components/MatureContentChannelGate.tsx b/fluxer_app/src/features/channel/components/MatureContentChannelGate.tsx
index 8a3832147..067301e16 100644
--- a/fluxer_app/src/features/channel/components/MatureContentChannelGate.tsx
+++ b/fluxer_app/src/features/channel/components/MatureContentChannelGate.tsx
@@ -2,32 +2,22 @@
import {ExternalLink} from '@app/features/app/components/shared/ExternalLink';
import {HelpCenterArticleSlug} from '@app/features/app/config/HelpCenterConstants';
-import {MatureContentCheckModal} from '@app/features/auth/components/modals/MatureContentCheckModal';
import styles from '@app/features/channel/components/MatureContentChannelGate.module.css';
import * as GuildMatureContentCommands from '@app/features/guild/commands/GuildMatureContentCommands';
import GuildMatureContentAgree, {
type AgreementScope,
MatureContentGateReason,
} from '@app/features/guild/state/GuildMatureContentAgree';
-import {
- COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR,
- MATURE_CONTENT_DESCRIPTOR,
- PROCEED_DESCRIPTOR,
-} from '@app/features/i18n/utils/CommonMessageDescriptors';
+import {MATURE_CONTENT_DESCRIPTOR, PROCEED_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {getDefaultContentWarningText} from '@app/features/messaging/utils/ContentWarningUtils';
-import {
- getEffectiveMatureContentGeoContext,
- isMatureContentCheckAvailableInRegion,
-} from '@app/features/moderation/utils/MatureContentGeoUtils';
+import {getEffectiveMatureContentGeoContext} from '@app/features/moderation/utils/MatureContentGeoUtils';
import {Button} from '@app/features/ui/button/Button';
-import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
-import {modal} from '@app/features/ui/commands/ModalCommands';
import * as HelpCenterUtils from '@app/features/ui/utils/HelpCenterUtils';
import {getRegionDisplayName} from '@app/features/user/utils/UserGeo';
import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
import {observer} from 'mobx-react-lite';
-import {useCallback} from 'react';
+import type {ReactNode} from 'react';
const MATURE_COMMUNITY_NOT_AVAILABLE_DESCRIPTOR = msg({
message: 'This mature community is not available to your account.',
@@ -57,13 +47,6 @@ export const MatureContentChannelGate = observer(({channelId, guildId, reason, s
const effectiveMatureContent = resolved.effectiveMatureContent;
const hasCustomWarningText = resolved.effectiveWarningText != null && resolved.effectiveWarningText.length > 0;
const warningBody = hasCustomWarningText ? resolved.effectiveWarningText : getDefaultContentWarningText(i18n);
- const handleOpenMatureContentCheck = useCallback(() => {
- ModalCommands.push(
- modal(() => (
- <MatureContentCheckModal data-flx="channel.mature-content-channel-gate.handle-open-mature-content-check.mature-content-check-modal" />
- )),
- );
- }, []);
const handleProceed = () => {
if (scope === 'guild' && resolved.guildId) {
GuildMatureContentCommands.agreeToGuild(resolved.guildId);
@@ -86,42 +69,16 @@ export const MatureContentChannelGate = observer(({channelId, guildId, reason, s
case MatureContentGateReason.GEO_RESTRICTED: {
const {countryCode, regionCode} = getEffectiveMatureContentGeoContext();
const regionName = getRegionDisplayName(i18n, countryCode ?? undefined, regionCode ?? undefined);
- const matureContentCheckAvailable = isMatureContentCheckAvailableInRegion();
return (
<>
<h2 className={styles.title} data-flx="channel.mature-content-channel-gate.render-content.title">
{i18n._(MATURE_CONTENT_DESCRIPTOR)}
</h2>
- {matureContentCheckAvailable ? (
- <p
- className={styles.description}
- data-flx="channel.mature-content-channel-gate.render-content.description"
- >
- <Trans>
- Due to mature content laws in {regionName}, mature content is blocked until you complete the mature
- content check.
- </Trans>
- </p>
- ) : (
- <p
- className={styles.description}
- data-flx="channel.mature-content-channel-gate.render-content.description--2"
- >
- <Trans>
- Due to mature content laws in {regionName}, mature content is not available from here. Mature content
- checks are available only in the UK.
- </Trans>
- </p>
- )}
- {matureContentCheckAvailable && (
- <Button
- onClick={handleOpenMatureContentCheck}
- variant="primary"
- data-flx="channel.mature-content-channel-gate.render-content.button.open-mature-content-check"
- >
- {i18n._(COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR)}
- </Button>
- )}
+ <p className={styles.description} data-flx="channel.mature-content-channel-gate.render-content.description">
+ <Trans comment="Shown in place of a mature content channel when local law blocks it. regionName is the country or region the person is in.">
+ Due to mature content laws in {regionName}, mature content is not available from here.
+ </Trans>
+ </p>
</>
);
}
@@ -207,14 +164,14 @@ export const MatureContentChannelGate = observer(({channelId, guildId, reason, s
);
default: {
if (!effectiveMatureContent) {
- const title =
- scope === 'guild' ? (
- <Trans>Community content warning</Trans>
- ) : scope === 'category' ? (
- <Trans>Category content warning</Trans>
- ) : (
- <Trans>Channel content warning</Trans>
- );
+ let title: ReactNode;
+ if (scope === 'guild') {
+ title = <Trans>Community content warning</Trans>;
+ } else if (scope === 'category') {
+ title = <Trans>Category content warning</Trans>;
+ } else {
+ title = <Trans>Channel content warning</Trans>;
+ }
return (
<>
<h2 className={styles.title} data-flx="channel.mature-content-channel-gate.render-content.title--5">
diff --git a/fluxer_app/src/features/channel/components/modals/ChannelAccessGateModal.tsx b/fluxer_app/src/features/channel/components/modals/ChannelAccessGateModal.tsx
index e087c301e..70884ea88 100644
--- a/fluxer_app/src/features/channel/components/modals/ChannelAccessGateModal.tsx
+++ b/fluxer_app/src/features/channel/components/modals/ChannelAccessGateModal.tsx
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import * as Modal from '@app/features/app/components/dialogs/Modal';
-import {MatureContentCheckModal} from '@app/features/auth/components/modals/MatureContentCheckModal';
import type {Channel} from '@app/features/channel/models/Channel';
import * as GuildMatureContentCommands from '@app/features/guild/commands/GuildMatureContentCommands';
import GuildMatureContentAgree, {
@@ -10,21 +9,15 @@ import GuildMatureContentAgree, {
} from '@app/features/guild/state/GuildMatureContentAgree';
import {
CANCEL_DESCRIPTOR,
- COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR,
CONTINUE_DESCRIPTOR,
MATURE_CONTENT_DESCRIPTOR,
OPEN_LINK_DESCRIPTOR,
PROCEED_DESCRIPTOR,
- UNDERSTOOD_DESCRIPTOR,
} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {getDefaultContentWarningText} from '@app/features/messaging/utils/ContentWarningUtils';
-import {
- getEffectiveMatureContentGeoContext,
- isMatureContentCheckAvailableInRegion,
-} from '@app/features/moderation/utils/MatureContentGeoUtils';
+import {getEffectiveMatureContentGeoContext} from '@app/features/moderation/utils/MatureContentGeoUtils';
import {Button} from '@app/features/ui/button/Button';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
-import {modal} from '@app/features/ui/commands/ModalCommands';
import {getRegionDisplayName} from '@app/features/user/utils/UserGeo';
import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';
import {msg} from '@lingui/core/macro';
@@ -44,17 +37,10 @@ const CHANNEL_CONTENT_WARNING_DESCRIPTOR = msg({
message: 'Channel content warning',
comment: 'Title in a modal shown before opening a channel with a custom content warning.',
});
-const DUE_TO_MATURE_CONTENT_LAWS_DESCRIPTOR = msg({
- message:
- 'Due to mature content laws in {regionName}, this content is blocked until you complete the mature content check.',
+const MATURE_CONTENT_REGION_UNAVAILABLE_DESCRIPTOR = msg({
+ message: 'Due to mature content laws in {regionName}, this content is not available from here.',
comment:
- 'Body in the channel gate modal for regions that require a mature content check. {regionName} is a localized place name.',
-});
-const MATURE_CONTENT_CHECK_NOT_AVAILABLE_DESCRIPTOR = msg({
- message:
- 'Due to mature content laws in {regionName}, this content is not available from here. Mature content checks are available only in the UK.',
- comment:
- 'Body in the channel gate modal for regions where mature content is blocked and the app cannot offer the check. {regionName} is a localized place name.',
+ 'Body in the channel gate modal for regions where local law blocks mature content. {regionName} is a localized place name.',
});
const MATURE_COMMUNITY_UNAVAILABLE_DESCRIPTOR = msg({
message: 'This mature community is not available to your account.',
@@ -129,8 +115,6 @@ export const ChannelAccessGateModal = observer(
const warningBody = hasCustomWarningText ? resolved.effectiveWarningText : getDefaultContentWarningText(i18n);
const isVoiceChannel = channel?.type === ChannelTypes.GUILD_VOICE;
const isLinkChannel = channel?.type === ChannelTypes.GUILD_LINK;
- const matureContentCheckAvailable =
- reason === MatureContentGateReason.GEO_RESTRICTED && isMatureContentCheckAvailableInRegion();
const title = useMemo(() => {
if (
reason === MatureContentGateReason.GEO_RESTRICTED ||
@@ -153,10 +137,7 @@ export const ChannelAccessGateModal = observer(
if (reason === MatureContentGateReason.GEO_RESTRICTED) {
const {countryCode, regionCode} = getEffectiveMatureContentGeoContext();
const regionName = getRegionDisplayName(i18n, countryCode ?? undefined, regionCode ?? undefined);
- if (matureContentCheckAvailable) {
- return i18n._(DUE_TO_MATURE_CONTENT_LAWS_DESCRIPTOR, {regionName});
- }
- return i18n._(MATURE_CONTENT_CHECK_NOT_AVAILABLE_DESCRIPTOR, {regionName});
+ return i18n._(MATURE_CONTENT_REGION_UNAVAILABLE_DESCRIPTOR, {regionName});
}
if (reason === MatureContentGateReason.MATURE_CONTENT_CHECK_REQUIRED) {
if (resolved.scope === 'guild') {
@@ -189,7 +170,6 @@ export const ChannelAccessGateModal = observer(
}, [
i18n.locale,
reason,
- matureContentCheckAvailable,
resolved.scope,
resolved.effectiveMatureContent,
warningBody,
@@ -200,20 +180,20 @@ export const ChannelAccessGateModal = observer(
const handleCancel = useCallback(() => {
ModalCommands.pop();
}, []);
- const handleOpenMatureContentCheck = useCallback(() => {
- ModalCommands.pop();
- ModalCommands.push(
- modal(() => (
- <MatureContentCheckModal data-flx="channel.channel-access-gate-modal.mature-content-check-modal" />
- )),
- );
- }, []);
const handleConfirm = useCallback(() => {
agreeToResolvedScope(resolved, channelId ?? channel?.id ?? null);
ModalCommands.pop();
onConfirm?.();
}, [channel?.id, channelId, onConfirm, resolved]);
const canConfirm = reason === MatureContentGateReason.CONSENT_REQUIRED;
+ let confirmDescriptor = CONTINUE_DESCRIPTOR;
+ if (canConfirm) {
+ if (resolved.effectiveMatureContent) {
+ confirmDescriptor = PROCEED_DESCRIPTOR;
+ } else if (isLinkChannel) {
+ confirmDescriptor = OPEN_LINK_DESCRIPTOR;
+ }
+ }
return (
<Modal.Root
size="small"
@@ -228,8 +208,8 @@ export const ChannelAccessGateModal = observer(
<Modal.Description data-flx="channel.channel-access-gate-modal.modal-description">{body}</Modal.Description>
</Modal.ContentLayout>
</Modal.Content>
- <Modal.Footer data-flx="channel.channel-access-gate-modal.modal-footer">
- {canConfirm && (
+ {canConfirm ? (
+ <Modal.Footer data-flx="channel.channel-access-gate-modal.modal-footer">
<Button
type="button"
variant="secondary"
@@ -238,29 +218,19 @@ export const ChannelAccessGateModal = observer(
>
{i18n._(CANCEL_DESCRIPTOR)}
</Button>
- )}
- <Button
- type="button"
- ref={initialFocusRef}
- variant={canConfirm && resolved.effectiveMatureContent ? 'danger' : 'primary'}
- onClick={
- canConfirm ? handleConfirm : matureContentCheckAvailable ? handleOpenMatureContentCheck : handleCancel
- }
- data-flx="channel.channel-access-gate-modal.button.primary"
- >
- {canConfirm
- ? i18n._(
- resolved.effectiveMatureContent
- ? PROCEED_DESCRIPTOR
- : isLinkChannel
- ? OPEN_LINK_DESCRIPTOR
- : CONTINUE_DESCRIPTOR,
- )
- : matureContentCheckAvailable
- ? i18n._(COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR)
- : i18n._(UNDERSTOOD_DESCRIPTOR)}
- </Button>
- </Modal.Footer>
+ <Button
+ type="button"
+ ref={initialFocusRef}
+ variant={resolved.effectiveMatureContent ? 'danger' : 'primary'}
+ onClick={handleConfirm}
+ data-flx="channel.channel-access-gate-modal.button.primary"
+ >
+ {i18n._(confirmDescriptor)}
+ </Button>
+ </Modal.Footer>
+ ) : (
+ <Modal.DismissFooter data-flx="channel.channel-access-gate-modal.dismiss-footer" />
+ )}
</Modal.Root>
);
},
diff --git a/fluxer_app/src/features/mature_content/commands/MatureContentCheckCommands.ts b/fluxer_app/src/features/mature_content/commands/MatureContentCheckCommands.ts
deleted file mode 100644
index 1c9f03f9a..000000000
--- a/fluxer_app/src/features/mature_content/commands/MatureContentCheckCommands.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-or-later
-
-import {Endpoints} from '@app/features/app/constants/Endpoints';
-import {http} from '@app/features/platform/transport/RestTransport';
-import {Logger} from '@app/features/platform/utils/AppLogger';
-
-const logger = new Logger('MatureContentCheck');
-
-interface MatureContentCheckSession {
- url: string;
-}
-
-async function requestMatureContentCheckSession(): Promise<MatureContentCheckSession> {
- const response = await http.post<MatureContentCheckSession>(Endpoints.AGE_VERIFICATION);
- return response.body;
-}
-
-function sessionUrlFrom(response: MatureContentCheckSession): string {
- return response.url;
-}
-
-function rethrowSessionFailure(error: unknown): never {
- logger.error('Mature content check session creation failed', error);
- throw error;
-}
-
-export async function createMatureContentCheckSession(): Promise<string> {
- try {
- const session = await requestMatureContentCheckSession();
- logger.info('Mature content check session created');
- return sessionUrlFrom(session);
- } catch (error) {
- rethrowSessionFailure(error);
- }
-}
diff --git a/fluxer_app/src/features/moderation/components/modals/MatureMediaGateDetailsModal.tsx b/fluxer_app/src/features/moderation/components/modals/MatureMediaGateDetailsModal.tsx
index c045db5d3..fa2388b1f 100644
--- a/fluxer_app/src/features/moderation/components/modals/MatureMediaGateDetailsModal.tsx
+++ b/fluxer_app/src/features/moderation/components/modals/MatureMediaGateDetailsModal.tsx
@@ -3,19 +3,9 @@
import * as Modal from '@app/features/app/components/dialogs/Modal';
import {ExternalLink} from '@app/features/app/components/shared/ExternalLink';
import {HelpCenterArticleSlug} from '@app/features/app/config/HelpCenterConstants';
-import {MatureContentCheckModal} from '@app/features/auth/components/modals/MatureContentCheckModal';
import {MatureContentGateReason} from '@app/features/guild/state/GuildMatureContentAgree';
-import {
- CLOSE_DESCRIPTOR,
- COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR,
-} from '@app/features/i18n/utils/CommonMessageDescriptors';
-import {
- getEffectiveMatureContentGeoContext,
- isMatureContentCheckAvailableInRegion,
-} from '@app/features/moderation/utils/MatureContentGeoUtils';
-import {Button} from '@app/features/ui/button/Button';
+import {getEffectiveMatureContentGeoContext} from '@app/features/moderation/utils/MatureContentGeoUtils';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
-import {modal} from '@app/features/ui/commands/ModalCommands';
import * as HelpCenterUtils from '@app/features/ui/utils/HelpCenterUtils';
import {getRegionDisplayName} from '@app/features/user/utils/UserGeo';
import {msg} from '@lingui/core/macro';
@@ -43,18 +33,9 @@ export const MatureMediaGateDetailsModal = observer(({reason}: MatureMediaGateDe
const handleClose = useCallback(() => {
ModalCommands.pop();
}, []);
- const handleOpenMatureContentCheck = useCallback(() => {
- ModalCommands.pop();
- ModalCommands.push(
- modal(() => (
- <MatureContentCheckModal data-flx="moderation.mature-media-gate-details-modal.handle-open-mature-content-check.mature-content-check-modal" />
- )),
- );
- }, []);
if (reason === MatureContentGateReason.GEO_RESTRICTED) {
const {countryCode, regionCode} = getEffectiveMatureContentGeoContext();
const regionName = getRegionDisplayName(i18n, countryCode ?? undefined, regionCode ?? undefined);
- const matureContentCheckAvailable = isMatureContentCheckAvailableInRegion();
return (
<Modal.Root size="small" centered data-flx="moderation.mature-media-gate-details-modal.modal-root">
<Modal.Header
@@ -68,35 +49,12 @@ export const MatureMediaGateDetailsModal = observer(({reason}: MatureMediaGateDe
Due to mature content laws in {regionName}, this media is not available from your current region.
</Trans>
</Modal.Description>
- {matureContentCheckAvailable ? (
- <Modal.Description data-flx="moderation.mature-media-gate-details-modal.modal-description--2">
- <Trans>Complete the mature content check to unlock mature media.</Trans>
- </Modal.Description>
- ) : (
- <Modal.Description data-flx="moderation.mature-media-gate-details-modal.modal-description--3">
- <Trans>Mature content checks are currently available only in the UK.</Trans>
- </Modal.Description>
- )}
</Modal.ContentLayout>
</Modal.Content>
- {matureContentCheckAvailable && (
- <Modal.Footer data-flx="moderation.mature-media-gate-details-modal.modal-footer">
- <Button
- onClick={handleClose}
- variant="secondary"
- data-flx="moderation.mature-media-gate-details-modal.button.close"
- >
- {i18n._(CLOSE_DESCRIPTOR)}
- </Button>
- <Button
- onClick={handleOpenMatureContentCheck}
- variant="primary"
- data-flx="moderation.mature-media-gate-details-modal.button.open-mature-content-check"
- >
- {i18n._(COMPLETE_MATURE_CONTENT_CHECK_DESCRIPTOR)}
- </Button>
- </Modal.Footer>
- )}
+ <Modal.DismissFooter
+ onDismiss={handleClose}
+ data-flx="moderation.mature-media-gate-details-modal.dismiss-footer"
+ />
</Modal.Root>
);
}
diff --git a/fluxer_app/src/features/moderation/utils/MatureContentGeoUtils.ts b/fluxer_app/src/features/moderation/utils/MatureContentGeoUtils.ts
index f08f9c737..ff8aa048f 100644
--- a/fluxer_app/src/features/moderation/utils/MatureContentGeoUtils.ts
+++ b/fluxer_app/src/features/moderation/utils/MatureContentGeoUtils.ts
@@ -17,8 +17,3 @@ export function getEffectiveMatureContentGeoContext(): MatureContentGeoContext {
regionCode: GeoIP.regionCode,
};
}
-
-export function isMatureContentCheckAvailableInRegion(): boolean {
- const {countryCode} = getEffectiveMatureContentGeoContext();
- return countryCode === 'GB';
-}