diff --git a/keyserver/src/creators/invite-link-creator.js b/keyserver/src/creators/invite-link-creator.js --- a/keyserver/src/creators/invite-link-creator.js +++ b/keyserver/src/creators/invite-link-creator.js @@ -2,6 +2,7 @@ import Filter from 'bad-words'; +import { inviteLinkBlobHash } from 'lib/shared/invite-links.js'; import type { CreateOrUpdatePublicLinkRequest, InviteLink, @@ -152,7 +153,7 @@ async function getInviteLinkBlob( request: CreateOrUpdatePublicLinkRequest, ): Promise { - const hash = `invite_${request.name}`; + const hash = inviteLinkBlobHash(request.name); return download(hash); } diff --git a/keyserver/src/deleters/link-deleters.js b/keyserver/src/deleters/link-deleters.js --- a/keyserver/src/deleters/link-deleters.js +++ b/keyserver/src/deleters/link-deleters.js @@ -1,5 +1,6 @@ // @flow +import { inviteLinkBlobHash } from 'lib/shared/invite-links.js'; import type { DisableInviteLinkRequest } from 'lib/types/link-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { ServerError } from 'lib/utils/errors.js'; @@ -31,7 +32,7 @@ const [[row]] = await dbQuery(query); if (row?.blobHolder) { await deleteBlob({ - hash: `invite_${request.name}`, + hash: inviteLinkBlobHash(request.name), holder: row.blobHolder, }); } diff --git a/lib/shared/invite-links.js b/lib/shared/invite-links.js --- a/lib/shared/invite-links.js +++ b/lib/shared/invite-links.js @@ -11,4 +11,8 @@ const defaultErrorMessage = 'Unknown error.'; -export { inviteLinkErrorMessages, defaultErrorMessage }; +function inviteLinkBlobHash(secret: string): string { + return `invite_${secret}`; +} + +export { inviteLinkErrorMessages, defaultErrorMessage, inviteLinkBlobHash };