feat(nostr): Removed entries from authors on the npub blacklist

This commit is contained in:
Daniel Gonzalez
2025-09-09 18:27:27 -04:00
parent fa623aa4eb
commit ed56fe9e38
3 changed files with 50 additions and 1 deletions
+1
View File
@@ -74,6 +74,7 @@ function App (props) {
console.log('asyncInitStarted: ', appData.asyncInitStarted) console.log('asyncInitStarted: ', appData.asyncInitStarted)
console.log('is single view : ', singleView) console.log('is single view : ', singleView)
await appData.nostrQueries.start()
if (!appData.asyncInitStarted && !singleView) { if (!appData.asyncInitStarted && !singleView) {
try { try {
// Instantiate the async load object. // Instantiate the async load object.
+2 -1
View File
@@ -203,7 +203,8 @@ function NostrChat (props) {
pool.on('event', (relay, subId, ev) => { pool.on('event', (relay, subId, ev) => {
console.log('Group post retrieved from ', relay.url, ev.content) console.log('Group post retrieved from ', relay.url, ev.content)
onMsgRead(ev) const onBlackList = nostrQueries.blackList.find((val) => { return val === ev.pubkey })
if (!onBlackList)onMsgRead(ev)
}) })
return () => { return () => {
+47
View File
@@ -6,6 +6,7 @@ import { RelayPool } from 'nostr'
import * as nip19 from 'nostr-tools/nip19' import * as nip19 from 'nostr-tools/nip19'
import { nip04 } from 'nostr-tools' import { nip04 } from 'nostr-tools'
import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency import { hexToBytes } from '@noble/hashes/utils' // already an installed dependency
import axios from 'axios'
export default class NostrQueries { export default class NostrQueries {
constructor ({ relays }) { constructor ({ relays }) {
@@ -13,6 +14,17 @@ export default class NostrQueries {
this.loadedProfiles = {} this.loadedProfiles = {}
this.loadedChannelsInfo = {} this.loadedChannelsInfo = {}
this.blackList = []
this.blackListFetched = false
}
async start () {
try {
await this.getBlackList()
} catch (error) {
console.error('NostrQueries.start() error : ', error.message)
throw error
}
} }
setRelays (relays) { setRelays (relays) {
@@ -459,4 +471,39 @@ export default class NostrQueries {
throw error throw error
} }
} }
async getBlackList () {
try {
if (this.blackListFetched) return
const opts = {
method: 'GET',
url: 'https://blacklists.psfoundation.info/nostr-chat-blacklist.json',
headers: {
'Content-Type': 'application/json'
}
}
const result = await axios.request(opts)
const { data } = result
const { npubs } = data
// // Dev test mock npub for testing purposes
// const myNpubMock = 'npub1y3xq402pu9aqms3khetnt5gzm54t63pzcla56wwfmwshde0ws77qkff5gc'
// npubs.push(myNpubMock)
// //
this.blackListFetched = true
for (let i = 0; i < npubs.length; i++) {
const npub = npubs[i]
const pubKey = this.npubToHex(npub)
this.blackList.push(pubKey)
}
console.log('BlackList ', this.blackList)
return data
} catch (error) {
console.log('Error on getBlackList()')
throw error
}
}
} }