From dca165f444574ca8e62899aee32afc6452f31f99 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 30 Oct 2024 20:48:34 +0800 Subject: [PATCH] Disable non-essential jobs --- packages/api/src/queue-processor.ts | 48 +++++++++---------- packages/api/src/services/create_user.ts | 4 ++ packages/db/migrate.ts | 2 +- .../components/elements/MaintenanceBanner.tsx | 45 ++++++++--------- .../web/components/templates/AuthLayout.tsx | 2 +- .../web/components/templates/LoginLayout.tsx | 9 ++-- .../components/templates/NavigationLayout.tsx | 2 +- .../templates/library/LibraryContainer.tsx | 11 +++-- .../templates/library/LibraryHeader.tsx | 3 ++ packages/web/pages/_document.tsx | 1 + packages/web/pages/auth/email-signup.tsx | 3 +- packages/web/pages/l/[section].tsx | 1 + 12 files changed, 70 insertions(+), 61 deletions(-) diff --git a/packages/api/src/queue-processor.ts b/packages/api/src/queue-processor.ts index 556809a646..87d38e8b6a 100644 --- a/packages/api/src/queue-processor.ts +++ b/packages/api/src/queue-processor.ts @@ -159,25 +159,25 @@ export const createWorker = (connection: ConnectionOptions) => async (job: Job) => { const executeJob = async (job: Job) => { switch (job.name) { - case 'refresh-all-feeds': { - const queue = await getQueue() - const counts = await queue?.getJobCounts('prioritized') - if (counts && counts.wait > 1000) { - return - } - return await refreshAllFeeds(appDataSource) - } - case 'refresh-feed': { - return await refreshFeed(job.data) - } + // case 'refresh-all-feeds': { + // const queue = await getQueue() + // const counts = await queue?.getJobCounts('prioritized') + // if (counts && counts.wait > 1000) { + // return + // } + // return await refreshAllFeeds(appDataSource) + // } + // case 'refresh-feed': { + // return await refreshFeed(job.data) + // } case 'save-page': { return savePageJob(job.data, job.attemptsMade) } case 'update-pdf-content': { return updatePDFContentJob(job.data) } - case THUMBNAIL_JOB: - return findThumbnail(job.data) + // case THUMBNAIL_JOB: + // return findThumbnail(job.data) case TRIGGER_RULE_JOB_NAME: return triggerRule(job.data) case UPDATE_LABELS_JOB: @@ -192,11 +192,11 @@ export const createWorker = (connection: ConnectionOptions) => return callWebhook(job.data) case EXPORT_ITEM_JOB_NAME: return exportItem(job.data) - case AI_SUMMARIZE_JOB_NAME: - return aiSummarize(job.data) - case PROCESS_YOUTUBE_VIDEO_JOB_NAME: - return processYouTubeVideo(job.data) - case PROCESS_YOUTUBE_TRANSCRIPT_JOB_NAME: + // case AI_SUMMARIZE_JOB_NAME: + // return aiSummarize(job.data) + // case PROCESS_YOUTUBE_VIDEO_JOB_NAME: + // return processYouTubeVideo(job.data) + // case PROCESS_YOUTUBE_TRANSCRIPT_JOB_NAME: return processYouTubeTranscript(job.data) case EXPORT_ALL_ITEMS_JOB_NAME: return exportAllItems(job.data) @@ -214,12 +214,12 @@ export const createWorker = (connection: ConnectionOptions) => return createDigest(job.data) case UPLOAD_CONTENT_JOB: return uploadContentJob(job.data) - case UPDATE_HOME_JOB: - return updateHome(job.data) - case SCORE_LIBRARY_ITEM_JOB: - return scoreLibraryItem(job.data) - case GENERATE_PREVIEW_CONTENT_JOB: - return generatePreviewContent(job.data) + // case UPDATE_HOME_JOB: + // return updateHome(job.data) + // case SCORE_LIBRARY_ITEM_JOB: + // return scoreLibraryItem(job.data) + // case GENERATE_PREVIEW_CONTENT_JOB: + // return generatePreviewContent(job.data) case PRUNE_TRASH_JOB: return pruneTrashJob(job.data) case EXPIRE_FOLDERS_JOB_NAME: diff --git a/packages/api/src/services/create_user.ts b/packages/api/src/services/create_user.ts index 00a06658bb..d16bfcd1bf 100644 --- a/packages/api/src/services/create_user.ts +++ b/packages/api/src/services/create_user.ts @@ -61,6 +61,10 @@ export const createUser = async (input: { return [existingUser, profile] } + if (process.env.SIGNUP_CLOSED) { + return Promise.reject({ errorCode: SignupErrorCode.AccessDenied }) + } + if (!validateUsername(input.username)) { return Promise.reject({ errorCode: SignupErrorCode.InvalidUsername }) } diff --git a/packages/db/migrate.ts b/packages/db/migrate.ts index f4867b3faa..7e2961a8b2 100755 --- a/packages/db/migrate.ts +++ b/packages/db/migrate.ts @@ -52,7 +52,7 @@ const postgrator = new Postgrator({ // Schema table name schemaTable: 'schemaversion', // Validate migration md5 checksum to ensure the contents of the script have not changed - validateChecksums: true, + validateChecksums: false, }) log('Starting migration manager') diff --git a/packages/web/components/elements/MaintenanceBanner.tsx b/packages/web/components/elements/MaintenanceBanner.tsx index fd24c743a6..abce57548f 100644 --- a/packages/web/components/elements/MaintenanceBanner.tsx +++ b/packages/web/components/elements/MaintenanceBanner.tsx @@ -2,41 +2,34 @@ import { usePersistedState } from '../../lib/hooks/usePersistedState' import { CloseButton } from './CloseButton' import { HStack, SpanBox } from './LayoutPrimitives' -export const MaintenanceBanner = () => { +export const AnnouncementBanner = () => { const [ showMaintenanceMode, setShowMaintenanceMode, isLoadingShowMaintenanceMode, ] = usePersistedState({ - key: 'show-maintenance-mode', + key: 'show-maintenance-mode-03', isSessionStorage: false, - initialValue: false, + initialValue: true, }) return ( <> - {!isLoadingShowMaintenanceMode && showMaintenanceMode && ( - - Omnivore will be undergoing maintenance for 30 minutes at 05:00 UTC, - during that time the website and APIs will be unavailable. - - { - setShowMaintenanceMode(false) - }} - /> - - )} + + Omnivore is joining ElevenLabs and will be shutting down the free hosted + version. Read more here. + ) } diff --git a/packages/web/components/templates/AuthLayout.tsx b/packages/web/components/templates/AuthLayout.tsx index 5b945b903f..dbf2bc2da4 100644 --- a/packages/web/components/templates/AuthLayout.tsx +++ b/packages/web/components/templates/AuthLayout.tsx @@ -1,5 +1,5 @@ import { Box, VStack, HStack } from '../elements/LayoutPrimitives' -import { MaintenanceBanner } from '../elements/MaintenanceBanner' +import { AnnouncementBanner } from '../elements/MaintenanceBanner' import { OmnivoreNameLogo } from '../elements/images/OmnivoreNameLogo' import { theme } from '../tokens/stitches.config' import { GoogleReCaptchaProvider } from '@google-recaptcha/react' diff --git a/packages/web/components/templates/LoginLayout.tsx b/packages/web/components/templates/LoginLayout.tsx index 4b6819bc2e..1b1a203836 100644 --- a/packages/web/components/templates/LoginLayout.tsx +++ b/packages/web/components/templates/LoginLayout.tsx @@ -3,6 +3,7 @@ import { Box, HStack, MediumBreakpointBox, + SpanBox, VStack, } from '../elements/LayoutPrimitives' import { LoginForm } from './LoginForm' @@ -10,7 +11,7 @@ import type { LoginFormProps } from './LoginForm' import { OmnivoreNameLogo } from '../elements/images/OmnivoreNameLogo' import featureFullWidthImage from '../../public/static/images/login/login-feature-image-full.png' -import { MaintenanceBanner } from '../elements/MaintenanceBanner' +import { AnnouncementBanner } from '../elements/MaintenanceBanner' export function LoginLayout(props: LoginFormProps): JSX.Element { return ( @@ -20,11 +21,12 @@ export function LoginLayout(props: LoginFormProps): JSX.Element { largerLayoutNode={} /> - - + ) } diff --git a/packages/web/components/templates/NavigationLayout.tsx b/packages/web/components/templates/NavigationLayout.tsx index 9e640434ef..fb265a8f75 100644 --- a/packages/web/components/templates/NavigationLayout.tsx +++ b/packages/web/components/templates/NavigationLayout.tsx @@ -23,7 +23,7 @@ import { useGetViewer } from '../../lib/networking/viewer/useGetViewer' import { useQueryClient } from '@tanstack/react-query' import { usePersistedState } from '../../lib/hooks/usePersistedState' import { CloseButton } from '../elements/CloseButton' -import { MaintenanceBanner } from '../elements/MaintenanceBanner' +import { AnnouncementBanner } from '../elements/MaintenanceBanner' export type NavigationSection = | 'home' diff --git a/packages/web/components/templates/library/LibraryContainer.tsx b/packages/web/components/templates/library/LibraryContainer.tsx index 6120c357a2..882406ec79 100644 --- a/packages/web/components/templates/library/LibraryContainer.tsx +++ b/packages/web/components/templates/library/LibraryContainer.tsx @@ -55,6 +55,7 @@ import { State } from '../../../lib/networking/fragments/articleFragment' import { useHandleAddUrl } from '../../../lib/hooks/useHandleAddUrl' import { useGetViewer } from '../../../lib/networking/viewer/useGetViewer' import { Spinner } from '@phosphor-icons/react/dist/ssr' +import { AnnouncementBanner } from '../../elements/MaintenanceBanner' export type LayoutType = 'LIST_LAYOUT' | 'GRID_LAYOUT' @@ -93,11 +94,13 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element { const gridContainerRef = useRef(null) - const [labelsTarget, setLabelsTarget] = - useState(undefined) + const [labelsTarget, setLabelsTarget] = useState( + undefined + ) - const [notebookTarget, setNotebookTarget] = - useState(undefined) + const [notebookTarget, setNotebookTarget] = useState( + undefined + ) const [showAddLinkModal, setShowAddLinkModal] = useState(false) const [showEditTitleModal, setShowEditTitleModal] = useState(false) diff --git a/packages/web/components/templates/library/LibraryHeader.tsx b/packages/web/components/templates/library/LibraryHeader.tsx index d9559ce53d..59ba294a61 100644 --- a/packages/web/components/templates/library/LibraryHeader.tsx +++ b/packages/web/components/templates/library/LibraryHeader.tsx @@ -17,6 +17,7 @@ import { MultiSelectControls, CheckBoxButton, } from '../homeFeed/MultiSelectControls' +import { AnnouncementBanner } from '../../elements/MaintenanceBanner' export type MultiSelectMode = 'off' | 'none' | 'some' | 'visible' | 'search' @@ -74,6 +75,8 @@ export function LibraryHeader(props: LibraryHeaderProps): JSX.Element { }, }} > + + diff --git a/packages/web/pages/_document.tsx b/packages/web/pages/_document.tsx index bed2d46846..49285d3356 100644 --- a/packages/web/pages/_document.tsx +++ b/packages/web/pages/_document.tsx @@ -3,6 +3,7 @@ import NextDocument, { Html, Head, Main, NextScript } from 'next/document' import { getCssText, globalStyles } from '../components/tokens/stitches.config' import { Toaster } from 'react-hot-toast' +import { AnnouncementBanner } from '../components/elements/MaintenanceBanner' export default class Document extends NextDocument { render() { diff --git a/packages/web/pages/auth/email-signup.tsx b/packages/web/pages/auth/email-signup.tsx index e71d335dac..0dd16a19e7 100644 --- a/packages/web/pages/auth/email-signup.tsx +++ b/packages/web/pages/auth/email-signup.tsx @@ -6,7 +6,8 @@ export default function EmailRegistrationPage(): JSX.Element { return ( - + Sign ups for Omnivore are currently closed. If you already have an account + you can login here. ) } diff --git a/packages/web/pages/l/[section].tsx b/packages/web/pages/l/[section].tsx index d1e0935d8e..b27b1790a9 100644 --- a/packages/web/pages/l/[section].tsx +++ b/packages/web/pages/l/[section].tsx @@ -10,6 +10,7 @@ import { useMemo } from 'react' import { HighlightsContainer } from '../../components/nav-containers/HighlightsContainer' import { usePersistedState } from '../../lib/hooks/usePersistedState' import { State } from '../../lib/networking/fragments/articleFragment' +import { AnnouncementBanner } from '../../components/elements/MaintenanceBanner' export default function Home(): JSX.Element { const router = useRouter()