mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-05-21 01:12:03 +00:00
Good stuff
This commit is contained in:
parent
a0a9b9fcc8
commit
b800ab3b88
@ -11,7 +11,7 @@ import { useRouter } from "next/router";
|
|||||||
import { formatTimestampToHowLongAgo } from "@/utils/time";
|
import { formatTimestampToHowLongAgo } from "@/utils/time";
|
||||||
import { ProgressSpinner } from "primereact/progressspinner";
|
import { ProgressSpinner } from "primereact/progressspinner";
|
||||||
import GenericButton from "@/components/buttons/GenericButton";
|
import GenericButton from "@/components/buttons/GenericButton";
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
export function CourseTemplate({ course }) {
|
export function CourseTemplate({ course }) {
|
||||||
const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: course });
|
const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: course });
|
||||||
@ -41,7 +41,7 @@ export function CourseTemplate({ course }) {
|
|||||||
pubkey: course.pubkey,
|
pubkey: course.pubkey,
|
||||||
kind: course.kind,
|
kind: course.kind,
|
||||||
identifier: course.id,
|
identifier: course.id,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
setNAddress(nAddress);
|
setNAddress(nAddress);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import { formatTimestampToHowLongAgo } from "@/utils/time";
|
|||||||
import { nip19 } from "nostr-tools";
|
import { nip19 } from "nostr-tools";
|
||||||
import { Tag } from "primereact/tag";
|
import { Tag } from "primereact/tag";
|
||||||
import GenericButton from "@/components/buttons/GenericButton";
|
import GenericButton from "@/components/buttons/GenericButton";
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
export function DocumentTemplate({ document }) {
|
export function DocumentTemplate({ document }) {
|
||||||
const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: document });
|
const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: document });
|
||||||
@ -25,7 +25,7 @@ export function DocumentTemplate({ document }) {
|
|||||||
pubkey: document.pubkey,
|
pubkey: document.pubkey,
|
||||||
kind: document.kind,
|
kind: document.kind,
|
||||||
identifier: document.id,
|
identifier: document.id,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
setNAddress(nAddress);
|
setNAddress(nAddress);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import { nip19 } from "nostr-tools";
|
|||||||
import { formatTimestampToHowLongAgo } from "@/utils/time";
|
import { formatTimestampToHowLongAgo } from "@/utils/time";
|
||||||
import { Tag } from "primereact/tag";
|
import { Tag } from "primereact/tag";
|
||||||
import GenericButton from "@/components/buttons/GenericButton";
|
import GenericButton from "@/components/buttons/GenericButton";
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
export function VideoTemplate({ video }) {
|
export function VideoTemplate({ video }) {
|
||||||
const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: video });
|
const { zaps, zapsLoading, zapsError } = useZapsSubscription({ event: video });
|
||||||
@ -26,7 +26,7 @@ export function VideoTemplate({ video }) {
|
|||||||
pubkey: video.pubkey,
|
pubkey: video.pubkey,
|
||||||
kind: video.kind,
|
kind: video.kind,
|
||||||
identifier: video.id,
|
identifier: video.id,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
})
|
})
|
||||||
setNAddress(addr);
|
setNAddress(addr);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import { findKind0Fields } from '@/utils/nostr';
|
|||||||
import 'primeicons/primeicons.css';
|
import 'primeicons/primeicons.css';
|
||||||
import CoursePaymentButton from "@/components/bitcoinConnect/CoursePaymentButton";
|
import CoursePaymentButton from "@/components/bitcoinConnect/CoursePaymentButton";
|
||||||
import { ProgressSpinner } from 'primereact/progressspinner';
|
import { ProgressSpinner } from 'primereact/progressspinner';
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
import useWindowWidth from '@/hooks/useWindowWidth';
|
import useWindowWidth from '@/hooks/useWindowWidth';
|
||||||
|
|
||||||
const MDDisplay = dynamic(
|
const MDDisplay = dynamic(
|
||||||
@ -69,7 +69,7 @@ export default function CourseDetails({ processedEvent, paidCourse, lessons, dec
|
|||||||
pubkey: processedEvent.pubkey,
|
pubkey: processedEvent.pubkey,
|
||||||
kind: processedEvent.kind,
|
kind: processedEvent.kind,
|
||||||
identifier: processedEvent.d,
|
identifier: processedEvent.d,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
setNAddress(naddr);
|
setNAddress(naddr);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import { useSession } from 'next-auth/react';
|
|||||||
import useWindowWidth from "@/hooks/useWindowWidth";
|
import useWindowWidth from "@/hooks/useWindowWidth";
|
||||||
import { useNDKContext } from "@/context/NDKContext";
|
import { useNDKContext } from "@/context/NDKContext";
|
||||||
import { findKind0Fields } from '@/utils/nostr';
|
import { findKind0Fields } from '@/utils/nostr';
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
import { ProgressSpinner } from 'primereact/progressspinner';
|
import { ProgressSpinner } from 'primereact/progressspinner';
|
||||||
|
|
||||||
const lnAddress = process.env.NEXT_PUBLIC_LIGHTNING_ADDRESS;
|
const lnAddress = process.env.NEXT_PUBLIC_LIGHTNING_ADDRESS;
|
||||||
@ -49,7 +49,7 @@ export default function CourseDetailsNew({ processedEvent, paidCourse, lessons,
|
|||||||
pubkey: processedEvent.pubkey,
|
pubkey: processedEvent.pubkey,
|
||||||
kind: processedEvent.kind,
|
kind: processedEvent.kind,
|
||||||
identifier: processedEvent.d,
|
identifier: processedEvent.d,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
setNAddress(naddr);
|
setNAddress(naddr);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import { Divider } from "primereact/divider";
|
|||||||
import { getTotalFromZaps } from "@/utils/lightning";
|
import { getTotalFromZaps } from "@/utils/lightning";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import useWindowWidth from "@/hooks/useWindowWidth";
|
import useWindowWidth from "@/hooks/useWindowWidth";
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
const MDDisplay = dynamic(
|
const MDDisplay = dynamic(
|
||||||
() => import("@uiw/react-markdown-preview"),
|
() => import("@uiw/react-markdown-preview"),
|
||||||
@ -39,7 +39,7 @@ const DocumentLesson = ({ lesson, course, decryptionPerformed, isPaid }) => {
|
|||||||
pubkey: lesson.pubkey,
|
pubkey: lesson.pubkey,
|
||||||
kind: lesson.kind,
|
kind: lesson.kind,
|
||||||
identifier: lesson.d,
|
identifier: lesson.d,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
})
|
})
|
||||||
setNAddress(addr);
|
setNAddress(addr);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import { findKind0Fields } from '@/utils/nostr';
|
|||||||
import { useToast } from '@/hooks/useToast';
|
import { useToast } from '@/hooks/useToast';
|
||||||
import { formatDateTime } from '@/utils/time';
|
import { formatDateTime } from '@/utils/time';
|
||||||
import { validateEvent } from '@/utils/nostr';
|
import { validateEvent } from '@/utils/nostr';
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
import 'primeicons/primeicons.css';
|
import 'primeicons/primeicons.css';
|
||||||
|
|
||||||
const MDDisplay = dynamic(
|
const MDDisplay = dynamic(
|
||||||
@ -110,7 +110,7 @@ export default function DraftCourseDetails({ processedEvent, draftId, lessons })
|
|||||||
pubkey: resource.pubkey,
|
pubkey: resource.pubkey,
|
||||||
kind: resource.kind,
|
kind: resource.kind,
|
||||||
identifier: dTag,
|
identifier: dTag,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
|
|
||||||
const userResponse = await axios.get(`/api/users/${user.pubkey}`);
|
const userResponse = await axios.get(`/api/users/${user.pubkey}`);
|
||||||
|
@ -9,7 +9,7 @@ import { nip19 } from "nostr-tools";
|
|||||||
import { getTotalFromZaps } from "@/utils/lightning";
|
import { getTotalFromZaps } from "@/utils/lightning";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import { Divider } from "primereact/divider";
|
import { Divider } from "primereact/divider";
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
import useWindowWidth from "@/hooks/useWindowWidth";
|
import useWindowWidth from "@/hooks/useWindowWidth";
|
||||||
|
|
||||||
const MDDisplay = dynamic(
|
const MDDisplay = dynamic(
|
||||||
@ -38,7 +38,7 @@ const VideoLesson = ({ lesson, course, decryptionPerformed, isPaid }) => {
|
|||||||
pubkey: lesson.pubkey,
|
pubkey: lesson.pubkey,
|
||||||
kind: lesson.kind,
|
kind: lesson.kind,
|
||||||
identifier: lesson.d,
|
identifier: lesson.d,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
setNAddress(addr);
|
setNAddress(addr);
|
||||||
}, [lesson]);
|
}, [lesson]);
|
||||||
|
@ -5,7 +5,7 @@ import { useImageProxy } from "@/hooks/useImageProxy";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { nip19 } from "nostr-tools";
|
import { nip19 } from "nostr-tools";
|
||||||
import { Divider } from 'primereact/divider';
|
import { Divider } from 'primereact/divider';
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
|
|
||||||
const ContentListItem = (content) => {
|
const ContentListItem = (content) => {
|
||||||
@ -24,7 +24,7 @@ const ContentListItem = (content) => {
|
|||||||
identifier: content.id,
|
identifier: content.id,
|
||||||
kind: content.kind,
|
kind: content.kind,
|
||||||
pubkey: content.pubkey,
|
pubkey: content.pubkey,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
router.push(`/course/${nAddress}`);
|
router.push(`/course/${nAddress}`);
|
||||||
} else if (isDraftCourse) {
|
} else if (isDraftCourse) {
|
||||||
@ -34,7 +34,7 @@ const ContentListItem = (content) => {
|
|||||||
identifier: content.id,
|
identifier: content.id,
|
||||||
kind: content.kind,
|
kind: content.kind,
|
||||||
pubkey: content.pubkey,
|
pubkey: content.pubkey,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
router.push(`/details/${nAddress}`);
|
router.push(`/details/${nAddress}`);
|
||||||
} else if (isDraft) {
|
} else if (isDraft) {
|
||||||
|
@ -16,8 +16,7 @@ import ContentList from "@/components/content/lists/ContentList";
|
|||||||
import { parseEvent } from "@/utils/nostr";
|
import { parseEvent } from "@/utils/nostr";
|
||||||
import { ProgressSpinner } from "primereact/progressspinner";
|
import { ProgressSpinner } from "primereact/progressspinner";
|
||||||
import { useNDKContext } from "@/context/NDKContext";
|
import { useNDKContext } from "@/context/NDKContext";
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
const UserContent = () => {
|
const UserContent = () => {
|
||||||
const [activeIndex, setActiveIndex] = useState(0);
|
const [activeIndex, setActiveIndex] = useState(0);
|
||||||
@ -60,7 +59,7 @@ const UserContent = () => {
|
|||||||
const fetchAllContentFromNDK = async (ids) => {
|
const fetchAllContentFromNDK = async (ids) => {
|
||||||
try {
|
try {
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
const filter = { "#d": ids, authors: [AUTHOR_PUBKEY] };
|
const filter = { "#d": ids, authors: appConfig.authorPubkeys };
|
||||||
|
|
||||||
const uniqueEvents = new Set();
|
const uniqueEvents = new Set();
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { Column } from "primereact/column";
|
|||||||
import { useImageProxy } from "@/hooks/useImageProxy";
|
import { useImageProxy } from "@/hooks/useImageProxy";
|
||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
import { ProgressSpinner } from "primereact/progressspinner";
|
import { ProgressSpinner } from "primereact/progressspinner";
|
||||||
import { useNDKContext, defaultRelayUrls } from "@/context/NDKContext";
|
import { useNDKContext } from "@/context/NDKContext";
|
||||||
import useWindowWidth from "@/hooks/useWindowWidth";
|
import useWindowWidth from "@/hooks/useWindowWidth";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import BitcoinConnectButton from "@/components/bitcoinConnect/BitcoinConnect";
|
import BitcoinConnectButton from "@/components/bitcoinConnect/BitcoinConnect";
|
||||||
@ -14,6 +14,7 @@ import { nip19 } from "nostr-tools";
|
|||||||
import { InputText } from "primereact/inputtext";
|
import { InputText } from "primereact/inputtext";
|
||||||
import { Tooltip } from "primereact/tooltip";
|
import { Tooltip } from "primereact/tooltip";
|
||||||
import { useToast } from "@/hooks/useToast";
|
import { useToast } from "@/hooks/useToast";
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
const UserSettings = () => {
|
const UserSettings = () => {
|
||||||
const [user, setUser] = useState(null);
|
const [user, setUser] = useState(null);
|
||||||
@ -96,7 +97,7 @@ const UserSettings = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const removeRelay = (url) => {
|
const removeRelay = (url) => {
|
||||||
if (!defaultRelayUrls.includes(url)) {
|
if (!appConfig.defaultRelayUrls.includes(url)) {
|
||||||
setUserRelays(userRelays.filter(relay => relay !== url));
|
setUserRelays(userRelays.filter(relay => relay !== url));
|
||||||
reInitializeNDK();
|
reInitializeNDK();
|
||||||
setCollapsed(true);
|
setCollapsed(true);
|
||||||
@ -107,7 +108,7 @@ const UserSettings = () => {
|
|||||||
const relayActionsBody = (rowData) => {
|
const relayActionsBody = (rowData) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{!defaultRelayUrls.includes(rowData) ? (
|
{!appConfig.defaultRelayUrls.includes(rowData) ? (
|
||||||
<GenericButton
|
<GenericButton
|
||||||
icon="pi pi-trash"
|
icon="pi pi-trash"
|
||||||
className="p-button-rounded p-button-danger p-button-text"
|
className="p-button-rounded p-button-danger p-button-text"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { nip19 } from "nostr-tools";
|
import { nip19 } from "nostr-tools";
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
const ZapForm = ({ event }) => {
|
const ZapForm = ({ event }) => {
|
||||||
const nAddress = nip19.naddrEncode({
|
const nAddress = nip19.naddrEncode({
|
||||||
kind: event?.kind,
|
kind: event?.kind,
|
||||||
pubkey: event?.pubkey,
|
pubkey: event?.pubkey,
|
||||||
identifier: event.d,
|
identifier: event.d,
|
||||||
relays: [...defaultRelayUrls]
|
relays: [...appConfig.defaultRelayUrls]
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -2,28 +2,16 @@ import React, { createContext, useContext, useEffect, useState, useMemo } from '
|
|||||||
import NDK, { NDKNip07Signer } from "@nostr-dev-kit/ndk";
|
import NDK, { NDKNip07Signer } from "@nostr-dev-kit/ndk";
|
||||||
import NDKCacheAdapterDexie from "@nostr-dev-kit/ndk-cache-dexie";
|
import NDKCacheAdapterDexie from "@nostr-dev-kit/ndk-cache-dexie";
|
||||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
const NDKContext = createContext(null);
|
const NDKContext = createContext(null);
|
||||||
|
|
||||||
export const defaultRelayUrls = [
|
|
||||||
"wss://nos.lol/",
|
|
||||||
"wss://relay.damus.io/",
|
|
||||||
"wss://relay.snort.social/",
|
|
||||||
"wss://relay.nostr.band/",
|
|
||||||
"wss://relay.mutinywallet.com/",
|
|
||||||
"wss://relay.primal.net/",
|
|
||||||
"wss://nostr21.com/",
|
|
||||||
"wss://nostrue.com/",
|
|
||||||
"wss://purplerelay.com/",
|
|
||||||
// "wss://relay.devs.tools/"
|
|
||||||
];
|
|
||||||
|
|
||||||
export const NDKProvider = ({ children }) => {
|
export const NDKProvider = ({ children }) => {
|
||||||
const [ndk, setNdk] = useState(null);
|
const [ndk, setNdk] = useState(null);
|
||||||
const [userRelays, setUserRelays] = useLocalStorage("userRelays", defaultRelayUrls);
|
const [userRelays, setUserRelays] = useLocalStorage("userRelays", appConfig.defaultRelayUrls);
|
||||||
|
|
||||||
const createNDKInstance = (relays) => {
|
const createNDKInstance = (relays) => {
|
||||||
const allRelays = [...new Set([...defaultRelayUrls, ...relays])];
|
const allRelays = [...new Set([...appConfig.defaultRelayUrls, ...relays])];
|
||||||
return new NDK({
|
return new NDK({
|
||||||
explicitRelayUrls: allRelays,
|
explicitRelayUrls: allRelays,
|
||||||
enableOutboxModel: true,
|
enableOutboxModel: true,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useNDKContext } from '@/context/NDKContext';
|
import { useNDKContext } from '@/context/NDKContext';
|
||||||
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
export function useCourses() {
|
export function useCourses() {
|
||||||
const [isClient, setIsClient] = useState(false);
|
const [isClient, setIsClient] = useState(false);
|
||||||
@ -35,7 +34,7 @@ export function useCourses() {
|
|||||||
|
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
|
|
||||||
const filter = { kinds: [30004], authors: [AUTHOR_PUBKEY] };
|
const filter = { kinds: [30004], authors: appConfig.authorPubkeys };
|
||||||
const events = await ndk.fetchEvents(filter);
|
const events = await ndk.fetchEvents(filter);
|
||||||
|
|
||||||
if (events && events.size > 0) {
|
if (events && events.size > 0) {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useNDKContext } from '@/context/NDKContext';
|
import { useNDKContext } from '@/context/NDKContext';
|
||||||
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
export function useDocuments() {
|
export function useDocuments() {
|
||||||
const [isClient, setIsClient] = useState(false);
|
const [isClient, setIsClient] = useState(false);
|
||||||
@ -36,7 +35,7 @@ export function useDocuments() {
|
|||||||
|
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
|
|
||||||
const filter = { kinds: [30023, 30402], authors: [AUTHOR_PUBKEY] };
|
const filter = { kinds: [30023, 30402], authors: appConfig.authorPubkeys };
|
||||||
const events = await ndk.fetchEvents(filter);
|
const events = await ndk.fetchEvents(filter);
|
||||||
|
|
||||||
if (events && events.size > 0) {
|
if (events && events.size > 0) {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useNDKContext } from '@/context/NDKContext';
|
import { useNDKContext } from '@/context/NDKContext';
|
||||||
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
export function useVideos() {
|
export function useVideos() {
|
||||||
const [isClient, setIsClient] = useState(false);
|
const [isClient, setIsClient] = useState(false);
|
||||||
@ -36,7 +35,7 @@ export function useVideos() {
|
|||||||
|
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
|
|
||||||
const filter = { kinds: [30023, 30402], authors: [AUTHOR_PUBKEY] };
|
const filter = { kinds: [30023, 30402], authors: appConfig.authorPubkeys };
|
||||||
const events = await ndk.fetchEvents(filter);
|
const events = await ndk.fetchEvents(filter);
|
||||||
|
|
||||||
if (events && events.size > 0) {
|
if (events && events.size > 0) {
|
||||||
|
@ -2,8 +2,7 @@ import { useState, useEffect } from 'react';
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useNDKContext } from '@/context/NDKContext';
|
import { useNDKContext } from '@/context/NDKContext';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
export function useCoursesQuery() {
|
export function useCoursesQuery() {
|
||||||
const [isClient, setIsClient] = useState(false);
|
const [isClient, setIsClient] = useState(false);
|
||||||
@ -30,7 +29,7 @@ export function useCoursesQuery() {
|
|||||||
|
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
|
|
||||||
const filter = { kinds: [30004], authors: [AUTHOR_PUBKEY] };
|
const filter = { kinds: [30004], authors: appConfig.authorPubkeys };
|
||||||
const events = await ndk.fetchEvents(filter);
|
const events = await ndk.fetchEvents(filter);
|
||||||
|
|
||||||
console.log('events', events);
|
console.log('events', events);
|
||||||
|
@ -2,8 +2,7 @@ import { useState, useEffect } from 'react';
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useNDKContext } from '@/context/NDKContext';
|
import { useNDKContext } from '@/context/NDKContext';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import appConfig from '@/config/appConfig';
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
export function useDocumentsQuery() {
|
export function useDocumentsQuery() {
|
||||||
const [isClient, setIsClient] = useState(false);
|
const [isClient, setIsClient] = useState(false);
|
||||||
@ -31,7 +30,7 @@ export function useDocumentsQuery() {
|
|||||||
|
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
|
|
||||||
const filter = { kinds: [30023, 30402], authors: [AUTHOR_PUBKEY] };
|
const filter = { kinds: [30023, 30402], authors: appConfig.authorPubkeys };
|
||||||
const events = await ndk.fetchEvents(filter);
|
const events = await ndk.fetchEvents(filter);
|
||||||
|
|
||||||
if (events && events.size > 0) {
|
if (events && events.size > 0) {
|
||||||
|
@ -2,8 +2,7 @@ import { useState, useEffect } from 'react';
|
|||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useNDKContext } from '@/context/NDKContext';
|
import { useNDKContext } from '@/context/NDKContext';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import appConfig from '@/config/appConfig';
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
export function useVideosQuery() {
|
export function useVideosQuery() {
|
||||||
const [isClient, setIsClient] = useState(false);
|
const [isClient, setIsClient] = useState(false);
|
||||||
@ -31,7 +30,7 @@ export function useVideosQuery() {
|
|||||||
|
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
|
|
||||||
const filter = { kinds: [30023, 30402], authors: [AUTHOR_PUBKEY] };
|
const filter = { kinds: [30023, 30402], authors: appConfig.authorPubkeys };
|
||||||
const events = await ndk.fetchEvents(filter);
|
const events = await ndk.fetchEvents(filter);
|
||||||
|
|
||||||
if (events && events.size > 0) {
|
if (events && events.size > 0) {
|
||||||
|
@ -2,8 +2,7 @@ import { useState, useEffect } from 'react';
|
|||||||
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
import { useContentIdsQuery } from '@/hooks/apiQueries/useContentIdsQuery';
|
||||||
import { useNDKContext } from '@/context/NDKContext';
|
import { useNDKContext } from '@/context/NDKContext';
|
||||||
import { parseEvent, parseCourseEvent } from '@/utils/nostr';
|
import { parseEvent, parseCourseEvent } from '@/utils/nostr';
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
const AUTHOR_PUBKEY = process.env.NEXT_PUBLIC_AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
export const useContentSearch = () => {
|
export const useContentSearch = () => {
|
||||||
const [allContent, setAllContent] = useState([]);
|
const [allContent, setAllContent] = useState([]);
|
||||||
@ -15,7 +14,7 @@ export const useContentSearch = () => {
|
|||||||
try {
|
try {
|
||||||
await ndk.connect();
|
await ndk.connect();
|
||||||
const filter = {
|
const filter = {
|
||||||
authors: [AUTHOR_PUBKEY],
|
authors: appConfig.authorPubkeys,
|
||||||
kinds: [30004, 30023, 30402],
|
kinds: [30004, 30023, 30402],
|
||||||
"#d": ids
|
"#d": ids
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,12 @@ import { generateSecretKey, getPublicKey } from 'nostr-tools/pure'
|
|||||||
import { bytesToHex } from '@noble/hashes/utils'
|
import { bytesToHex } from '@noble/hashes/utils'
|
||||||
import { updateUser } from "@/db/models/userModels";
|
import { updateUser } from "@/db/models/userModels";
|
||||||
import { createRole } from "@/db/models/roleModels";
|
import { createRole } from "@/db/models/roleModels";
|
||||||
import { defaultRelayUrls } from "@/context/NDKContext";
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
const BASE_URL = process.env.BASE_URL;
|
const BASE_URL = process.env.BASE_URL;
|
||||||
const AUTHOR_PUBKEY = process.env.AUTHOR_PUBKEY;
|
|
||||||
|
|
||||||
const ndk = new NDK({
|
const ndk = new NDK({
|
||||||
explicitRelayUrls: defaultRelayUrls,
|
explicitRelayUrls: appConfig.defaultRelayUrls,
|
||||||
});
|
});
|
||||||
|
|
||||||
const authorize = async (pubkey) => {
|
const authorize = async (pubkey) => {
|
||||||
@ -107,7 +106,7 @@ export const authOptions = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user && user?.pubkey === AUTHOR_PUBKEY && !user?.role) {
|
if (user && appConfig.authorPubkeys.includes(user?.pubkey) && !user?.role) {
|
||||||
// create a new author role for this user
|
// create a new author role for this user
|
||||||
const role = await createRole({
|
const role = await createRole({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
@ -2,6 +2,7 @@ import { getServerSession } from "next-auth/next"
|
|||||||
import { authOptions } from "./auth/[...nextauth]"
|
import { authOptions } from "./auth/[...nextauth]"
|
||||||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"
|
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"
|
||||||
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"
|
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3"
|
||||||
|
import appConfig from "@/config/appConfig";
|
||||||
|
|
||||||
const s3Client = new S3Client({
|
const s3Client = new S3Client({
|
||||||
endpoint: "https://nyc3.digitaloceanspaces.com", // DigitalOcean Spaces endpoint
|
endpoint: "https://nyc3.digitaloceanspaces.com", // DigitalOcean Spaces endpoint
|
||||||
@ -12,8 +13,6 @@ const s3Client = new S3Client({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const AUTHOR_PUBKEY = process.env.AUTHOR_PUBKEY
|
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
try {
|
try {
|
||||||
// Check if the request method is GET
|
// Check if the request method is GET
|
||||||
@ -34,7 +33,7 @@ export default async function handler(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user is authorized to access the video
|
// Check if the user is authorized to access the video
|
||||||
if (!session.user.role?.subscribed && session.user.pubkey !== AUTHOR_PUBKEY) {
|
if (!session.user.role?.subscribed && !appConfig.authorPubkeys.includes(session.user.pubkey)) {
|
||||||
const purchasedVideo = session.user.purchased?.find(purchase => purchase?.resource?.videoId === videoKey)
|
const purchasedVideo = session.user.purchased?.find(purchase => purchase?.resource?.videoId === videoKey)
|
||||||
console.log("purchasedVideo", purchasedVideo)
|
console.log("purchasedVideo", purchasedVideo)
|
||||||
if (!purchasedVideo) {
|
if (!purchasedVideo) {
|
||||||
|
@ -9,7 +9,7 @@ import { useNDKContext } from '@/context/NDKContext';
|
|||||||
import VideoDetails from '@/components/content/videos/VideoDetails';
|
import VideoDetails from '@/components/content/videos/VideoDetails';
|
||||||
import DocumentDetails from '@/components/content/documents/DocumentDetails';
|
import DocumentDetails from '@/components/content/documents/DocumentDetails';
|
||||||
import { ProgressSpinner } from 'primereact/progressspinner';
|
import { ProgressSpinner } from 'primereact/progressspinner';
|
||||||
import { defaultRelayUrls } from '@/context/NDKContext';
|
import appConfig from "@/config/appConfig";
|
||||||
import 'primeicons/primeicons.css';
|
import 'primeicons/primeicons.css';
|
||||||
|
|
||||||
const privkey = process.env.NEXT_PUBLIC_APP_PRIV_KEY;
|
const privkey = process.env.NEXT_PUBLIC_APP_PRIV_KEY;
|
||||||
@ -171,7 +171,7 @@ export default function Details() {
|
|||||||
pubkey: processedEvent.pubkey,
|
pubkey: processedEvent.pubkey,
|
||||||
kind: processedEvent.kind,
|
kind: processedEvent.kind,
|
||||||
identifier: processedEvent.d,
|
identifier: processedEvent.d,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
setNAddress(naddr);
|
setNAddress(naddr);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import useResponsiveImageDimensions from '@/hooks/useResponsiveImageDimensions';
|
|||||||
import 'primeicons/primeicons.css';
|
import 'primeicons/primeicons.css';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { validateEvent } from '@/utils/nostr';
|
import { validateEvent } from '@/utils/nostr';
|
||||||
import { defaultRelayUrls } from '@/context/NDKContext';
|
import appConfig from "@/config/appConfig";
|
||||||
import { useIsAdmin } from "@/hooks/useIsAdmin";
|
import { useIsAdmin } from "@/hooks/useIsAdmin";
|
||||||
|
|
||||||
const MDDisplay = dynamic(
|
const MDDisplay = dynamic(
|
||||||
@ -132,7 +132,7 @@ export default function Draft() {
|
|||||||
pubkey: resource.pubkey,
|
pubkey: resource.pubkey,
|
||||||
kind: resource.kind,
|
kind: resource.kind,
|
||||||
identifier: dTag,
|
identifier: dTag,
|
||||||
relayUrls: defaultRelayUrls
|
relayUrls: appConfig.defaultRelayUrls
|
||||||
});
|
});
|
||||||
|
|
||||||
const userResponse = await axios.get(`/api/users/${user.pubkey}`);
|
const userResponse = await axios.get(`/api/users/${user.pubkey}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user