feat(nostr): Filter out posts from deletedPosts database

This commit is contained in:
Daniel Gonzalez
2025-11-04 19:39:01 -04:00
parent dfb0bca2ec
commit 9f6c0d3fc7
+25 -2
View File
@@ -21,12 +21,14 @@ export default class NostrQueries {
this.blackListFetched = false
this.deletedChats = []
this.deletedPosts = []
}
async start () {
try {
await this.getBlackList()
await this.fetchDeletedChats()
await this.fetchDeletedPosts()
} catch (error) {
console.error('NostrQueries.start() error : ', error.message)
throw error
@@ -188,7 +190,9 @@ export default class NostrQueries {
pool.on('event', (relay, subId, ev) => {
console.log('post retrieved from ', relay.url, ev.sig)
list = [...list, ev]
const isDeleted = this.deletedPosts.find((val) => { return val.eventId === ev.id })
if (!isDeleted) list = [...list, ev]
})
pool.on('error', (relay) => {
relay.close()
@@ -524,7 +528,26 @@ export default class NostrQueries {
const { deletedChats } = result.data
this.deletedChats = deletedChats
} catch (error) {
console.error('Error deletedChats: ', error)
console.error('Error fetchDeletedChats: ', error)
throw error
}
}
// Get all deleted posts
async fetchDeletedPosts () {
try {
const options = {
method: 'GET',
url: `${SERVER}nostr/deletedPost`
}
const result = await axios.request(options)
console.log('result', result)
const { deletedPosts } = result.data
console.log('deletedPosts', deletedPosts)
this.deletedPosts = deletedPosts
} catch (error) {
console.error('Error fetchDeletedPosts: ', error)
throw error
}
}