mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-19 11:17:27 +01:00
image generation: ratings from wot
This commit is contained in:
@@ -214,13 +214,15 @@ async function listen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//let dvm = store.state.nip89dvms.find(x => JSON.parse(x.event).pubkey === event.author.toHex())
|
//let dvm = store.state.nip89dvms.find(x => JSON.parse(x.event).pubkey === event.author.toHex())
|
||||||
|
|
||||||
|
|
||||||
for (const el of store.state.nip89dvms) {
|
for (const el of store.state.nip89dvms) {
|
||||||
if (JSON.parse(el.event).pubkey === event.author.toHex().toString()) {
|
if (JSON.parse(el.event).pubkey === event.author.toHex().toString()) {
|
||||||
jsonentry.name = el.name
|
jsonentry.name = el.name
|
||||||
jsonentry.about = el.about
|
jsonentry.about = el.about
|
||||||
jsonentry.image = el.image
|
jsonentry.image = el.image
|
||||||
jsonentry.nip90Params = el.nip90Params
|
jsonentry.nip90Params = el.nip90Params
|
||||||
jsonentry.reactions = await dvmreactions(PublicKey.parse(el.id))
|
jsonentry.reactions = await dvmreactions(PublicKey.parse(el.id), store.state.followings)
|
||||||
jsonentry.reactions.negativeUser = false
|
jsonentry.reactions.negativeUser = false
|
||||||
jsonentry.reactions.positiveUser = false
|
jsonentry.reactions.positiveUser = false
|
||||||
jsonentry.event = Event.fromJson(el.event)
|
jsonentry.event = Event.fromJson(el.event)
|
||||||
|
|||||||
@@ -871,6 +871,7 @@ export default {
|
|||||||
|
|
||||||
|
|
||||||
let followings = []
|
let followings = []
|
||||||
|
let ids = []
|
||||||
let followers_filter = new Filter().author(publicKey).kind(3).limit(1)
|
let followers_filter = new Filter().author(publicKey).kind(3).limit(1)
|
||||||
let followers = await dbclient.getEventsOf([followers_filter], Duration.fromSecs(5))
|
let followers = await dbclient.getEventsOf([followers_filter], Duration.fromSecs(5))
|
||||||
console.log(followers)
|
console.log(followers)
|
||||||
@@ -879,6 +880,7 @@ export default {
|
|||||||
if (tag.asVec()[0] === "p") {
|
if (tag.asVec()[0] === "p") {
|
||||||
let following = tag.asVec()[1]
|
let following = tag.asVec()[1]
|
||||||
followings.push(PublicKey.parse(following))
|
followings.push(PublicKey.parse(following))
|
||||||
|
ids.push((following))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,6 +891,8 @@ export default {
|
|||||||
let filter = new Filter().kind(0).authors(followings)
|
let filter = new Filter().kind(0).authors(followings)
|
||||||
|
|
||||||
|
|
||||||
|
store.commit('set_followings', ids)
|
||||||
|
|
||||||
await dbclient.reconcile(filter, opts);
|
await dbclient.reconcile(filter, opts);
|
||||||
console.log("Done syncing profiles")
|
console.log("Done syncing profiles")
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ export async function fetchAsync (url) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function dvmreactions(dvmid) {
|
export async function dvmreactions(dvmid, authors) {
|
||||||
let reactions = {
|
let reactions = {
|
||||||
positive: [],
|
positive: [],
|
||||||
negative: [],
|
negative: [],
|
||||||
@@ -391,27 +391,21 @@ export async function dvmreactions(dvmid) {
|
|||||||
|
|
||||||
let client = store.state.client
|
let client = store.state.client
|
||||||
|
|
||||||
if (store.state.dbclient.database === undefined){
|
let authorscheck = []
|
||||||
console.log("not logged in, not getting profile suggestions")
|
for (let author of authors){
|
||||||
return []
|
try{
|
||||||
|
authorscheck.push(PublicKey.parse(author))
|
||||||
|
}
|
||||||
|
catch{
|
||||||
|
console.log("err" + author)
|
||||||
}
|
}
|
||||||
let dbclient = store.state.dbclient
|
|
||||||
let profiles = []
|
|
||||||
let filter1 = new Filter().kind(0)
|
|
||||||
let users = await dbclient.database.query([filter1])
|
|
||||||
|
|
||||||
console.log(users)
|
|
||||||
|
|
||||||
let authors = []
|
|
||||||
for (const entry of users){
|
|
||||||
authors.push(entry.author)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let reactionfilter = new Filter().kind(7).pubkey (dvmid).authors(authors).since(Timestamp.fromSecs(Timestamp.now().asSecs() - 60*60*24*60)) // reactions by our followers in the last 2 months
|
|
||||||
|
let reactionfilter = new Filter().kind(7).pubkey (dvmid).authors(authorscheck).since(Timestamp.fromSecs(Timestamp.now().asSecs() - 60*60*24*60)) // reactions by our followers in the last 2 months
|
||||||
let evts = await client.getEventsOf([reactionfilter], Duration.fromSecs(5))
|
let evts = await client.getEventsOf([reactionfilter], Duration.fromSecs(5))
|
||||||
|
|
||||||
console.log(evts)
|
|
||||||
if (evts.length > 0){
|
if (evts.length > 0){
|
||||||
for (let reaction of evts){
|
for (let reaction of evts){
|
||||||
if (reaction.content === "👎"){
|
if (reaction.content === "👎"){
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const store = createStore({
|
|||||||
signer: NostrSigner,
|
signer: NostrSigner,
|
||||||
dbclient: Client,
|
dbclient: Client,
|
||||||
pubkey: PublicKey,
|
pubkey: PublicKey,
|
||||||
|
followings: [],
|
||||||
nooglekey: import.meta.env.VITE_NOOGLE_PK,
|
nooglekey: import.meta.env.VITE_NOOGLE_PK,
|
||||||
subscription_verifier_pubkey: import.meta.env.VITE_SUBSCRIPTIPON_VERIFIER_PUBKEY,
|
subscription_verifier_pubkey: import.meta.env.VITE_SUBSCRIPTIPON_VERIFIER_PUBKEY,
|
||||||
requestidSearch: String,
|
requestidSearch: String,
|
||||||
@@ -51,6 +52,10 @@ const store = createStore({
|
|||||||
set_pubkey(state, pubkey) {
|
set_pubkey(state, pubkey) {
|
||||||
state.pubkey = pubkey
|
state.pubkey = pubkey
|
||||||
},
|
},
|
||||||
|
set_followings(state, items) {
|
||||||
|
state.followings.length = 0
|
||||||
|
state.followings.push.apply(state.followings, items)
|
||||||
|
},
|
||||||
set_hasEventListener(state, hasEventListener) {
|
set_hasEventListener(state, hasEventListener) {
|
||||||
state.hasEventListener = hasEventListener
|
state.hasEventListener = hasEventListener
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user