diff --git a/nostr_dvm/tasks/discovery_inactive_follows.py b/nostr_dvm/tasks/discovery_inactive_follows.py index db05ac0..6ab55bc 100644 --- a/nostr_dvm/tasks/discovery_inactive_follows.py +++ b/nostr_dvm/tasks/discovery_inactive_follows.py @@ -25,8 +25,8 @@ Params: None class DiscoverInactiveFollows(DVMTaskInterface): KIND: Kind = EventDefinitions.KIND_NIP90_PEOPLE_DISCOVERY - TASK: str = "inactive-follows" - FIX_COST: float = 0 + TASK: str = "inactive-followings" + FIX_COST: float = 100 client: Client dvm_config: DVMConfig @@ -204,6 +204,7 @@ def build_example(name, identifier, admin_config): "name": name, "image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg", "about": "I discover users you follow, but that have been inactive on Nostr", + "action": "unfollow", #follow, mute, unmute "encryptionSupported": True, "cashuAccepted": True, "nip90Params": { diff --git a/ui/noogle/src/components/FilterGeneration.vue b/ui/noogle/src/components/FilterGeneration.vue new file mode 100644 index 0000000..2e993e9 --- /dev/null +++ b/ui/noogle/src/components/FilterGeneration.vue @@ -0,0 +1,1476 @@ + + + + + + + diff --git a/ui/noogle/src/components/ImageGeneration.vue b/ui/noogle/src/components/ImageGeneration.vue index 1cc45cd..01dbf6a 100644 --- a/ui/noogle/src/components/ImageGeneration.vue +++ b/ui/noogle/src/components/ImageGeneration.vue @@ -36,16 +36,11 @@ import StringUtil from "@/components/helper/string.ts"; let dvms =[] let hasmultipleinputs = false +let requestids = [] async function generate_image(message) { - if (!store.state.imagehasEventListener){ - store.commit('set_imagehasEventListener', true) - listen() - } - else{ - console.log("Already has event listener") - } + listen() try { if (message === undefined){ @@ -89,7 +84,8 @@ async function generate_image(message) { res = await amberSignerService.signEvent(draft) requestid = res.id - store.commit('set_current_request_id_image', requestid) + requestids.push(requestid) + store.commit('set_current_request_id_image', requestids) await client.sendEvent(Event.fromJson(JSON.stringify(res))) } @@ -106,7 +102,8 @@ async function generate_image(message) { let signedEvent = await (await client.signer()).signEvent(unsigned) console.log(signedEvent.id.toHex()) requestid = signedEvent.id.toHex() - store.commit('set_current_request_id_image', requestid) + requestids.push(requestid) + store.commit('set_current_request_id_image', requestids) await client.sendEvent(signedEvent) @@ -139,9 +136,7 @@ async function listen() { sleep(0).then(async () => { for (let tag in event.tags) { if (event.tags[tag].asVec()[0] === "e") { - //console.log("IMAGE ETAG: " + event.tags[tag].asVec()[1]) - //console.log("IMAGE LISTEN TO : " + store.state.requestidImage) - if (event.tags[tag].asVec()[1] === store.state.requestidImage) { + if (store.state.requestidImage.includes(event.tags[tag].asVec()[1])){ resonsetorequest = true } } @@ -182,7 +177,7 @@ async function listen() { jsonentry.bolt11 = event.tags[tag].asVec()[2] } else{ - let profiles = await get_user_infos([event.author]) + let profiles = await get_user_infos([event.author.toHex()]) let created = 0 let current console.log("NUM KIND0 FOUND " + profiles.length) diff --git a/ui/noogle/src/components/Login.vue b/ui/noogle/src/components/Login.vue index 0bef4f4..42508fb 100644 --- a/ui/noogle/src/components/Login.vue +++ b/ui/noogle/src/components/Login.vue @@ -189,7 +189,7 @@ import { Options, Duration, PublicKey, - Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits + Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits, Contact } from "@rust-nostr/nostr-sdk"; import VueNotifications from "vue-notifications"; import store from '../store'; @@ -372,7 +372,6 @@ export default { store.commit('set_client', client) store.commit('set_signer', this.signer) store.commit('set_pubkey', pubkey) - store.commit('set_hasEventListener', false) localStorage.setItem('nostr-key-method', "nostr-login") localStorage.setItem('nostr-key', pubkey.toHex()) console.log("Client Nip46 connected") @@ -426,7 +425,6 @@ export default { store.commit('set_client', client) store.commit('set_signer', this.signer) store.commit('set_pubkey', pubkey) - store.commit('set_hasEventListener', false) console.log("LOGINANON") localStorage.setItem('nostr-key-method', "anon") localStorage.setItem('nostr-key', "") @@ -489,7 +487,6 @@ export default { store.commit('set_client', client) store.commit('set_signer', this.signer) store.commit('set_pubkey', pubkey) - store.commit('set_hasEventListener', false) console.log("LOGIN with Key") localStorage.setItem('nostr-key-method', "nsec") localStorage.setItem('nostr-key', keys.publicKey.toHex()) @@ -557,7 +554,6 @@ export default { store.commit('set_client', client) store.commit('set_signer', this.signer) store.commit('set_pubkey', pubkey) - store.commit('set_hasEventListener', false) localStorage.setItem('nostr-key-method', "nip07") localStorage.setItem('nostr-key', pubkey.toHex()) @@ -629,7 +625,6 @@ export default { store.commit('set_client', client) store.commit('set_signer', this.signer) store.commit('set_pubkey', pubkey) - store.commit('set_hasEventListener', false) localStorage.setItem('nostr-key-method', "nip46") localStorage.setItem('nostr-key', connectionstring) console.log("Client connected") @@ -692,7 +687,6 @@ export default { store.commit('set_client', client) store.commit('set_signer', this.signer) store.commit('set_pubkey', publicKey) - store.commit('set_hasEventListener', false) localStorage.setItem('nostr-key-method', "android-signer") localStorage.setItem('nostr-key', hexKey) @@ -789,6 +783,10 @@ export default { jsonentry.encryptionSupported = false } + if(!jsonentry.action){ + jsonentry.action = "None" + } + if(!jsonentry.cashuAccepted){ jsonentry.cashuAccepted = false } @@ -904,7 +902,8 @@ export default { let opts = new NegentropyOptions().direction(direction); - let followings = [] + let followings = [] //TODO legacy, try to remove with contacts + let contacts = [] let ids = [] let followers_filter = new Filter().author(publicKey).kind(3).limit(1) let followers = await dbclient.getEventsOf([followers_filter], Duration.fromSecs(5)) @@ -917,19 +916,22 @@ export default { for (let tag of followers[0].tags) { if (tag.asVec()[0] === "p") { let following = tag.asVec()[1] + let contact = new Contact(PublicKey.parse(tag.asVec()[1]), tag.asVec()[2], tag.asVec()[3]) + contacts.push(contact) followings.push(PublicKey.parse(following)) - ids.push((following)) + ids.push(following) } } } - console.log("Followings: " + (followings.length).toString()) + console.log("Contacts: " + (contacts.length).toString()) //console.log(followings) let filter = new Filter().kind(0).authors(followings) store.commit('set_followings', ids) + store.commit('set_contacts', contacts) let mute_filter = new Filter().author(publicKey).kind(10000) let mutes = await dbclient.getEventsOf([mute_filter], Duration.fromSecs(5)) diff --git a/ui/noogle/src/components/Recommendation.vue b/ui/noogle/src/components/Recommendation.vue deleted file mode 100644 index 8325d33..0000000 --- a/ui/noogle/src/components/Recommendation.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - - - \ No newline at end of file diff --git a/ui/noogle/src/components/RecommendationGeneration.vue b/ui/noogle/src/components/RecommendationGeneration.vue index 4537a39..7e1e881 100644 --- a/ui/noogle/src/components/RecommendationGeneration.vue +++ b/ui/noogle/src/components/RecommendationGeneration.vue @@ -326,7 +326,7 @@ async function listen() { if (event.tags[tag].asVec().length > 2) { dvms.find(i => i.id === event.author.toHex()).bolt11 = event.tags[tag].asVec()[2] } else { - let profiles = await get_user_infos([event.author]) + let profiles = await get_user_infos([event.author.toHex()]) let created = 0 if (profiles.length > 0) { console.log(profiles[0].profile) @@ -408,7 +408,7 @@ async function listen() { for (const evt of events) { try{ - authors.push(evt.author) + authors.push(evt.author.toHex()) } catch(error){ //console.log(error) @@ -594,7 +594,8 @@ async function addAllContentDVMs() { bolt11: "", lud16: el.lud16, subscription: "", - nip88: el.nip88 + nip88: el.nip88, + action: el.action } @@ -638,7 +639,7 @@ async function addDVM(event){ jsonentry.bolt11 = event.tags[tag].asVec()[2] } else{ - let profiles = await get_user_infos([event.author]) + let profiles = await get_user_infos([event.author.toHex()]) let created = 0 if (profiles.length > 0){ // for (const profile of profiles){ @@ -1291,6 +1292,8 @@ const submitHandler = async () => { + + diff --git a/ui/noogle/src/components/Search.vue b/ui/noogle/src/components/Search.vue index 9315c5f..1dc83af 100644 --- a/ui/noogle/src/components/Search.vue +++ b/ui/noogle/src/components/Search.vue @@ -278,7 +278,7 @@ async function listen() { const events = await getEvents(entries) let authors = [] for (const evt of events) { - authors.push(evt.author) + authors.push(evt.author.toHex()) } if (authors.length > 0) { let profiles = await get_user_infos(authors) @@ -337,7 +337,7 @@ async function listen() { let authors = [] if (event_ptags.length > 0) { for (let ptag of event_ptags) { - authors.push(PublicKey.parse(ptag[1])) + authors.push(ptag[1]) } if (authors.length > 0) { diff --git a/ui/noogle/src/components/SummarizationGeneration.vue b/ui/noogle/src/components/SummarizationGeneration.vue index 479baba..2f997ba 100644 --- a/ui/noogle/src/components/SummarizationGeneration.vue +++ b/ui/noogle/src/components/SummarizationGeneration.vue @@ -32,15 +32,13 @@ import {zap} from "@/components/helper/Zap.vue"; import index from "vuex"; let dvms =[] +let requestids = [] async function summarizefeed(eventids) { - if (!store.state.summarizationhasEventListener){ - store.commit('set_summariarizationEventListener', true) - listen() - } - else{ - console.log("Already has event listener") - } + listen() + + + let sortedIds = eventids.sort(function(a,b) {return (a.index > b.index) ? 1 : ((b.index > a.index) ? -1 : 0);} ); try { @@ -94,8 +92,8 @@ let sortedIds = eventids.sort(function(a,b) {return (a.index > b.index) ? 1 : (( } - - store.commit('set_current_request_id_summarization', requestid) + requestids.push(requestid) + store.commit('set_current_request_id_summarization', requestids) } catch (error) { @@ -125,7 +123,7 @@ async function listen() { for (let tag in event.tags) { if (event.tags[tag].asVec()[0] === "e") { - if (event.tags[tag].asVec()[1] === store.state.requestidSummarization) { + if (store.state.requestidSummarization.includes(event.tags[tag].asVec()[1])){ resonsetorequest = true } } @@ -163,7 +161,7 @@ async function listen() { jsonentry.bolt11 = event.tags[tag].asVec()[2] } else{ - let profiles = await get_user_infos([event.author]) + let profiles = await get_user_infos([event.author.toHex()]) let created = 0 let current console.log("NUM KIND0 FOUND " + profiles.length) diff --git a/ui/noogle/src/components/helper/Helper.vue b/ui/noogle/src/components/helper/Helper.vue index b7741fb..2d68ae9 100644 --- a/ui/noogle/src/components/helper/Helper.vue +++ b/ui/noogle/src/components/helper/Helper.vue @@ -65,9 +65,7 @@ export async function react_to_dvm(dvm, reaction) { } - let pk = PublicKey.parse(store.state.pubkey.toHex()) - - let users = await get_user_infos([pk]) + let users = await get_user_infos([store.state.pubkey]) console.log(users[0]) if (reaction === "👎"){ dvm.reactions.negativeUser = true @@ -165,9 +163,13 @@ export function nextInput(e) { } export async function get_user_infos(pubkeys){ + let pkeys = [] + for (let pk of pubkeys){ + pkeys.push(PublicKey.parse(pk)) + } let profiles = [] let client = store.state.client - const profile_filter = new Filter().kind(0).authors(pubkeys) + const profile_filter = new Filter().kind(0).authors(pkeys) let evts = await client.getEventsOf([profile_filter], Duration.fromSecs(10)) for (const entry of evts){ @@ -351,7 +353,7 @@ export async function parseandreplacenpubs(note){ //console.log(pk.toBech32()) try{ let pk = PublicKey.parse(myArray[word].replace("nostr:", "")) - let profiles = await get_user_infos([pk]) + let profiles = await get_user_infos([pk.toHex()]) console.log(profiles) //console.log(profiles[0].profile.nip05) myArray[word] = profiles[0].profile.nip05 // replace with nip05 for now @@ -392,7 +394,7 @@ export async function parseandreplacenpubsName(note){ //console.log(pk.toBech32()) try{ let pk = PublicKey.parse(myArray[word].replace("nostr:", "")) - let profiles = await get_user_infos([pk]) + let profiles = await get_user_infos([pk.toHex()]) //console.log(profiles[0].profile.nip05) // myArray[word] = "" + profiles[0].profile.name + " " @@ -444,7 +446,7 @@ export async function dvmreactions(dvmid, authors) { let evts = await client.getEventsOf([reactionfilter], Duration.fromSecs(5)) let npubs = [] for (let evt of evts){ - npubs.push(evt.author) + npubs.push(evt.author.toHex()) } let users = await get_user_infos(npubs) diff --git a/ui/noogle/src/layouts/ThreeColumnLayout.vue b/ui/noogle/src/layouts/ThreeColumnLayout.vue index 58ab90e..07bc925 100644 --- a/ui/noogle/src/layouts/ThreeColumnLayout.vue +++ b/ui/noogle/src/layouts/ThreeColumnLayout.vue @@ -10,10 +10,14 @@ import {isVisible} from "bootstrap/js/src/util/index.js";
- Search +
+ Search Discover Create + Filter DVMs +
+
@@ -50,6 +54,16 @@ import {isVisible} from "bootstrap/js/src/util/index.js"; "aside" "footer"; + div.scroll { + margin: 4px; + padding: 4px; + background-color: #08c708; + width: 300px; + overflow-x: auto; + overflow-y: hidden; + white-space: nowrap; + } + header { grid-area: header; margin-top: 30px; diff --git a/ui/noogle/src/router/index.js b/ui/noogle/src/router/index.js index 54084d9..5f8c125 100644 --- a/ui/noogle/src/router/index.js +++ b/ui/noogle/src/router/index.js @@ -8,7 +8,9 @@ const routes = [ { path: "/donate", component: () => import("@/components/Donate.vue") }, { path: "/nip89", component: () => import("@/components/Nip89view.vue") }, { path: "/image", component: () => import("@/components/Image.vue") }, - { path: "/discover", component: () => import("@/components/Recommendation.vue") }, + { path: "/filter", component: () => import("@/components/FilterGeneration.vue") }, + + { path: "/discover", component: () => import("@/components/RecommendationGeneration.vue") }, { path: "/article/:id", component: () => import("@/components/Home.vue") }, { path: '/:pathMatch(.*)*', component: () => import("@/components/Home.vue") }, ]; diff --git a/ui/noogle/src/store.js b/ui/noogle/src/store.js index c961d62..2d386ca 100644 --- a/ui/noogle/src/store.js +++ b/ui/noogle/src/store.js @@ -10,31 +10,28 @@ const store = createStore({ dbclient: Client, pubkey: PublicKey, followings: [], + contacts: [], mutes: [], nooglekey: import.meta.env.VITE_NOOGLE_PK, subscription_verifier_pubkey: import.meta.env.VITE_SUBSCRIPTIPON_VERIFIER_PUBKEY, requestidSearch: String, requestidSearchProfile: String, - requestidImage: String, + requestidImage: [], requestidRecommendation: [], - requestidSummarization: String, - hasEventListener: false, - imagehasEventListener: false, - recommendationehasEventListener: false, - summarizationhasEventListener: false, + requestidSummarization: [], + requestidFilter: [], imagedvmreplies: [], nip89dvms: [], activesearchdvms: [], recommendationdvms: [], + filterdvms: [], summarizationdvms: [], results: [], profile_results: [], - relays: [ - "wss://relay.damus.io", - "wss://nos.lol", - "wss://pablof7z.nostr1.com", - - ], + relays: ["wss://relay.damus.io", "wss://nos.lol", "wss://nostr.wine", + "wss://nostr.mom", "wss://nostr.oxtr.dev", "wss://relay.nostr.bg", + "wss://pablof7z.nostr1.com", "wss://relay.nostr.net", "wss://140.f7z.io", + ], } }, mutations: { @@ -57,25 +54,17 @@ const store = createStore({ state.followings.length = 0 state.followings.push.apply(state.followings, items) }, + set_contacts(state, items) { + state.contacts.length = 0 + state.contacts.push.apply(state.contacts, items) + }, + + set_mutes(state, items) { state.mutes.length = 0 state.mutes.push.apply(state.mutes, items) }, - set_hasEventListener(state, hasEventListener) { - state.hasEventListener = hasEventListener - }, - set_imagehasEventListener(state, imagehasEventListener) { - state.imagehasEventListener = imagehasEventListener - }, - - set_recommendationEventListener(state, recommendationehasEventListener) { - state.recommendationehasEventListener = recommendationehasEventListener - }, - - set_summariarizationEventListener(state, summarizationhasEventListener) { - state.summarizationhasEventListener = summarizationhasEventListener - }, set_nip89dvms(state, nip89dvms) { state.nip89dvms.length = 0 @@ -91,9 +80,14 @@ const store = createStore({ }, set_current_request_id_summarization(state, requestid){ - state.requestidSummarization = String(requestid) + state.requestidSummarization.length = 0 + state.requestidSummarization.push.apply(state.requestidSummarization, requestid) }, + set_current_request_id_filter(state, requestid){ + state.requestidFilter.length = 0 + state.requestidFilter.push.apply(state.requestidFilter, requestid) + }, set_current_request_profile_id_search(state, requestid){ state.requestidSearchProfile = String(requestid) }, @@ -106,6 +100,11 @@ const store = createStore({ state.recommendationdvms.push.apply(state.recommendationdvms, dvms) }, + set_filter_dvms(state, dvms) { + state.filterdvms.length = 0 + state.filterdvms.push.apply(state.filterdvms, dvms) + }, + set_summarization_dvms(state, dvms) { state.summarizationdvms.length = 0 state.summarizationdvms.push.apply(state.summarizationdvms, dvms) @@ -115,7 +114,8 @@ const store = createStore({ state.profile_results.push.apply(state.profile_results, items) }, set_current_request_id_image(state, requestid){ - state.requestidImage = requestid + state.requestidImage.length = 0 + state.requestidImage.push.apply(state.requestidImage, requestid) }, set_current_request_id_recommendation(state, requestid){ state.requestidRecommendation.length = 0