From f7e5a8cbfd62fcec04bc26628dccc656db720b55 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 7 Sep 2023 14:01:18 +0800 Subject: [PATCH 1/5] Increase unauthed rate limit --- packages/api/src/server.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/api/src/server.ts b/packages/api/src/server.ts index 886173432..7178cb427 100755 --- a/packages/api/src/server.ts +++ b/packages/api/src/server.ts @@ -107,14 +107,14 @@ export const createApp = (): { const apiLimiter = rateLimit({ windowMs: 60 * 1000, // 1 minute max: async (req) => { - // 100 RPM for an authenticated request, 5 for a non-authenticated request + // 100 RPM for an authenticated request, 15 for a non-authenticated request const token = getTokenByRequest(req) try { const claims = await getClaimsByToken(token) - return claims ? 100 : 5 + return claims ? 100 : 15 } catch (e) { console.log('non-authenticated request') - return 5 + return 15 } }, keyGenerator: (req) => { From 5ec5916cc87cb15857f73420258cfd56cc0e0e5d Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 7 Sep 2023 14:01:31 +0800 Subject: [PATCH 2/5] Increase cache time for text to speech data --- packages/text-to-speech/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/text-to-speech/src/index.ts b/packages/text-to-speech/src/index.ts index 821611ffb..992111ef7 100644 --- a/packages/text-to-speech/src/index.ts +++ b/packages/text-to-speech/src/index.ts @@ -347,12 +347,12 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction( } const audioDataString = audioData.toString('hex') - // save audio data to cache for 24 hours for mainly the newsletters + // save audio data to cache for 72 hours for mainly the newsletters await redisClient.set( cacheKey, JSON.stringify({ audioDataString, speechMarks }), { - EX: 3600 * 24, // in seconds + EX: 3600 * 72, // in seconds NX: true, } ) From 154b619d2db480d29b11c9f5316102c5e99d6f21 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 7 Sep 2023 14:04:51 +0800 Subject: [PATCH 3/5] Increase the debounce time on username validation --- packages/web/components/templates/ConfirmProfileModal.tsx | 2 +- packages/web/components/templates/auth/EmailSignup.tsx | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/web/components/templates/ConfirmProfileModal.tsx b/packages/web/components/templates/ConfirmProfileModal.tsx index a61766932..0c8e4387f 100644 --- a/packages/web/components/templates/ConfirmProfileModal.tsx +++ b/packages/web/components/templates/ConfirmProfileModal.tsx @@ -27,7 +27,7 @@ export function ConfirmProfileModal(): JSX.Element { setUsername(event.target.value) setTimeout(() => { setDebouncedUsername(event.target.value) - }, 400) + }, 2000) }, [] ) diff --git a/packages/web/components/templates/auth/EmailSignup.tsx b/packages/web/components/templates/auth/EmailSignup.tsx index 090c9f7ac..7913d2575 100644 --- a/packages/web/components/templates/auth/EmailSignup.tsx +++ b/packages/web/components/templates/auth/EmailSignup.tsx @@ -18,9 +18,8 @@ export function EmailSignup(): JSX.Element { const [password, setPassword] = useState() const [fullname, setFullname] = useState() const [username, setUsername] = useState() - const [debouncedUsername, setDebouncedUsername] = useState< - string | undefined - >() + const [debouncedUsername, setDebouncedUsername] = + useState() const [errorMessage, setErrorMessage] = useState() useEffect(() => { @@ -41,7 +40,7 @@ export function EmailSignup(): JSX.Element { setUsername(event.target.value) setTimeout(() => { setDebouncedUsername(event.target.value) - }, 400) + }, 2000) }, [] ) From b9cab3a87561604c4a63c36ac3c9745a79b496f9 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 7 Sep 2023 14:17:14 +0800 Subject: [PATCH 4/5] Change mobile debounce time for validate username --- .../main/java/app/omnivore/omnivore/ui/auth/LoginViewModel.kt | 2 +- .../Sources/App/Views/Registration/CreateProfileView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/auth/LoginViewModel.kt b/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/auth/LoginViewModel.kt index 05a452995..84937dbbb 100644 --- a/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/auth/LoginViewModel.kt +++ b/android/Omnivore/app/src/main/java/app/omnivore/omnivore/ui/auth/LoginViewModel.kt @@ -113,7 +113,7 @@ class LoginViewModel @Inject constructor( validateUsernameJob?.cancel() validateUsernameJob = viewModelScope.launch { - delay(500) + delay(2000) // Check the username requirements first if (potentialUsername.isEmpty()) { diff --git a/apple/OmnivoreKit/Sources/App/Views/Registration/CreateProfileView.swift b/apple/OmnivoreKit/Sources/App/Views/Registration/CreateProfileView.swift index 605da0dac..3f977b834 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Registration/CreateProfileView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Registration/CreateProfileView.swift @@ -95,7 +95,7 @@ import Views potentialUsername = profile.username $potentialUsername - .debounce(for: .seconds(0.5), scheduler: DispatchQueue.main) + .debounce(for: .seconds(2.0), scheduler: DispatchQueue.main) .sink(receiveValue: { [weak self] username in self?.validateUsername(username: username, dataService: dataService) }) From d0583bf271408967641b3347582b531df3d208a8 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 7 Sep 2023 14:49:48 +0800 Subject: [PATCH 5/5] Disable persisted queries in Apollo --- packages/api/src/apollo.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/api/src/apollo.ts b/packages/api/src/apollo.ts index 65435b78d..4ea00c319 100644 --- a/packages/api/src/apollo.ts +++ b/packages/api/src/apollo.ts @@ -109,6 +109,7 @@ export function makeApolloServer(): ApolloServer { return new Error('Unexpected server error') }, introspection: env.dev.isLocal, + persistedQueries: false, }) return apollo