From 7933f83af2016ebe72e12973650ab219155666b1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 29 May 2024 09:39:02 -0500 Subject: [PATCH] Feature-gate domain blocks --- src/features/account/components/header.tsx | 2 +- src/features/ui/components/link-footer.tsx | 2 +- src/features/ui/index.tsx | 2 +- src/utils/features.ts | 11 +++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/features/account/components/header.tsx b/src/features/account/components/header.tsx index 837b5c976..cd95d5945 100644 --- a/src/features/account/components/header.tsx +++ b/src/features/account/components/header.tsx @@ -464,7 +464,7 @@ const Header: React.FC = ({ account }) => { }); } - if (!account.local) { + if (!account.local && features.domainBlocks) { const domain = account.fqn.split('@')[1]; menu.push(null); diff --git a/src/features/ui/components/link-footer.tsx b/src/features/ui/components/link-footer.tsx index 1800528a5..2162b20ca 100644 --- a/src/features/ui/components/link-footer.tsx +++ b/src/features/ui/components/link-footer.tsx @@ -53,7 +53,7 @@ const LinkFooter: React.FC = (): JSX.Element => { {features.followedHashtagsList && ( )} - {features.federating && ( + {features.domainBlocks && ( )} {account.admin && ( diff --git a/src/features/ui/index.tsx b/src/features/ui/index.tsx index 5ffb93aec..552adf723 100644 --- a/src/features/ui/index.tsx +++ b/src/features/ui/index.tsx @@ -268,7 +268,7 @@ const SwitchingColumnsArea: React.FC = ({ children }) => {features.blocks && } - {features.federating && } + {features.domainBlocks && } {(features.filters || features.filtersV2) && } {(features.filters || features.filtersV2) && } diff --git a/src/utils/features.ts b/src/utils/features.ts index 00737592b..b5aa122be 100644 --- a/src/utils/features.ts +++ b/src/utils/features.ts @@ -400,6 +400,17 @@ const getInstanceFeatures = (instance: Instance) => { */ dislikes: v.software === FRIENDICA && gte(v.version, '2023.3.0'), + /** + * Ability to block users by domain. + * @see GET /api/v1/domain_blocks + * @see POST /api/v1/domain_blocks + * @see DELETE /api/v1/domain_blocks + */ + domainBlocks: federation.enabled && any([ + v.software === MASTODON && gte(v.compatVersion, '1.4.0'), + v.software === PLEROMA, + ]), + /** * Allow to register on a given domain * @see GET /api/v1/pleroma/admin/domains