diff --git a/keyserver/src/creators/farcaster-channel-tag-creator.js b/keyserver/src/creators/farcaster-channel-tag-creator.js --- a/keyserver/src/creators/farcaster-channel-tag-creator.js +++ b/keyserver/src/creators/farcaster-channel-tag-creator.js @@ -2,14 +2,12 @@ import uuid from 'uuid'; -import { - DISABLE_TAGGING_FARCASTER_CHANNEL, - farcasterChannelTagBlobHash, -} from 'lib/shared/community-utils.js'; +import { farcasterChannelTagBlobHash } from 'lib/shared/community-utils.js'; import type { CreateOrUpdateFarcasterChannelTagRequest, CreateOrUpdateFarcasterChannelTagResponse, } from 'lib/types/community-types.js'; +import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { ServerError } from 'lib/utils/errors.js'; import { @@ -18,6 +16,7 @@ MYSQL_DUPLICATE_ENTRY_FOR_KEY_ERROR_CODE, } from '../database/database.js'; import { fetchCommunityInfos } from '../fetchers/community-fetchers.js'; +import { checkThreadPermission } from '../fetchers/thread-permission-fetchers.js'; import { uploadBlob, assignHolder, @@ -33,15 +32,23 @@ viewer: Viewer, request: CreateOrUpdateFarcasterChannelTagRequest, ): Promise { - if (DISABLE_TAGGING_FARCASTER_CHANNEL) { - throw new ServerError('internal_error'); - } + const permissionPromise = checkThreadPermission( + viewer, + request.commCommunityID, + threadPermissions.MANAGE_FARCASTER_CHANNEL_TAGS, + ); - const [communityInfos, blobDownload, keyserverID] = await Promise.all([ - fetchCommunityInfos(viewer, [request.commCommunityID]), - getFarcasterChannelTagBlob(request.farcasterChannelID), - thisKeyserverID(), - ]); + const [hasPermission, communityInfos, blobDownload, keyserverID] = + await Promise.all([ + permissionPromise, + fetchCommunityInfos(viewer, [request.commCommunityID]), + getFarcasterChannelTagBlob(request.farcasterChannelID), + thisKeyserverID(), + ]); + + if (!hasPermission) { + throw new ServerError('invalid_credentials'); + } if (communityInfos.length !== 1) { throw new ServerError('invalid_parameters'); diff --git a/keyserver/src/deleters/farcaster-channel-tag-deleters.js b/keyserver/src/deleters/farcaster-channel-tag-deleters.js --- a/keyserver/src/deleters/farcaster-channel-tag-deleters.js +++ b/keyserver/src/deleters/farcaster-channel-tag-deleters.js @@ -1,13 +1,12 @@ // @flow -import { - DISABLE_TAGGING_FARCASTER_CHANNEL, - farcasterChannelTagBlobHash, -} from 'lib/shared/community-utils.js'; +import { farcasterChannelTagBlobHash } from 'lib/shared/community-utils.js'; import type { DeleteFarcasterChannelTagRequest } from 'lib/types/community-types'; +import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { ServerError } from 'lib/utils/errors.js'; import { dbQuery, SQL } from '../database/database.js'; +import { checkThreadPermission } from '../fetchers/thread-permission-fetchers.js'; import { deleteBlob } from '../services/blob.js'; import type { Viewer } from '../session/viewer'; @@ -15,8 +14,14 @@ viewer: Viewer, request: DeleteFarcasterChannelTagRequest, ): Promise { - if (DISABLE_TAGGING_FARCASTER_CHANNEL) { - throw new ServerError('internal_error'); + const hasPermission = await checkThreadPermission( + viewer, + request.commCommunityID, + threadPermissions.MANAGE_FARCASTER_CHANNEL_TAGS, + ); + + if (!hasPermission) { + throw new ServerError('invalid_credentials'); } const query = SQL` diff --git a/lib/shared/community-utils.js b/lib/shared/community-utils.js --- a/lib/shared/community-utils.js +++ b/lib/shared/community-utils.js @@ -1,9 +1,7 @@ // @flow -const DISABLE_TAGGING_FARCASTER_CHANNEL = true; - function farcasterChannelTagBlobHash(farcasterChannelID: string): string { return `farcaster_channel_tag_${farcasterChannelID}`; } -export { DISABLE_TAGGING_FARCASTER_CHANNEL, farcasterChannelTagBlobHash }; +export { farcasterChannelTagBlobHash }; diff --git a/native/components/community-actions-button.react.js b/native/components/community-actions-button.react.js --- a/native/components/community-actions-button.react.js +++ b/native/components/community-actions-button.react.js @@ -7,13 +7,11 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { primaryInviteLinksSelector } from 'lib/selectors/invite-links-selectors.js'; -import { DISABLE_TAGGING_FARCASTER_CHANNEL } from 'lib/shared/community-utils.js'; import { useThreadHasPermission } from 'lib/shared/thread-utils.js'; import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; import { useCurrentUserFID } from 'lib/utils/farcaster-utils.js'; -import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js'; import SWMansionIcon from './swmansion-icon.react.js'; import { @@ -94,6 +92,10 @@ community, threadPermissions.CHANGE_ROLE, ); + const canManageFarcasterChannelTag = useThreadHasPermission( + community, + threadPermissions.MANAGE_FARCASTER_CHANNEL_TAGS, + ); const { showActionSheetWithOptions } = useActionSheet(); const actions = React.useMemo(() => { @@ -124,10 +126,9 @@ } const canTagFarcasterChannel = - !DISABLE_TAGGING_FARCASTER_CHANNEL && + canManageFarcasterChannelTag && fid && - community.type !== threadTypes.GENESIS && - (usingCommServicesAccessToken || __DEV__); + community.type !== threadTypes.GENESIS; if (canTagFarcasterChannel) { result.push({ @@ -145,6 +146,7 @@ canManageLinks, inviteLink, canChangeRoles, + canManageFarcasterChannelTag, fid, navigateToManagePublicLinkView, navigateToInviteLinksView,