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,7 +2,10 @@ import uuid from 'uuid'; -import { DISABLE_TAGGING_FARCASTER_CHANNEL } from 'lib/shared/community-utils.js'; +import { + DISABLE_TAGGING_FARCASTER_CHANNEL, + farcasterChannelTagBlobHash, +} from 'lib/shared/community-utils.js'; import type { CreateOrUpdateFarcasterChannelTagRequest, CreateOrUpdateFarcasterChannelTagResponse, @@ -56,10 +59,6 @@ }; } -function farcasterChannelTagBlobHash(secret: string): string { - return `farcaster_channel_tag_${secret}`; -} - function getFarcasterChannelTagBlob( secret: string, ): Promise { diff --git a/keyserver/src/deleters/farcaster-channel-tag-deleters.js b/keyserver/src/deleters/farcaster-channel-tag-deleters.js new file mode 100644 --- /dev/null +++ b/keyserver/src/deleters/farcaster-channel-tag-deleters.js @@ -0,0 +1,32 @@ +// @flow + +import { + DISABLE_TAGGING_FARCASTER_CHANNEL, + farcasterChannelTagBlobHash, +} from 'lib/shared/community-utils.js'; +import type { DeleteFarcasterChannelTagRequest } from 'lib/types/community-types'; +import { ServerError } from 'lib/utils/errors.js'; + +import { deleteBlob } from '../services/blob.js'; +import type { Viewer } from '../session/viewer'; + +async function deleteFarcasterChannelTag( + viewer: Viewer, + request: DeleteFarcasterChannelTagRequest, +): Promise { + const { farcasterChannelID, blobHolder } = request; + + if (DISABLE_TAGGING_FARCASTER_CHANNEL) { + throw new ServerError('internal_error'); + } + + await deleteBlob( + { + hash: farcasterChannelTagBlobHash(farcasterChannelID), + holder: blobHolder, + }, + true, + ); +} + +export { deleteFarcasterChannelTag }; 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 @@ -2,4 +2,8 @@ const DISABLE_TAGGING_FARCASTER_CHANNEL = true; -export { DISABLE_TAGGING_FARCASTER_CHANNEL }; +function farcasterChannelTagBlobHash(farcasterChannelID: string): string { + return `farcaster_channel_tag_${farcasterChannelID}`; +} + +export { DISABLE_TAGGING_FARCASTER_CHANNEL, farcasterChannelTagBlobHash }; diff --git a/lib/types/community-types.js b/lib/types/community-types.js --- a/lib/types/community-types.js +++ b/lib/types/community-types.js @@ -26,3 +26,9 @@ +commCommunityID: string, +blobHolder: string, }; + +export type DeleteFarcasterChannelTagRequest = { + +commCommunityID: string, + +farcasterChannelID: string, + +blobHolder: string, +};