feat(curating): add scanpubkeys API method to retroactively populate unclassified users
- Add ScanAllPubkeys method to scan SerialPubkey index for all pubkeys - Count events for each pubkey using the Pubkey index - Store event counts in CURATING_ACL_EVENT_COUNT_ prefix - Add NIP-86 "scanpubkeys" API endpoint to trigger the scan This allows the curation UI to show all existing users in the unclassified list, even if they had events before curating mode was enabled. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -143,6 +143,8 @@ func (s *Server) handleCuratingNIP86Method(request NIP86Request, curatingACL *ac
|
||||
return s.handleUnblockCuratingIP(request.Params, dbACL)
|
||||
case "isconfigured":
|
||||
return s.handleIsConfigured(dbACL)
|
||||
case "scanpubkeys":
|
||||
return s.handleScanPubkeys(dbACL)
|
||||
default:
|
||||
return NIP86Response{Error: "Unknown method: " + request.Method}
|
||||
}
|
||||
@@ -167,6 +169,7 @@ func (s *Server) handleCuratingSupportedMethods() NIP86Response {
|
||||
"listblockedips",
|
||||
"unblockip",
|
||||
"isconfigured",
|
||||
"scanpubkeys",
|
||||
}
|
||||
return NIP86Response{Result: methods}
|
||||
}
|
||||
@@ -606,3 +609,18 @@ func parseRange(s string, parts []int) (int, error) {
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// handleScanPubkeys scans the database for all pubkeys and populates event counts
|
||||
// This is used to retroactively populate the unclassified users list
|
||||
func (s *Server) handleScanPubkeys(dbACL *database.CuratingACL) NIP86Response {
|
||||
result, err := dbACL.ScanAllPubkeys()
|
||||
if chk.E(err) {
|
||||
return NIP86Response{Error: "Failed to scan pubkeys: " + err.Error()}
|
||||
}
|
||||
|
||||
return NIP86Response{Result: map[string]interface{}{
|
||||
"total_pubkeys": result.TotalPubkeys,
|
||||
"total_events": result.TotalEvents,
|
||||
"skipped": result.Skipped,
|
||||
}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user