diff --git a/src/App.tsx b/src/App.tsx index 1992a68d..554dcc71 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -137,6 +137,7 @@ const defaultConfig: AppConfig = { fsPathTemplates: electronPaths.fsPathTemplates, sentryDsn: import.meta.env.VITE_SENTRY_DSN || "", sentryEnabled: true, + communityFollowPack: "nevent1qvzqqqr4xypzpyexz3t34l966ngh5xg7u2q788hthdqmj0av3lv8s2tz9t43zt6dqy28wumn8ghj7un9d3shjtnyv9kh2uewd9hsz9nhwden5te0wfjkccte9ehx7um5wghxyctwvsq3gamnwvaz7tmwdaehgu3wdau8gu3wv3jhvqgawaehxw309ahx7um5wgkhqatz9emk2mrvdaexgetj9ehx2aqpp4mhxue69uhkummn9ekx7mqpzemhxue69uhhyetvv9ujuurjd9kkzmpwdejhgqgwwaehxw309ahx7uewd3hkctcpz9mhxue69uhkummnw3ezuamfdejj7qghwaehxw309aex2mrp0yhxummnw3ezucnpdejz7qgmwaehxw309aex2mrp0yhxummnw3e8qmr9vfejucm0d5hsz8mhwden5te0dehhxarj94ex2mrp0yhxgetjv44hymmnwvhx6ef0qyt8wumn8ghj7mn0wd68yetvd96x2uewdaexwtcprfmhxue69uhhq7tjv9kkjepwve5kzar2v9nzucm0d5hszfthwden5te0dehhxarj94ex2mrp0yhxgetjv44hymmnwvhx6ef0d9hxymmc9uqzqq6casgsyhj2c29rjlcy3tu3devp3akg7j6zqr296met9gz98np3qkwsg5", }; // Initialize filesystem adapter based on environment diff --git a/src/components/AppProvider.tsx b/src/components/AppProvider.tsx index 069efb80..b96bcd92 100644 --- a/src/components/AppProvider.tsx +++ b/src/components/AppProvider.tsx @@ -50,6 +50,7 @@ const AppConfigSchema = z.object({ sentryDsn: z.string(), sentryEnabled: z.boolean(), systemPrompt: z.string(), + communityFollowPack: z.string(), }) satisfies z.ZodType; export function AppProvider(props: AppProviderProps) { diff --git a/src/components/SentryProvider.test.tsx b/src/components/SentryProvider.test.tsx index 9af8c289..5d5cf938 100644 --- a/src/components/SentryProvider.test.tsx +++ b/src/components/SentryProvider.test.tsx @@ -40,6 +40,7 @@ describe('SentryProvider', () => { fsPathTmp: '/tmp', fsPathPlugins: '/plugins', fsPathTemplates: '/templates', + communityFollowPack: '', }; render( @@ -77,6 +78,7 @@ describe('SentryProvider', () => { fsPathTmp: '/tmp', fsPathPlugins: '/plugins', fsPathTemplates: '/templates', + communityFollowPack: '', }; render( @@ -115,6 +117,7 @@ describe('SentryProvider', () => { fsPathTmp: '/tmp', fsPathPlugins: '/plugins', fsPathTemplates: '/templates', + communityFollowPack: '', }; render( @@ -156,6 +159,7 @@ describe('SentryProvider', () => { fsPathTmp: '/tmp', fsPathPlugins: '/plugins', fsPathTemplates: '/templates', + communityFollowPack: '', }; render( diff --git a/src/contexts/AppContext.ts b/src/contexts/AppContext.ts index 68ad6c78..51caea0f 100644 --- a/src/contexts/AppContext.ts +++ b/src/contexts/AppContext.ts @@ -57,6 +57,8 @@ export interface AppConfig { sentryEnabled: boolean; /** System prompt EJS template */ systemPrompt?: string; + /** Nostr follow pack naddr for community events (e.g., "naddr1...") */ + communityFollowPack: string; } export interface AppContextType { diff --git a/src/hooks/useCommunity.ts b/src/hooks/useCommunity.ts index 504fba81..322d7a70 100644 --- a/src/hooks/useCommunity.ts +++ b/src/hooks/useCommunity.ts @@ -1,14 +1,8 @@ import { type NostrEvent, NRelay1 } from '@nostrify/nostrify'; import { useNostr } from '@nostrify/react'; import { useQuery } from '@tanstack/react-query'; - -// Soapbox Follow Pack naddr for team members -// naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m -const SOAPBOX_FOLLOW_PACK = { - pubkey: '932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d', - kind: 39089, - identifier: 'k4p5w0n22suf', -}; +import { nip19 } from 'nostr-tools'; +import { useAppContext } from '@/hooks/useAppContext'; // ShakespeareGitCommits bot npub // npub1msc06u2v3y3z2awdxlc7k2tnjlc78xg8awvha5rsaphd8py7ussqd0phxu @@ -56,25 +50,91 @@ function hasShakespeareInTitle(event: NostrEvent): boolean { } /** - * Hook to fetch the Soapbox Follow Pack to get team member pubkeys + * Decoded follow pack data - either from naddr or nevent */ -export function useSoapboxFollowPack() { +type FollowPackData = { + /** For naddr: query by author, kind, and d-tag */ + type: 'naddr'; + pubkey: string; + kind: number; + identifier: string; +} | { + /** For nevent: query by event id */ + type: 'nevent'; + id: string; + relays?: string[]; +}; + +/** + * Decode a follow pack identifier (naddr or nevent) to get its components + */ +function decodeFollowPackIdentifier(identifier: string): FollowPackData | null { + try { + const decoded = nip19.decode(identifier); + if (decoded.type === 'naddr') { + return { + type: 'naddr', + pubkey: decoded.data.pubkey, + kind: decoded.data.kind, + identifier: decoded.data.identifier, + }; + } + if (decoded.type === 'nevent') { + return { + type: 'nevent', + id: decoded.data.id, + relays: decoded.data.relays, + }; + } + } catch { + // Invalid identifier + } + return null; +} + +/** + * Hook to fetch the community follow pack to get team member pubkeys + * Uses the communityFollowPack setting from the app config + * Supports both naddr and nevent identifiers + */ +export function useCommunityFollowPack() { const { nostr } = useNostr(); + const { config } = useAppContext(); + + const followPackData = decodeFollowPackIdentifier(config.communityFollowPack); return useQuery({ - queryKey: ['soapbox-follow-pack'], + queryKey: ['community-follow-pack', config.communityFollowPack], queryFn: async (c) => { + if (!followPackData) { + return []; + } + const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]); - const events = await nostr.query( - [{ - kinds: [SOAPBOX_FOLLOW_PACK.kind], - authors: [SOAPBOX_FOLLOW_PACK.pubkey], - '#d': [SOAPBOX_FOLLOW_PACK.identifier], - limit: 1, - }], - { signal } - ); + let events: NostrEvent[]; + + if (followPackData.type === 'naddr') { + // Query by author, kind, and d-tag for addressable events + events = await nostr.query( + [{ + kinds: [followPackData.kind], + authors: [followPackData.pubkey], + '#d': [followPackData.identifier], + limit: 1, + }], + { signal } + ); + } else { + // Query by event id for nevent + events = await nostr.query( + [{ + ids: [followPackData.id], + limit: 1, + }], + { signal } + ); + } if (events.length === 0) { return []; @@ -88,20 +148,22 @@ export function useSoapboxFollowPack() { return pubkeys; }, staleTime: 300000, // 5 minutes + enabled: !!followPackData, }); } /** - * Hook to fetch calendar events from Soapbox Follow Pack members (NIP-52) + * Hook to fetch calendar events from community follow pack members (NIP-52) * Filtered to only show events with "shakespeare" in the title * Fetches both date-based (31922) and time-based (31923) calendar events */ export function useCommunityEvents(limit = 10) { const { nostr } = useNostr(); - const { data: teamPubkeys } = useSoapboxFollowPack(); + const { config } = useAppContext(); + const { data: teamPubkeys } = useCommunityFollowPack(); return useQuery({ - queryKey: ['community-events', limit, teamPubkeys], + queryKey: ['community-events', limit, config.communityFollowPack, teamPubkeys], queryFn: async (c) => { if (!teamPubkeys || teamPubkeys.length === 0) { return []; diff --git a/src/hooks/useGenerateProjectInfo.test.ts b/src/hooks/useGenerateProjectInfo.test.ts index b20f6437..4735e40a 100644 --- a/src/hooks/useGenerateProjectInfo.test.ts +++ b/src/hooks/useGenerateProjectInfo.test.ts @@ -75,6 +75,7 @@ describe('useGenerateProjectInfo', () => { fsPathTemplates: '/templates', sentryDsn: '', sentryEnabled: false, + communityFollowPack: '', }; mockUseAppContext.mockReturnValue({ config, @@ -228,6 +229,7 @@ describe('useGenerateProjectInfo', () => { fsPathTemplates: '/templates', sentryDsn: '', sentryEnabled: false, + communityFollowPack: '', }; mockUseAppContext.mockReturnValue({ config, diff --git a/src/hooks/useGit.test.ts b/src/hooks/useGit.test.ts index 03c26442..95f85c68 100644 --- a/src/hooks/useGit.test.ts +++ b/src/hooks/useGit.test.ts @@ -52,6 +52,7 @@ function createWrapper(corsProxy: string) { fsPathTemplates: '/templates', sentryDsn: '', sentryEnabled: false, + communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m', }; return createElement( diff --git a/src/lib/SessionManager.test.ts b/src/lib/SessionManager.test.ts index bea3f769..b92cf5ac 100644 --- a/src/lib/SessionManager.test.ts +++ b/src/lib/SessionManager.test.ts @@ -56,6 +56,7 @@ const testConfig: AppConfig = { fsPathTemplates: '/templates', sentryDsn: '', sentryEnabled: false, + communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m', }; describe('SessionManager', () => { diff --git a/src/lib/system.test.ts b/src/lib/system.test.ts index f52bd79f..fcd17b5f 100644 --- a/src/lib/system.test.ts +++ b/src/lib/system.test.ts @@ -43,6 +43,7 @@ const testConfig: AppConfig = { fsPathTemplates: '/templates', sentryDsn: '', sentryEnabled: false, + communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m', }; describe('makeSystemPrompt', () => { diff --git a/src/locales/en.json b/src/locales/en.json index 24c01c39..a34d10ab 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -51,6 +51,8 @@ "showcaseEnabledDescription": "Display the app showcase section on the home page", "showcaseModerator": "Showcase Moderator", "showcaseModeratorDescription": "Nostr public key (npub) of the user who can moderate showcase submissions", + "communityFollowPack": "Community", + "communityFollowPackDescription": "Nostr event of the follow pack used for the Community Events section of the Community page", "filesystemPaths": "Filesystem Paths", "projectsDirectory": "Projects Directory", "projectsDirectoryDescription": "Filesystem path where projects are stored", diff --git a/src/locales/ha.json b/src/locales/ha.json index 3ddca2ae..d1760312 100644 --- a/src/locales/ha.json +++ b/src/locales/ha.json @@ -51,6 +51,8 @@ "showcaseEnabledDescription": "Nuna sashen nuni na aikace-aikace a shafin gida", "showcaseModerator": "Mai Kula da Nuni", "showcaseModeratorDescription": "Maɓallin jama'a na Nostr (npub) na mai amfani wanda zai iya kula da ƙaddamarwar nuni", + "communityFollowPack": "Al'umma", + "communityFollowPackDescription": "Taron Nostr na fakitin bi da ake amfani da shi don sashen Ayyukan Al'umma a shafin Al'umma", "filesystemPaths": "Hanyoyin Tsarin Fayil", "projectsDirectory": "Kundin Ayyuka", "projectsDirectoryDescription": "Hanyar tsarin fayil inda ake adana ayyuka", diff --git a/src/locales/ig.json b/src/locales/ig.json index 8e9ec297..30235188 100644 --- a/src/locales/ig.json +++ b/src/locales/ig.json @@ -51,6 +51,8 @@ "showcaseEnabledDescription": "Gosipụta ngalaba ngosipụta ngwa na ibe ụlọ", "showcaseModerator": "Onye Nlekọta Ngosipụta", "showcaseModeratorDescription": "Igodo ọha Nostr (npub) nke onye ọrụ nwere ike ilekọta ntinye ngosipụta", + "communityFollowPack": "Obodo", + "communityFollowPackDescription": "Ihe omume Nostr nke ngwugwu eso a na-eji maka ngalaba Mmemme Obodo na ibe Obodo", "filesystemPaths": "Ụzọ Sistemu Faịlụ", "projectsDirectory": "Ndekọ Ọrụ", "projectsDirectoryDescription": "Ụzọ sistemu faịlụ ebe echekwara ọrụ", diff --git a/src/locales/pt.json b/src/locales/pt.json index 14422c45..18abd614 100644 --- a/src/locales/pt.json +++ b/src/locales/pt.json @@ -51,6 +51,8 @@ "showcaseEnabledDescription": "Exibir a seção de vitrine de aplicativos na página inicial", "showcaseModerator": "Moderador da Vitrine", "showcaseModeratorDescription": "Chave pública Nostr (npub) do usuário que pode moderar envios da vitrine", + "communityFollowPack": "Comunidade", + "communityFollowPackDescription": "Evento Nostr do pacote de seguir usado para a seção de Eventos da Comunidade na página da Comunidade", "filesystemPaths": "Caminhos do Sistema de Arquivos", "projectsDirectory": "Diretório de Projetos", "projectsDirectoryDescription": "Caminho do sistema de arquivos onde os projetos são armazenados", diff --git a/src/locales/yo.json b/src/locales/yo.json index 93692976..9d16bd3f 100644 --- a/src/locales/yo.json +++ b/src/locales/yo.json @@ -51,6 +51,8 @@ "showcaseEnabledDescription": "Ṣafihan apakan ifihan ohun elo lori oju-iwe ile", "showcaseModerator": "Oluṣakoso Ifihan", "showcaseModeratorDescription": "Bọtini gbangba Nostr (npub) ti olumulo ti o le ṣakoso awọn ifisilẹ ifihan", + "communityFollowPack": "Agbegbe", + "communityFollowPackDescription": "Iṣẹlẹ Nostr ti apo atẹle ti a lo fun apakan Awọn Iṣẹlẹ Agbegbe lori oju-iwe Agbegbe", "filesystemPaths": "Awọn Ọna Eto Faili", "projectsDirectory": "Itọsọna Awọn iṣẹ akanṣe", "projectsDirectoryDescription": "Ọna eto faili nibiti a tọju awọn iṣẹ akanṣe", diff --git a/src/locales/zh.json b/src/locales/zh.json index bed6ed89..7004afaa 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -51,6 +51,8 @@ "showcaseEnabledDescription": "在主页上显示应用展示部分", "showcaseModerator": "展示管理员", "showcaseModeratorDescription": "可以审核展示提交的用户的Nostr公钥(npub)", + "communityFollowPack": "社区", + "communityFollowPackDescription": "用于社区页面社区活动部分的关注包的Nostr事件", "filesystemPaths": "文件系统路径", "projectsDirectory": "项目目录", "projectsDirectoryDescription": "存储项目的文件系统路径", diff --git a/src/pages/SystemSettings.tsx b/src/pages/SystemSettings.tsx index 75b0e7e1..4c075771 100644 --- a/src/pages/SystemSettings.tsx +++ b/src/pages/SystemSettings.tsx @@ -1,4 +1,4 @@ -import { Settings, ArrowLeft, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, FolderTree, Terminal as TerminalIcon } from "lucide-react"; +import { Settings, ArrowLeft, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, FolderTree, Terminal as TerminalIcon, Users } from "lucide-react"; import { useTranslation } from 'react-i18next'; import { useState, useEffect, useMemo } from "react"; import { Button } from "@/components/ui/button"; @@ -26,6 +26,7 @@ export function SystemSettings() { const [faviconUrlInput, setFaviconUrlInput] = useState(config.faviconUrl); const [previewDomainInput, setPreviewDomainInput] = useState(config.previewDomain); const [showcaseModeratorInput, setShowcaseModeratorInput] = useState(config.showcaseModerator); + const [communityFollowPackInput, setCommunityFollowPackInput] = useState(config.communityFollowPack); const [fsPathProjectsInput, setFsPathProjectsInput] = useState(config.fsPathProjects); const [fsPathConfigInput, setFsPathConfigInput] = useState(config.fsPathConfig); const [fsPathTmpInput, setFsPathTmpInput] = useState(config.fsPathTmp); @@ -41,6 +42,7 @@ export function SystemSettings() { previewDomain: config.previewDomain !== defaultConfig.previewDomain, showcaseEnabled: config.showcaseEnabled !== defaultConfig.showcaseEnabled, showcaseModerator: config.showcaseModerator !== defaultConfig.showcaseModerator, + communityFollowPack: config.communityFollowPack !== defaultConfig.communityFollowPack, fsPathProjects: config.fsPathProjects !== defaultConfig.fsPathProjects, fsPathConfig: config.fsPathConfig !== defaultConfig.fsPathConfig, fsPathTmp: config.fsPathTmp !== defaultConfig.fsPathTmp, @@ -102,6 +104,15 @@ export function SystemSettings() { }); }; + const restoreCommunityFollowPack = () => { + const defaultValue = defaultConfig.communityFollowPack; + setCommunityFollowPackInput(defaultValue); + updateConfig((current) => { + const { communityFollowPack, ...rest } = current; + return rest; + }); + }; + const restoreFsPathProjects = () => { const defaultValue = defaultConfig.fsPathProjects; setFsPathProjectsInput(defaultValue); @@ -680,6 +691,55 @@ export function SystemSettings() { + {/* Community Follow Pack Configuration */} + + + +
+ +

