Anthony Accioly on Nostr: Until greenart7c3 can work his magic, here's another one of my awful scripts to ...
Until greenart7c3 can work his magic, here's another one of my awful scripts to delete all kind 10002 events from a relay, following bitcao (nprofile…7sja)'s advice above. It works with Citrine but not with Haven (Haven is silently ignoring delete events).
👨💻 utxo 👨💻 (nprofile…x66a), is supporting NIP-09 (Event deletion requests) something you feel strongly against, or is this just something that haven't been implemented yet / possible bug?
My impression from this line is that delete events should be working: https://github.com/bitvora/haven/blob/b51529221e3df04de22b73840e2b3cc3ed6b898c/main.go#L247
```javascript
import WebSocket from 'ws'
import { Relay, useWebSocketImplementation } from 'nostr-tools/relay'
import { finalizeEvent, getPublicKey } from 'nostr-tools/pure'
import * as nip19 from 'nostr-tools/nip19'
useWebSocketImplementation(WebSocket);
const relay = await Relay.connect('ws://192.168.1.1:4869');
console.log(`connected to ${relay.url}`)
const sk = nip19.decode('nsec1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').data
const pk = getPublicKey(sk)
let eventCount = 0
let eventTemplate = {
kind: 5,
created_at: Math.floor(Date.now() / 1000),
tags: [],
content: 'Deleting all kind 10002 events',
}
relay.subscribe([
{
kinds: [10002],
authors: [pk],
},
], {
onevent(event) {
console.log('got event:', event)
eventTemplate.tags.push(['e', event.id], ['k', '10002'])
eventCount++
},
async oneose() {
console.log('Got', eventCount, 'events')
if (eventCount > 0) {
const signedEvent = finalizeEvent(eventTemplate, sk)
console.log('Deletion event:', signedEvent)
await relay.publish(signedEvent)
}
relay.close()
}
})
```
👨💻 utxo 👨💻 (nprofile…x66a), is supporting NIP-09 (Event deletion requests) something you feel strongly against, or is this just something that haven't been implemented yet / possible bug?
My impression from this line is that delete events should be working: https://github.com/bitvora/haven/blob/b51529221e3df04de22b73840e2b3cc3ed6b898c/main.go#L247
```javascript
import WebSocket from 'ws'
import { Relay, useWebSocketImplementation } from 'nostr-tools/relay'
import { finalizeEvent, getPublicKey } from 'nostr-tools/pure'
import * as nip19 from 'nostr-tools/nip19'
useWebSocketImplementation(WebSocket);
const relay = await Relay.connect('ws://192.168.1.1:4869');
console.log(`connected to ${relay.url}`)
const sk = nip19.decode('nsec1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa').data
const pk = getPublicKey(sk)
let eventCount = 0
let eventTemplate = {
kind: 5,
created_at: Math.floor(Date.now() / 1000),
tags: [],
content: 'Deleting all kind 10002 events',
}
relay.subscribe([
{
kinds: [10002],
authors: [pk],
},
], {
onevent(event) {
console.log('got event:', event)
eventTemplate.tags.push(['e', event.id], ['k', '10002'])
eventCount++
},
async oneose() {
console.log('Got', eventCount, 'events')
if (eventCount > 0) {
const signedEvent = finalizeEvent(eventTemplate, sk)
console.log('Deletion event:', signedEvent)
await relay.publish(signedEvent)
}
relay.close()
}
})
```