From e86c91a159504d03c161da26ccd2c40d90c3f8c8 Mon Sep 17 00:00:00 2001 From: William Chong Date: Wed, 11 Dec 2024 02:23:46 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20tableOfContents=20for=20book?= =?UTF-8?q?=20listing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/likernft/book/store.ts | 5 +++++ src/util/ValidationHelper.ts | 2 ++ src/util/api/likernft/book/index.ts | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/src/routes/likernft/book/store.ts b/src/routes/likernft/book/store.ts index e427bb7b1..d466e1549 100644 --- a/src/routes/likernft/book/store.ts +++ b/src/routes/likernft/book/store.ts @@ -419,6 +419,7 @@ router.post(['/:classId/new', '/class/:classId/new'], jwtAuth('write:nftbook'), mustClaimToView = false, hideDownload = false, enableCustomMessagePage = false, + tableOfContents, autoDeliverNFTsTxHash, } = req.body; const [iscnInfo, metadata] = await Promise.all([ @@ -479,6 +480,7 @@ router.post(['/:classId/new', '/class/:classId/new'], jwtAuth('write:nftbook'), shippingRates, mustClaimToView, enableCustomMessagePage, + tableOfContents, hideDownload, // From ISCN content metadata @@ -532,6 +534,7 @@ router.post(['/:classId/new', '/class/:classId/new'], jwtAuth('write:nftbook'), mustClaimToView, hideDownload, enableCustomMessagePage, + tableOfContents, }); res.json({ @@ -553,6 +556,7 @@ router.post(['/:classId/settings', '/class/:classId/settings'], jwtAuth('write:n mustClaimToView, hideDownload, enableCustomMessagePage, + tableOfContents, } = req.body; const bookInfo = await getNftBookInfo(classId); if (!bookInfo) throw new ValidationError('CLASS_ID_NOT_FOUND', 404); @@ -569,6 +573,7 @@ router.post(['/:classId/settings', '/class/:classId/settings'], jwtAuth('write:n mustClaimToView, hideDownload, enableCustomMessagePage, + tableOfContents, }); publisher.publish(PUBSUB_TOPIC_MISC, req, { diff --git a/src/util/ValidationHelper.ts b/src/util/ValidationHelper.ts index 71790f590..7d23736e5 100644 --- a/src/util/ValidationHelper.ts +++ b/src/util/ValidationHelper.ts @@ -688,6 +688,7 @@ export function filterNFTBookListingInfo(bookInfo, isOwner = false) { mustClaimToView = false, hideDownload = false, enableCustomMessagePage, + tableOfContents, signedMessageText, enableSignatureImage, inLanguage, @@ -713,6 +714,7 @@ export function filterNFTBookListingInfo(bookInfo, isOwner = false) { mustClaimToView, hideDownload, enableCustomMessagePage, + tableOfContents, signedMessageText, enableSignatureImage, inLanguage, diff --git a/src/util/api/likernft/book/index.ts b/src/util/api/likernft/book/index.ts index c0aaf5d30..7c2e9d2af 100644 --- a/src/util/api/likernft/book/index.ts +++ b/src/util/api/likernft/book/index.ts @@ -130,6 +130,7 @@ export async function newNftBookInfo(classId, data, apiWalletOwnedNFTIds: string mustClaimToView, hideDownload, enableCustomMessagePage, + tableOfContents, inLanguage, name, @@ -185,6 +186,7 @@ export async function newNftBookInfo(classId, data, apiWalletOwnedNFTIds: string if (enableCustomMessagePage !== undefined) { payload.enableCustomMessagePage = enableCustomMessagePage; } + if (tableOfContents) payload.tableOfContents = tableOfContents; let batch = db.batch(); batch.create(likeNFTBookCollection.doc(classId), payload); if (apiWalletOwnedNFTIds.length) { @@ -289,6 +291,7 @@ export async function updateNftBookInfo(classId: string, { mustClaimToView, hideDownload, enableCustomMessagePage, + tableOfContents, }: { prices?: any[]; notificationEmails?: string[]; @@ -298,6 +301,7 @@ export async function updateNftBookInfo(classId: string, { mustClaimToView?: boolean; hideDownload?: boolean; enableCustomMessagePage?: boolean; + tableOfContents?: string; } = {}, newAPIWalletOwnedNFTIds: string[] = []) { await syncNFTBookInfoWithISCN(classId); @@ -317,6 +321,7 @@ export async function updateNftBookInfo(classId: string, { if (enableCustomMessagePage !== undefined) { payload.enableCustomMessagePage = enableCustomMessagePage; } + if (tableOfContents !== undefined) { payload.tableOfContents = tableOfContents; } const classIdRef = likeNFTBookCollection.doc(classId); let batch = db.batch(); batch.update(classIdRef, payload);