{t('communityFollowPack')}

+ {isModified.communityFollowPack && ( +
+ )} +
+ + +
+
+ { + const value = e.target.value; + setCommunityFollowPackInput(value); + updateConfig((current) => ({ + ...current, + communityFollowPack: value, + })); + }} + className="flex-1" + /> + {isModified.communityFollowPack && ( + + )} +
+

+ {t('communityFollowPackDescription')} +

+
+
+ + + {/* Sentry DSN Configuration */} diff --git a/src/test/TestApp.tsx b/src/test/TestApp.tsx index 660418e4..45c69097 100644 --- a/src/test/TestApp.tsx +++ b/src/test/TestApp.tsx @@ -57,6 +57,7 @@ export function TestApp({ children }: TestAppProps) { fsPathTemplates: '/templates', sentryDsn: '', sentryEnabled: false, + communityFollowPack: 'naddr1qvzqqqr4xgpzpjcswsacvumftxsmcejj3vsxu8mf203p8hkxoklxtgva7rdxzm0qqy88wumn8ghj7mn0wd68yttsw43z7qg4waehxw309aex2mrp0yhx6mmddaehgu339e3k7mf0qythwumn8ghj7cn5vvhxkmr9dejxz7n0xvs8xmmrdejhytnrdakj7q3qdqr8kgh3s5q8ztw0swmvpwz98cse7rw43n4nhrpszgafnuwrxh8hscmhv5m', }; // Initialize LightningFS for testing