|
|
|
@ -14,12 +14,19 @@ import ( |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/encoders/event" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/encoders/filter" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/encoders/hex" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/encoders/tag" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/httpauth" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/protocol/auth" |
|
|
|
"lol.mleku.dev/chk" |
|
|
|
"lol.mleku.dev/chk" |
|
|
|
"next.orly.dev/app/branding" |
|
|
|
"next.orly.dev/app/branding" |
|
|
|
"next.orly.dev/app/config" |
|
|
|
"next.orly.dev/app/config" |
|
|
|
"next.orly.dev/pkg/acl" |
|
|
|
"next.orly.dev/pkg/acl" |
|
|
|
acliface "next.orly.dev/pkg/interfaces/acl" |
|
|
|
"next.orly.dev/pkg/archive" |
|
|
|
"next.orly.dev/pkg/blossom" |
|
|
|
"next.orly.dev/pkg/blossom" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/bunker" |
|
|
|
"next.orly.dev/pkg/database" |
|
|
|
"next.orly.dev/pkg/database" |
|
|
|
domainevents "next.orly.dev/pkg/domain/events" |
|
|
|
domainevents "next.orly.dev/pkg/domain/events" |
|
|
|
"next.orly.dev/pkg/domain/events/subscribers" |
|
|
|
"next.orly.dev/pkg/domain/events/subscribers" |
|
|
|
@ -29,25 +36,18 @@ import ( |
|
|
|
"next.orly.dev/pkg/event/routing" |
|
|
|
"next.orly.dev/pkg/event/routing" |
|
|
|
"next.orly.dev/pkg/event/specialkinds" |
|
|
|
"next.orly.dev/pkg/event/specialkinds" |
|
|
|
"next.orly.dev/pkg/event/validation" |
|
|
|
"next.orly.dev/pkg/event/validation" |
|
|
|
"git.mleku.dev/mleku/nostr/encoders/event" |
|
|
|
acliface "next.orly.dev/pkg/interfaces/acl" |
|
|
|
"git.mleku.dev/mleku/nostr/encoders/filter" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/encoders/hex" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/encoders/tag" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/policy" |
|
|
|
"next.orly.dev/pkg/policy" |
|
|
|
"git.mleku.dev/mleku/nostr/protocol/auth" |
|
|
|
|
|
|
|
"git.mleku.dev/mleku/nostr/httpauth" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/protocol/graph" |
|
|
|
"next.orly.dev/pkg/protocol/graph" |
|
|
|
"next.orly.dev/pkg/protocol/nip43" |
|
|
|
"next.orly.dev/pkg/protocol/nip43" |
|
|
|
"next.orly.dev/pkg/protocol/publish" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/bunker" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/protocol/nrc" |
|
|
|
"next.orly.dev/pkg/protocol/nrc" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/protocol/publish" |
|
|
|
"next.orly.dev/pkg/ratelimit" |
|
|
|
"next.orly.dev/pkg/ratelimit" |
|
|
|
"next.orly.dev/pkg/spider" |
|
|
|
"next.orly.dev/pkg/spider" |
|
|
|
"next.orly.dev/pkg/storage" |
|
|
|
"next.orly.dev/pkg/storage" |
|
|
|
dsync "next.orly.dev/pkg/sync" |
|
|
|
dsync "next.orly.dev/pkg/sync" |
|
|
|
"next.orly.dev/pkg/wireguard" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/archive" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/tor" |
|
|
|
"next.orly.dev/pkg/tor" |
|
|
|
|
|
|
|
"next.orly.dev/pkg/wireguard" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type Server struct { |
|
|
|
type Server struct { |
|
|
|
@ -57,7 +57,7 @@ type Server struct { |
|
|
|
Config *config.C |
|
|
|
Config *config.C |
|
|
|
// Ctx holds the server context.
|
|
|
|
// Ctx holds the server context.
|
|
|
|
// Deprecated: Use Context() method instead of accessing directly.
|
|
|
|
// Deprecated: Use Context() method instead of accessing directly.
|
|
|
|
Ctx context.Context |
|
|
|
Ctx context.Context |
|
|
|
publishers *publish.S |
|
|
|
publishers *publish.S |
|
|
|
// Admins holds the admin pubkeys.
|
|
|
|
// Admins holds the admin pubkeys.
|
|
|
|
// Deprecated: Use IsAdmin() method instead of accessing directly.
|
|
|
|
// Deprecated: Use IsAdmin() method instead of accessing directly.
|
|
|
|
@ -84,30 +84,30 @@ type Server struct { |
|
|
|
// Use RLock() for normal message processing, Lock() for updates
|
|
|
|
// Use RLock() for normal message processing, Lock() for updates
|
|
|
|
messagePauseMutex sync.RWMutex |
|
|
|
messagePauseMutex sync.RWMutex |
|
|
|
|
|
|
|
|
|
|
|
paymentProcessor *PaymentProcessor |
|
|
|
paymentProcessor *PaymentProcessor |
|
|
|
sprocketManager *SprocketManager |
|
|
|
sprocketManager *SprocketManager |
|
|
|
policyManager *policy.P |
|
|
|
policyManager *policy.P |
|
|
|
spiderManager *spider.Spider |
|
|
|
spiderManager *spider.Spider |
|
|
|
directorySpider *spider.DirectorySpider |
|
|
|
directorySpider *spider.DirectorySpider |
|
|
|
syncManager *dsync.Manager |
|
|
|
syncManager *dsync.Manager |
|
|
|
relayGroupMgr *dsync.RelayGroupManager |
|
|
|
relayGroupMgr *dsync.RelayGroupManager |
|
|
|
clusterManager *dsync.ClusterManager |
|
|
|
clusterManager *dsync.ClusterManager |
|
|
|
blossomServer *blossom.Server |
|
|
|
blossomServer *blossom.Server |
|
|
|
InviteManager *nip43.InviteManager |
|
|
|
InviteManager *nip43.InviteManager |
|
|
|
graphExecutor *graph.Executor |
|
|
|
graphExecutor *graph.Executor |
|
|
|
rateLimiter *ratelimit.Limiter |
|
|
|
rateLimiter *ratelimit.Limiter |
|
|
|
cfg *config.C |
|
|
|
cfg *config.C |
|
|
|
db database.Database // Changed from *database.D to interface
|
|
|
|
db database.Database // Changed from *database.D to interface
|
|
|
|
|
|
|
|
|
|
|
|
// Domain services for event handling
|
|
|
|
// Domain services for event handling
|
|
|
|
eventValidator *validation.Service |
|
|
|
eventValidator *validation.Service |
|
|
|
eventAuthorizer *authorization.Service |
|
|
|
eventAuthorizer *authorization.Service |
|
|
|
eventRouter *routing.DefaultRouter |
|
|
|
eventRouter *routing.DefaultRouter |
|
|
|
eventProcessor *processing.Service |
|
|
|
eventProcessor *processing.Service |
|
|
|
eventDispatcher *domainevents.Dispatcher |
|
|
|
eventDispatcher *domainevents.Dispatcher |
|
|
|
ingestionService *ingestion.Service |
|
|
|
ingestionService *ingestion.Service |
|
|
|
specialKinds *specialkinds.Registry |
|
|
|
specialKinds *specialkinds.Registry |
|
|
|
aclRegistry acliface.Registry |
|
|
|
aclRegistry acliface.Registry |
|
|
|
|
|
|
|
|
|
|
|
// WireGuard VPN and NIP-46 Bunker
|
|
|
|
// WireGuard VPN and NIP-46 Bunker
|
|
|
|
wireguardServer *wireguard.Server |
|
|
|
wireguardServer *wireguard.Server |
|
|
|
@ -1118,7 +1118,7 @@ func (s *Server) handleEventsMine(w http.ResponseWriter, r *http.Request) { |
|
|
|
w.Write(jsonData) |
|
|
|
w.Write(jsonData) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// handleImport receives a JSONL/NDJSON file or body and enqueues an async import using NIP-98 authentication. Admins only.
|
|
|
|
// handleImport receives a JSONL/NDJSON file or body and enqueues an async import using NIP-98 authentication. Write, admin, or owner roles required.
|
|
|
|
func (s *Server) handleImport(w http.ResponseWriter, r *http.Request) { |
|
|
|
func (s *Server) handleImport(w http.ResponseWriter, r *http.Request) { |
|
|
|
if r.Method != http.MethodPost { |
|
|
|
if r.Method != http.MethodPost { |
|
|
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) |
|
|
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) |
|
|
|
@ -1138,11 +1138,11 @@ func (s *Server) handleImport(w http.ResponseWriter, r *http.Request) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check permissions - require admin or owner level
|
|
|
|
// Check permissions - require write, admin, or owner level
|
|
|
|
accessLevel := acl.Registry.GetAccessLevel(pubkey, r.RemoteAddr) |
|
|
|
accessLevel := acl.Registry.GetAccessLevel(pubkey, r.RemoteAddr) |
|
|
|
if accessLevel != "admin" && accessLevel != "owner" { |
|
|
|
if accessLevel != "write" && accessLevel != "admin" && accessLevel != "owner" { |
|
|
|
http.Error( |
|
|
|
http.Error( |
|
|
|
w, "Admin or owner permission required", http.StatusForbidden, |
|
|
|
w, "Write, admin, or owner permission required", http.StatusForbidden, |
|
|
|
) |
|
|
|
) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|