From f30c0663052cb2f47bcfe18a8414ee1579fa5ef2 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sat, 3 Jun 2023 23:21:10 +0500 Subject: [PATCH] mobile: add file size limits --- apps/mobile/app/screens/editor/tiptap/picker.js | 3 +-- apps/mobile/app/utils/constants.js | 2 ++ apps/mobile/native/ios/Make Note/Info.plist | 2 ++ apps/mobile/native/ios/Notesnook/Info.plist | 2 ++ apps/mobile/share/share.js | 7 +++++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/mobile/app/screens/editor/tiptap/picker.js b/apps/mobile/app/screens/editor/tiptap/picker.js index 4e0f738eb..c97b58d77 100644 --- a/apps/mobile/app/screens/editor/tiptap/picker.js +++ b/apps/mobile/app/screens/editor/tiptap/picker.js @@ -35,8 +35,7 @@ import PremiumService from "../../../services/premium"; import { eCloseSheet } from "../../../utils/events"; import { editorController, editorState } from "./utils"; import { isImage } from "@notesnook/core/utils/filename"; -const FILE_SIZE_LIMIT = 500 * 1024 * 1024; -const IMAGE_SIZE_LIMIT = 50 * 1024 * 1024; +import { FILE_SIZE_LIMIT, IMAGE_SIZE_LIMIT } from "../../../utils/constants"; const showEncryptionSheet = (file) => { presentSheet({ diff --git a/apps/mobile/app/utils/constants.js b/apps/mobile/app/utils/constants.js index f41589989..8fe1c3065 100644 --- a/apps/mobile/app/utils/constants.js +++ b/apps/mobile/app/utils/constants.js @@ -21,6 +21,8 @@ import { Platform } from "react-native"; import { Monographs } from "../screens/notes/monographs"; export const IOS_APPGROUPID = "group.org.streetwriters.notesnook"; +export const FILE_SIZE_LIMIT = 500 * 1024 * 1024; +export const IMAGE_SIZE_LIMIT = 50 * 1024 * 1024; export const STORE_LINK = Platform.OS === "ios" diff --git a/apps/mobile/native/ios/Make Note/Info.plist b/apps/mobile/native/ios/Make Note/Info.plist index da796a9b3..2cfe5067c 100644 --- a/apps/mobile/native/ios/Make Note/Info.plist +++ b/apps/mobile/native/ios/Make Note/Info.plist @@ -63,5 +63,7 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + appGroupId + group.org.streetwriters.notesnook diff --git a/apps/mobile/native/ios/Notesnook/Info.plist b/apps/mobile/native/ios/Notesnook/Info.plist index 67cf00624..0d758e538 100644 --- a/apps/mobile/native/ios/Notesnook/Info.plist +++ b/apps/mobile/native/ios/Notesnook/Info.plist @@ -151,5 +151,7 @@ + appGroupId + group.org.streetwriters.notesnook diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.js index 273ed20eb..e959c9cec 100644 --- a/apps/mobile/share/share.js +++ b/apps/mobile/share/share.js @@ -52,6 +52,7 @@ import { Search } from "./search"; import { initDatabase, useShareStore } from "./store"; import { isImage } from "@notesnook/core/utils/filename"; import { NoteBundle } from "../app/utils/note-bundle"; +import { FILE_SIZE_LIMIT, IMAGE_SIZE_LIMIT } from "../app/utils/constants"; const getLinkPreview = (url) => { return getPreviewData(url, 5000); @@ -280,6 +281,12 @@ const ShareView = ({ quicknote = false }) => { } else { const user = await db.user.getUser(); if (user && user.subscription.type !== 0) { + if ( + (isImage(item.type) && item.size > IMAGE_SIZE_LIMIT) || + (!isImage(item.type) && item.size > FILE_SIZE_LIMIT) + ) + continue; + setRawFiles((files) => { const index = files.findIndex((file) => file.name === item.name); if (index === -1) {