From e37dd164ad1b6957ff4ffcca090d14f76427bce4 Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Wed, 13 Nov 2024 10:45:16 +0700 Subject: [PATCH] Revert "Revert "Turn off polling of non-priority feeds (#2167)" (#2170)" This reverts commit de3bd2eed5cb3abd275cded42dbda1342bcd2e9c. --- apps/passport-client/.env.example | 6 ++++++ apps/passport-client/build.ts | 14 ++++++++++++++ apps/passport-client/src/appConfig.ts | 10 +++++++++- apps/passport-client/src/dispatch.ts | 17 +++++++++++++---- turbo.json | 2 ++ 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/apps/passport-client/.env.example b/apps/passport-client/.env.example index 7bc4e57c2d..be27c545aa 100644 --- a/apps/passport-client/.env.example +++ b/apps/passport-client/.env.example @@ -55,3 +55,9 @@ DISABLE_CONSOLE_LOG= # Some origins are allowed to query Devcon tickets directly. Origins not in this list cannot do so: DEVCON_TICKET_QUERY_ORIGINS='["http://example.com", "http://localhost:3200"]' + +# If IGNORE_NON_PRIORITY_FEEDS=true, then non-priority feeds will be ignored. +IGNORE_NON_PRIORITY_FEEDS=false + +# URLs of feed providers that are priority feeds. +PRIORITY_FEED_PROVIDER_URLS='[]' diff --git a/apps/passport-client/build.ts b/apps/passport-client/build.ts index b4c464ffe5..911601d97c 100644 --- a/apps/passport-client/build.ts +++ b/apps/passport-client/build.ts @@ -87,6 +87,20 @@ const define = { process.env.DEVCON_TICKET_QUERY_ORIGINS ) } + : {}), + ...(process.env.IGNORE_NON_PRIORITY_FEEDS !== undefined + ? { + "process.env.IGNORE_NON_PRIORITY_FEEDS": JSON.stringify( + process.env.IGNORE_NON_PRIORITY_FEEDS + ) + } + : {}), + ...(process.env.PRIORITY_FEED_PROVIDER_URLS !== undefined + ? { + "process.env.PRIORITY_FEED_PROVIDER_URLS": JSON.stringify( + process.env.PRIORITY_FEED_PROVIDER_URLS + ) + } : {}) }; diff --git a/apps/passport-client/src/appConfig.ts b/apps/passport-client/src/appConfig.ts index 8b124b9503..d97c5aedfe 100644 --- a/apps/passport-client/src/appConfig.ts +++ b/apps/passport-client/src/appConfig.ts @@ -21,6 +21,10 @@ interface AppConfig { embeddedZapps: Record; // origins that are allowed to query Devcon tickets directly devconTicketQueryOrigins: string[]; + // If IGNORE_NON_PRIORITY_FEEDS=true, then non-priority feeds will be ignored. + ignoreNonPriorityFeeds: boolean; + // URLs of feed providers that are priority feeds. + priorityFeedProviderUrls: string[]; } if ( @@ -84,7 +88,11 @@ export const appConfig: AppConfig = { zappRestrictOrigins: process.env.ZAPP_RESTRICT_ORIGINS === "true", zappAllowedSignerOrigins: zappAllowedSignerOrigins, embeddedZapps: embeddedZapps, - devconTicketQueryOrigins: devconTicketQueryOrigins + devconTicketQueryOrigins: devconTicketQueryOrigins, + ignoreNonPriorityFeeds: process.env.IGNORE_NON_PRIORITY_FEEDS === "true", + priorityFeedProviderUrls: process.env.PRIORITY_FEED_PROVIDER_URLS + ? JSON.parse(process.env.PRIORITY_FEED_PROVIDER_URLS) + : [] }; console.log("App Config: " + JSON.stringify(appConfig)); diff --git a/apps/passport-client/src/dispatch.ts b/apps/passport-client/src/dispatch.ts index fc0f404dc7..d9b0d25a25 100644 --- a/apps/passport-client/src/dispatch.ts +++ b/apps/passport-client/src/dispatch.ts @@ -1160,14 +1160,23 @@ async function doSync( onSubscriptionResult, state.subscriptions .getActiveSubscriptions() - .filter( - (s) => - s.id !== + .filter((s) => { + if ( + s.id === state.subscriptions.findSubscription( ZUPASS_FEED_URL, ZupassFeedIds.Email )?.id - ) + ) { + return false; + } + + if (appConfig.ignoreNonPriorityFeeds) { + return appConfig.priorityFeedProviderUrls.includes(s.providerUrl); + } + + return true; + }) .map((s) => s.id) ); diff --git a/turbo.json b/turbo.json index 24c0ab35b1..5fafbc8b38 100644 --- a/turbo.json +++ b/turbo.json @@ -120,6 +120,8 @@ "DEVCON_TICKET_QUERY_ORIGINS", "GENERATED_CHUNKS", "TELEGRAM_CHAT_TO_PRODUCT_IDS", + "IGNORE_NON_PRIORITY_FEEDS", + "PRIORITY_FEED_PROVIDER_URLS", "//// add env vars above this line ////" ], "globalEnv": [