mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-04-01 00:18:04 +02:00
get mute list, fix bug that prevented nip89s to be deleted after sdk update
This commit is contained in:
parent
41f3860f0e
commit
71dc7c2361
@ -4,7 +4,7 @@ from hashlib import sha256
|
||||
from pathlib import Path
|
||||
|
||||
import dotenv
|
||||
from nostr_sdk import Tag, Keys, EventBuilder, Filter, Alphabet, PublicKey, Client, EventId, SingleLetterTag
|
||||
from nostr_sdk import Tag, Keys, EventBuilder, Filter, Alphabet, PublicKey, Client, EventId, SingleLetterTag, Kind
|
||||
|
||||
from nostr_dvm.utils.definitions import EventDefinitions
|
||||
from nostr_dvm.utils.nostr_utils import send_event
|
||||
@ -59,8 +59,8 @@ def fetch_nip89_parameters_for_deletion(keys, eventid, client, dvmconfig):
|
||||
|
||||
def nip89_delete_announcement(eid: str, keys: Keys, dtag: str, client: Client, config):
|
||||
e_tag = Tag.parse(["e", eid])
|
||||
a_tag = Tag.parse(["a", str(EventDefinitions.KIND_ANNOUNCEMENT) + ":" + keys.public_key().to_hex() + ":" + dtag])
|
||||
event = EventBuilder(5, "", [e_tag, a_tag]).to_event(keys)
|
||||
a_tag = Tag.parse(["a", str(EventDefinitions.KIND_ANNOUNCEMENT.as_u64()) + ":" + keys.public_key().to_hex() + ":" + dtag])
|
||||
event = EventBuilder(Kind(5), "", [e_tag, a_tag]).to_event(keys)
|
||||
send_event(event, client, config)
|
||||
|
||||
|
||||
|
@ -23,6 +23,9 @@ def playground():
|
||||
admin_config = AdminConfig()
|
||||
admin_config.REBROADCAST_NIP89 = False
|
||||
admin_config.UPDATE_PROFILE = False
|
||||
#admin_config.DELETE_NIP89 = True
|
||||
#admin_config.PRIVKEY = ""
|
||||
#admin_config.EVENTID = ""
|
||||
|
||||
discovery_test_sub = content_discovery_currently_popular.build_example_subscription("Currently Popular Notes DVM (with Subscriptions)", "discovery_content_test", admin_config)
|
||||
discovery_test_sub.run()
|
||||
|
@ -204,6 +204,7 @@ import {loadNWCObject} from "@/components/helper/Zap.vue"
|
||||
import {useDark, useToggle} from "@vueuse/core";
|
||||
import {ref} from "vue";
|
||||
import {webln} from "@getalby/sdk";
|
||||
import {nip04Decrypt} from "@rust-nostr/nostr-sdk/pkg/nostr_sdk_js_bg.wasm.js";
|
||||
const isDark = useDark();
|
||||
|
||||
//const toggleDark = useToggle(isDark);
|
||||
@ -874,6 +875,10 @@ export default {
|
||||
let ids = []
|
||||
let followers_filter = new Filter().author(publicKey).kind(3).limit(1)
|
||||
let followers = await dbclient.getEventsOf([followers_filter], Duration.fromSecs(5))
|
||||
|
||||
|
||||
|
||||
|
||||
console.log(followers)
|
||||
if (followers.length > 0){
|
||||
for (let tag of followers[0].tags) {
|
||||
@ -887,12 +892,55 @@ export default {
|
||||
}
|
||||
console.log("Followings: " + (followings.length).toString())
|
||||
|
||||
console.log(followings)
|
||||
//console.log(followings)
|
||||
let filter = new Filter().kind(0).authors(followings)
|
||||
|
||||
|
||||
store.commit('set_followings', ids)
|
||||
|
||||
let mute_filter = new Filter().author(publicKey).kind(10000)
|
||||
let mutes = await dbclient.getEventsOf([mute_filter], Duration.fromSecs(5))
|
||||
let mutelist = []
|
||||
if(mutes.length > 0){
|
||||
|
||||
for (let list of mutes){
|
||||
|
||||
let client = store.state.client
|
||||
let signer = client.signer()
|
||||
|
||||
for (let tag of list.tags){
|
||||
if (tag.asVec()[0] === "p"){
|
||||
//console.log(tag.asVec()[1])
|
||||
mutelist.push(tag.asVec()[1])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Public mutes: " + mutelist.length)
|
||||
|
||||
//private mutes
|
||||
try {
|
||||
let content = await (await signer).nip04Decrypt(store.state.pubkey, list.content)
|
||||
let json = JSON.parse(content)
|
||||
for (let entry of json) {
|
||||
if (entry[0] === "p") {
|
||||
console.log(entry[1])
|
||||
mutelist.push(entry[1])
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(error){
|
||||
//console.log(error)
|
||||
}
|
||||
|
||||
|
||||
console.log("Overall mutes: " + mutelist.length)
|
||||
}
|
||||
store.commit('set_mutes', mutelist)
|
||||
}
|
||||
|
||||
|
||||
await dbclient.reconcile(filter, opts);
|
||||
console.log("Done syncing profiles")
|
||||
|
||||
|
@ -424,6 +424,15 @@ async function listen() {
|
||||
if(!evt){
|
||||
continue
|
||||
}
|
||||
if(store.state.mutes.find(record => record === evt.author.toHex()) !== undefined){
|
||||
console.log("hidding muted user")
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
|
||||
|
||||
let p = profiles.find(record => record.author === evt.author.toHex())
|
||||
let bech32id = evt.id.toBech32()
|
||||
let nip19 = new Nip19Event(evt.id, evt.author, store.state.relays)
|
||||
@ -441,6 +450,9 @@ async function listen() {
|
||||
if (items.find(e => e.id === evt.id.toHex()) === undefined) {
|
||||
|
||||
let react = zaps.find(x => x.id === evt.id.toHex())
|
||||
|
||||
|
||||
|
||||
items.push({
|
||||
id: evt.id.toHex(),
|
||||
content: await parseandreplacenpubsName(evt.content),
|
||||
@ -466,12 +478,14 @@ async function listen() {
|
||||
})
|
||||
index = index + 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (dvms.find(i => i.id === event.author.toHex()) === undefined) {
|
||||
|
||||
/* if (dvms.find(i => i.id === event.author.toHex()) === undefined) {
|
||||
await addDVM(event)
|
||||
console.log("add dvm because of bug")
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
dvms.find(i => i.id === event.author.toHex()).result.length = 0
|
||||
|
@ -10,6 +10,7 @@ const store = createStore({
|
||||
dbclient: Client,
|
||||
pubkey: PublicKey,
|
||||
followings: [],
|
||||
mutes: [],
|
||||
nooglekey: import.meta.env.VITE_NOOGLE_PK,
|
||||
subscription_verifier_pubkey: import.meta.env.VITE_SUBSCRIPTIPON_VERIFIER_PUBKEY,
|
||||
requestidSearch: String,
|
||||
@ -56,6 +57,11 @@ const store = createStore({
|
||||
state.followings.length = 0
|
||||
state.followings.push.apply(state.followings, items)
|
||||
},
|
||||
|
||||
set_mutes(state, items) {
|
||||
state.mutes.length = 0
|
||||
state.mutes.push.apply(state.mutes, items)
|
||||
},
|
||||
set_hasEventListener(state, hasEventListener) {
|
||||
state.hasEventListener = hasEventListener
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user