From 3663ee57f3e3d83a03ca105e0dda11cd94f68c98 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 14 Jun 2023 20:00:16 -0500 Subject: Add testnet warning (#880) * Add testnet warning * Add watermarks to posts * Call the test environment the Sandbox --- src/lib/constants.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/lib/constants.ts') diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 0a6956909..0a8c32cd6 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -10,6 +10,22 @@ export const MAX_GRAPHEME_LENGTH = 300 // but increasing limit per user feedback export const MAX_ALT_TEXT = 1000 +export function IS_LOCAL_DEV(url: string) { + return url.includes('localhost') +} + +export function IS_STAGING(url: string) { + return !IS_LOCAL_DEV(url) && !IS_PROD(url) +} + +export function IS_PROD(url: string) { + // NOTE + // until open federation, "production" is defined as the main server + // this definition will not work once federation is enabled! + // -prf + return url.startsWith('https://bsky.social') +} + export const PROD_TEAM_HANDLES = [ 'jay.bsky.social', 'pfrazee.com', @@ -43,14 +59,14 @@ export async function DEFAULT_FEEDS( serviceUrl: string, resolveHandle: (name: string) => Promise, ) { - if (serviceUrl.includes('localhost')) { + if (IS_LOCAL_DEV(serviceUrl)) { // local dev const aliceDid = await resolveHandle('alice.test') return { pinned: [`at://${aliceDid}/app.bsky.feed.generator/alice-favs`], saved: [`at://${aliceDid}/app.bsky.feed.generator/alice-favs`], } - } else if (serviceUrl.includes('staging')) { + } else if (IS_STAGING(serviceUrl)) { // staging return { pinned: [STAGING_DEFAULT_FEED('whats-hot')], @@ -90,9 +106,9 @@ export const STAGING_LINK_META_PROXY = export const PROD_LINK_META_PROXY = 'https://cardyb.bsky.app/v1/extract?url=' export function LINK_META_PROXY(serviceUrl: string) { - if (serviceUrl.includes('localhost')) { + if (IS_LOCAL_DEV(serviceUrl)) { return STAGING_LINK_META_PROXY - } else if (serviceUrl.includes('staging')) { + } else if (IS_STAGING(serviceUrl)) { return STAGING_LINK_META_PROXY } else { return PROD_LINK_META_PROXY -- cgit 1.4.1