aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/lib/attachments.ts
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-10-06 14:33:40 +0000
committerMohamedBassem <me@mbassem.com>2024-10-06 15:51:45 +0000
commit1e5c575e16c8a9e6bd7592e83bea53af7f359e15 (patch)
treed706b7d0dad309e1c4e5ede15fcae8a5e2547c8a /packages/trpc/lib/attachments.ts
parentdb2d346cd6c265d8e7c69383c6de03bf5f6252f0 (diff)
downloadkarakeep-1e5c575e16c8a9e6bd7592e83bea53af7f359e15.tar.zst
refactor: Start tracking bookmark assets in the assets table
Diffstat (limited to 'packages/trpc/lib/attachments.ts')
-rw-r--r--packages/trpc/lib/attachments.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/trpc/lib/attachments.ts b/packages/trpc/lib/attachments.ts
index 6fe1ef40..175947f8 100644
--- a/packages/trpc/lib/attachments.ts
+++ b/packages/trpc/lib/attachments.ts
@@ -8,6 +8,8 @@ export function mapDBAssetTypeToUserType(assetType: AssetTypes): ZAssetType {
[AssetTypes.LINK_SCREENSHOT]: "screenshot",
[AssetTypes.LINK_FULL_PAGE_ARCHIVE]: "fullPageArchive",
[AssetTypes.LINK_BANNER_IMAGE]: "bannerImage",
+ [AssetTypes.BOOKMARK_ASSET]: "bookmarkAsset",
+ [AssetTypes.UNKNOWN]: "bannerImage",
};
return map[assetType];
}
@@ -19,6 +21,8 @@ export function mapSchemaAssetTypeToDB(
screenshot: AssetTypes.LINK_SCREENSHOT,
fullPageArchive: AssetTypes.LINK_FULL_PAGE_ARCHIVE,
bannerImage: AssetTypes.LINK_BANNER_IMAGE,
+ bookmarkAsset: AssetTypes.BOOKMARK_ASSET,
+ unknown: AssetTypes.UNKNOWN,
};
return map[assetType];
}
@@ -28,6 +32,8 @@ export function humanFriendlyNameForAssertType(type: ZAssetType) {
screenshot: "Screenshot",
fullPageArchive: "Full Page Archive",
bannerImage: "Banner Image",
+ bookmarkAsset: "Bookmark Asset",
+ unknown: "Unknown",
};
return map[type];
}
@@ -37,6 +43,19 @@ export function isAllowedToAttachAsset(type: ZAssetType) {
screenshot: true,
fullPageArchive: false,
bannerImage: true,
+ bookmarkAsset: false,
+ unknown: false,
+ };
+ return map[type];
+}
+
+export function isAllowedToDetachAsset(type: ZAssetType) {
+ const map: Record<ZAssetType, boolean> = {
+ screenshot: true,
+ fullPageArchive: true,
+ bannerImage: true,
+ bookmarkAsset: false,
+ unknown: false,
};
return map[type];
}