From d44e4c1a943fe00bf993029c6ebab3a7714da028 Mon Sep 17 00:00:00 2001 From: Kieran Date: Sun, 6 Aug 2023 15:35:39 +0100 Subject: [PATCH] Open NSFW streams on xxx host --- package.json | 3 ++- src/d.ts | 1 + src/element/new-stream.tsx | 12 ++++++++---- webpack.config.js | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 64c7716..160e607 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,8 @@ "scripts": { "start": "webpack serve", "build": "webpack --node-env=production", - "deploy": "npx wrangler pages publish build" + "deploy": "yarn build && npx wrangler pages publish build", + "deploy:xxzap": "__XXX='true' && yarn build && npx wrangler pages publish --project-name xxzap build" }, "eslintConfig": { "extends": [ diff --git a/src/d.ts b/src/d.ts index d90a39f..6acc4b6 100644 --- a/src/d.ts +++ b/src/d.ts @@ -2,6 +2,7 @@ /// declare const __XXX: boolean; +declare const __XXX_HOST: string; declare module "*.jpg" { const value: unknown; diff --git a/src/element/new-stream.tsx b/src/element/new-stream.tsx index d877c97..49db756 100644 --- a/src/element/new-stream.tsx +++ b/src/element/new-stream.tsx @@ -7,7 +7,7 @@ import { StreamProvider, StreamProviders } from "providers"; import { useEffect, useState } from "react"; import { StreamEditor, StreamEditorProps } from "./stream-editor"; import { useNavigate } from "react-router-dom"; -import { eventLink } from "utils"; +import { eventLink, findTag } from "utils"; import { NostrProviderDialog } from "./nostr-provider-dialog"; function NewStream({ ev, onFinish }: StreamEditorProps) { @@ -35,9 +35,13 @@ function NewStream({ ev, onFinish }: StreamEditorProps) { onFinish={(ex) => { currentProvider.updateStreamInfo(ex); if (!ev) { - navigate(`/${eventLink(ex)}`, { - state: ev, - }); + if (findTag(ex, "content-warning") && __XXX_HOST) { + location.href = `${__XXX_HOST}/${eventLink(ex)}`; + } else { + navigate(`/${eventLink(ex)}`, { + state: ev, + }); + } } else { onFinish?.(ev); } diff --git a/webpack.config.js b/webpack.config.js index b86e765..c9b2477 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -67,7 +67,8 @@ const config = { contextRegExp: /moment$/, }), new webpack.DefinePlugin({ - __XXX: process.env["__XXX"] || JSON.stringify(false) + __XXX: process.env["__XXX"] || JSON.stringify(false), + __XXX_HOST: JSON.stringify("https://xxzap.com") }) ], module: {