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 @@ -1,5 +1,6 @@ // @flow +import t, { type TInterface } from 'tcomb'; import uuid from 'uuid'; import { farcasterChannelTagBlobHash } from 'lib/shared/community-utils.js'; @@ -14,6 +15,7 @@ import { threadPermissions } from 'lib/types/thread-permission-types.js'; import type { BlobOperationResult } from 'lib/utils/blob-service.js'; import { ServerError } from 'lib/utils/errors.js'; +import { tShape } from 'lib/utils/validation-utils.js'; import { dbQuery, @@ -207,6 +209,19 @@ return download(hash); } +const farcasterChannelTagBlobValidator: TInterface = + tShape({ + commCommunityID: t.String, + farcasterChannelID: t.String, + keyserverURL: t.String, + }); + +type FarcasterChannelTagBlob = { + +commCommunityID: string, + +farcasterChannelID: string, + +keyserverURL: string, +}; + async function uploadFarcasterChannelTagBlob( commCommunityID: string, farcasterChannelID: string, @@ -215,7 +230,7 @@ const { baseDomain, basePath } = getAndAssertKeyserverURLFacts(); const keyserverURL = baseDomain + basePath; - const payload = { + const payload: FarcasterChannelTagBlob = { commCommunityID, farcasterChannelID, keyserverURL, @@ -234,4 +249,9 @@ return await assignHolder({ holder, hash }); } -export { createOrUpdateFarcasterChannelTag, uploadFarcasterChannelTagBlob }; +export { + createOrUpdateFarcasterChannelTag, + uploadFarcasterChannelTagBlob, + getFarcasterChannelTagBlob, + farcasterChannelTagBlobValidator, +};