diff --git a/packages/app/src/Element/Note.tsx b/packages/app/src/Element/Note.tsx index 6565856e..d7feb1bb 100644 --- a/packages/app/src/Element/Note.tsx +++ b/packages/app/src/Element/Note.tsx @@ -83,6 +83,7 @@ export default function Note(props: NoteProps) { const { pinned, bookmarked } = useSelector((s: RootState) => s.login); const publisher = useEventPublisher(); const [translated, setTranslated] = useState(); + const [contentWarningAccepted, setContentWarningAccepted] = useState(false); const { formatMessage } = useIntl(); const reactions = useMemo(() => getReactions(related, ev.id, EventKind.Reaction), [related, ev]); const groupReactions = useMemo(() => { @@ -161,8 +162,32 @@ export default function Note(props: NoteProps) { ); } + const contentWarning = ev.tags.find(a => a[0] === "content-warning"); + if (contentWarning && !contentWarningAccepted) { + return ( +
{ + e.stopPropagation(); + setContentWarningAccepted(true); + }}> + + {contentWarning[1] && ( + <> +
+ + + )} +
+ ); + } return ; - }, [ev]); + }, [ev, contentWarningAccepted]); useLayoutEffect(() => { if (entry && inView && extendable === false) { diff --git a/packages/app/src/Element/NoteCreator.tsx b/packages/app/src/Element/NoteCreator.tsx index 34b65919..98b01dfa 100644 --- a/packages/app/src/Element/NoteCreator.tsx +++ b/packages/app/src/Element/NoteCreator.tsx @@ -49,6 +49,7 @@ export function NoteCreator(props: NoteCreatorProps) { const [preview, setPreview] = useState(); const [showAdvanced, setShowAdvanced] = useState(false); const [zapForward, setZapForward] = useState(""); + const [sensitive, setSensitiveContent] = useState(); const uploader = useFileUpload(); async function sendNote() { @@ -68,6 +69,10 @@ export function NoteCreator(props: NoteCreatorProps) { return; } } + if (sensitive) { + extraTags ??= []; + extraTags.push(["content-warning", sensitive]); + } const ev = replyTo ? await publisher.reply(replyTo, note, extraTags) : await publisher.note(note, extraTags); console.debug("Sending note: ", ev); publisher.broadcast(ev); @@ -192,6 +197,9 @@ export function NoteCreator(props: NoteCreatorProps) {

+ + + setZapForward(e.target.value)} /> +

+ +

+

+ +

+ + + +
+ setSensitiveContent(e.target.value)} + maxLength={50} + minLength={1} + placeholder={formatMessage({ + defaultMessage: "Reason", + })} + /> +
)} diff --git a/packages/app/src/index.css b/packages/app/src/index.css index 0624496d..e2018fc9 100644 --- a/packages/app/src/index.css +++ b/packages/app/src/index.css @@ -12,6 +12,7 @@ --highlight: #8b5cf6; --error: #ff6053; --success: #2ad544; + --warning: #ff8800; --gray-superlight: #eee; --gray-light: #999; @@ -480,6 +481,10 @@ body.scroll-lock { color: var(--error); } +.warning { + color: var(--warning); +} + .bg-error { background-color: var(--error); } diff --git a/packages/app/src/lang.json b/packages/app/src/lang.json index 806dd221..52277cc9 100644 --- a/packages/app/src/lang.json +++ b/packages/app/src/lang.json @@ -199,6 +199,9 @@ "Adk34V": { "defaultMessage": "Setup your Profile" }, + "AkCxS/": { + "defaultMessage": "Reason" + }, "AnLrRC": { "defaultMessage": "Non-Zap", "description": "Non-Zap, Regular LN payment" @@ -372,6 +375,9 @@ "KAhAcM": { "defaultMessage": "Enter LNDHub config" }, + "KLo3SP": { + "defaultMessage": "Reason: {reason}" + }, "KQvWvD": { "defaultMessage": "Deleted" }, @@ -518,6 +524,9 @@ "UQ3pOC": { "defaultMessage": "On Nostr, many people have the same username. User names and identity are separate things. You can get a unique identifier in the next step." }, + "UUPFlt": { + "defaultMessage": "Users must accept the content warning to show the content of your note." + }, "Up5U7K": { "defaultMessage": "Block" }, @@ -594,6 +603,9 @@ "aWpBzj": { "defaultMessage": "Show more" }, + "bQdA2k": { + "defaultMessage": "Sensitive Content" + }, "brAXSu": { "defaultMessage": "Pick a username" }, @@ -672,6 +684,9 @@ "gDzDRs": { "defaultMessage": "Emoji to send when reactiong to a note" }, + "gXgY3+": { + "defaultMessage": "Not all clients support this yet" + }, "gjBiyj": { "defaultMessage": "Loading..." }, @@ -947,6 +962,9 @@ "wvFw6Y": { "defaultMessage": "Hey, it looks like you dont have a NIP-05 handle yet, you should get one! Check out {link}" }, + "x/q8d5": { + "defaultMessage": "This note has been marked as sensitive, click here to reveal" + }, "x82IOl": { "defaultMessage": "Mute" }, diff --git a/packages/app/src/translations/en.json b/packages/app/src/translations/en.json index 01e73d67..52d26f2f 100644 --- a/packages/app/src/translations/en.json +++ b/packages/app/src/translations/en.json @@ -64,6 +64,7 @@ "ADmfQT": "Parent", "ASRK0S": "This author has been muted", "Adk34V": "Setup your Profile", + "AkCxS/": "Reason", "AnLrRC": "Non-Zap", "AyGauy": "Login", "B4C47Y": "name too short", @@ -121,6 +122,7 @@ "K3r6DQ": "Delete", "K7AkdL": "Show", "KAhAcM": "Enter LNDHub config", + "KLo3SP": "Reason: {reason}", "KQvWvD": "Deleted", "KWuDfz": "I have saved my keys, continue", "KahimY": "Unknown event kind: {kind}", @@ -168,6 +170,7 @@ "TpgeGw": "Hex Salt..", "UDYlxu": "Pending Subscriptions", "UQ3pOC": "On Nostr, many people have the same username. User names and identity are separate things. You can get a unique identifier in the next step.", + "UUPFlt": "Users must accept the content warning to show the content of your note.", "Up5U7K": "Block", "VBadwB": "Hmm, can't find a key manager extension.. try reloading the page.", "VN0+Fz": "Balance: {amount} sats", @@ -193,6 +196,7 @@ "ZUZedV": "Lightning Donation:", "a5UPxh": "Fund developers and platforms providing NIP-05 verification services", "aWpBzj": "Show more", + "bQdA2k": "Sensitive Content", "brAXSu": "Pick a username", "bxv59V": "Just now", "c+oiJe": "Install Extension", @@ -218,6 +222,7 @@ "gBdUXk": "Save your keys!", "gDZkld": "Snort is a Nostr UI, nostr is a decentralised protocol for saving and distributing \"notes\".", "gDzDRs": "Emoji to send when reactiong to a note", + "gXgY3+": "Not all clients support this yet", "gjBiyj": "Loading...", "h8XMJL": "Badges", "hCUivF": "Notes will stream in real time into global and posts tab", @@ -308,6 +313,7 @@ "wqyN/i": "Find out more info about {service} at {link}", "wtLjP6": "Copy ID", "wvFw6Y": "Hey, it looks like you dont have a NIP-05 handle yet, you should get one! Check out {link}", + "x/q8d5": "This note has been marked as sensitive, click here to reveal", "x82IOl": "Mute", "xIoGG9": "Go to", "xJ9n2N": "Your public key",