diff --git a/ng-app/src/apps/ContactEditor.svelte b/ng-app/src/apps/ContactEditor.svelte index 9791dcd..8918893 100644 --- a/ng-app/src/apps/ContactEditor.svelte +++ b/ng-app/src/apps/ContactEditor.svelte @@ -90,21 +90,21 @@ } async function test() { - await on_qr_scanned("AgBX7NyrH_8cF47eeqkkFwtHFi-LrjrxOoRLNM0EScA1NAABANpOlaBYozbkSDVJFAUG2nSWSTXXD-wiLRG6ZUU23f8GCWFjY291bnQgNAEObmlrbzRAdHJ1ZS5jb20"); + await on_qr_scanned("AgBWW2hNMS_1xjz5Pvscq1QQ5D405EWRjoN70kIuAgNIqwABALRXYVWKYVaz6xqNqncU7D2HyheZKlFepLoJVE-xIbywB25pa28gMTMBD2ZpcmVmb3hAcHJvLmNvbQ"); }

Contact

-
+
--> {#if !has_camera && !has_name} No camera available. You cannot import with QR-code diff --git a/ng-app/src/apps/SocialQueryDemo.svelte b/ng-app/src/apps/SocialQueryDemo.svelte index 524ceec..2d8f5de 100644 --- a/ng-app/src/apps/SocialQueryDemo.svelte +++ b/ng-app/src/apps/SocialQueryDemo.svelte @@ -39,20 +39,24 @@ }, }; -const ranking_query = `SELECT ?mail (SAMPLE(?n) as?name) (MAX(?rust_) as ?rust) (MAX(?svelte_) as ?svelte) (MAX(?tailwind_) as ?tailwind) (MAX(?rdf_) as ?rdf) (MAX(?yjs_) as ?yjs) (MAX(?automerge_) as ?automerge) (SUM(?total_) as ?total) WHERE { - {SELECT ?mail (SAMPLE(?name) as ?n) ?skill (AVG(?value)+1 AS ?score) WHERE { - ?rating ?mail. - ?rating ?name. - ?rating ?hasrating. - ?hasrating ?value. - ?hasrating ?skill. -} GROUP BY ?mail ?skill } +const ranking_query = `SELECT ?mail (SAMPLE(?n) as?name) (MAX(?rust_) as ?rust) (MAX(?svelte_) as ?svelte) (MAX(?tailwind_) as ?tailwind) +(MAX(?rdf_) as ?rdf) (MAX(?yjs_) as ?yjs) (MAX(?automerge_) as ?automerge) (SUM(?total_) as ?total) +WHERE { + { SELECT ?mail (SAMPLE(?name) as ?n) ?skill (AVG(?value)+1 AS ?score) + WHERE { + ?rating ?mail. + ?rating ?name. + ?rating ?hasrating. + ?hasrating ?value. + ?hasrating ?skill. + } GROUP BY ?mail ?skill + } BIND (IF(sameTerm(?skill, ), ?score, 0) AS ?rust_) BIND (IF(sameTerm(?skill, ), ?score, 0) AS ?svelte_) BIND (IF(sameTerm(?skill, ), ?score, 0) AS ?tailwind_) BIND (IF(sameTerm(?skill, ), ?score, 0) AS ?rdf_) BIND (IF(sameTerm(?skill, ), ?score, 0) AS ?yjs_) - BIND (IF(sameTerm(?skill, ), ?score, 0) AS ?automerge_) + BIND (IF(sameTerm(?skill, ), ?score, 0) AS ?automerge_) BIND (?tailwind_+?svelte_+?rust_+?rdf_+?yjs_+?automerge_ AS ?total_) } GROUP BY ?mail ORDER BY DESC(?total)`; @@ -65,7 +69,7 @@ ORDER BY DESC(?total)`; $: if (commits.graph.length > 4) { sparql_query(ranking_query, false).then((res) => { - console.log(res.results?.bindings); + //console.log(res.results?.bindings); results = res.results?.bindings; }); } @@ -121,7 +125,7 @@ WHERE { "did:ng:a", request_nuri, "did:ng:d:c", - 2, + 0, ); } catch (e) { toast_error(display_error(e)); @@ -165,13 +169,13 @@ WHERE { {res.mail.value} {res.name.value} - {res.rust.value} - {res.svelte.value} - {res.tailwind.value} - {res.rdf.value} - {res.yjs.value} - {res.automerge.value} - {res.total.value} + {Math.round(res.rust.value * 10) / 10 } + {Math.round(res.svelte.value * 10) / 10 } + {Math.round(res.tailwind.value * 10) / 10 } + {Math.round(res.rdf.value * 10) / 10 } + {Math.round(res.yjs.value * 10) / 10 } + {Math.round(res.automerge.value * 10) / 10 } + {Math.round(res.total.value * 10) / 10 } {/each} diff --git a/ng-sdk-js/example-webapp-react-socialquery/package.json b/ng-sdk-js/example-webapp-react-socialquery/package.json index f2f0728..26d13c8 100644 --- a/ng-sdk-js/example-webapp-react-socialquery/package.json +++ b/ng-sdk-js/example-webapp-react-socialquery/package.json @@ -4,7 +4,7 @@ "version": "0.0.1", "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host", "build": "tsc --noEmit && vite build", "lint": "eslint .", "preview": "vite preview", diff --git a/ng-verifier/src/inbox_processor.rs b/ng-verifier/src/inbox_processor.rs index 8152416..f79c550 100644 --- a/ng-verifier/src/inbox_processor.rs +++ b/ng-verifier/src/inbox_processor.rs @@ -251,7 +251,7 @@ impl Verifier { //TODO: in case of errors here below, mark the forwarder as ng:social_query_error if sparql.is_none() { return Err(VerifierError::InvalidSocialQuery); } - log_info!("{}",sparql.as_ref().unwrap()); + //log_info!("{}",sparql.as_ref().unwrap()); let res = self.sparql_query(&NuriV0::new_entire_user_site(), sparql.unwrap(), None).await?; @@ -269,7 +269,7 @@ impl Verifier { } }; - log_info!("{:?}",results); + //log_info!("{:?}",results); // Do we have local results matching the request's query? If yes, we send them back to the forwarder right away if !results.is_empty() { @@ -303,13 +303,14 @@ impl Verifier { // getting the contacts to forward to let sparql = format!("PREFIX ng: + PREFIX vcard: SELECT ?profile_id ?inbox_id WHERE - {{ ?c ng:c \"social:contact\" . + {{ ?c a vcard:Individual . OPTIONAL {{ ?c ng:site ?profile_id . ?c ng:site_inbox ?inbox_id }} OPTIONAL {{ ?c ng:protected ?profile_id . ?c ng:protected_inbox ?inbox_id }} FILTER ( bound(?profile_id) && NOT EXISTS {{ ?c ng:site <{profile_id_nuri}> }} && NOT EXISTS {{ ?c ng:protected <{profile_id_nuri}> }} ) }}"); - log_info!("{sparql}"); + //log_info!("{sparql}"); let sols = match self.sparql_query( &NuriV0::new_entire_user_site(), sparql, None).await? @@ -319,7 +320,7 @@ impl Verifier { }; let degree = if req.degree == 0 { 0 } else { req.degree - 1 }; - log_info!("new degree {degree}"); + //log_info!("new degree {degree}"); let mut found_contact = false; let forwarder_id = forwarder_nuri.target.repo_id().clone(); @@ -353,7 +354,7 @@ impl Verifier { } } // if not found any contact, we stop here - log_info!("found contact {found_contact}"); + //log_info!("found contact {found_contact}"); if !found_contact { self.mark_social_query_forwarder(&forwarder_nuri_string, &forwarder_nuri, "social_query_ended".to_string()).await?; let post = InboxPost::new_social_query_response_replying_to( @@ -374,9 +375,11 @@ impl Verifier { return Err(VerifierError::InvalidSocialQuery) } - // TODO: first we open the response.forwarder_id (because in webapp, it might not be loaded yet) - let forwarder_nuri = NuriV0::new_repo_target_from_id(&response.forwarder_id); + + // TODO: first we open the response.forwarder_id (because in webapp, it might not be loaded yet) + //self.open_for_target(&forwarder_nuri.target, false).await?; + let forwarder_nuri_string = NuriV0::repo_id(&response.forwarder_id); // checking that we do have a running ForwardedSocialQuery, and that it didnt end, otherwise it must be spam. match self.sparql_query( &forwarder_nuri, format!("ASK {{ <> <{}> }} ", @@ -388,17 +391,17 @@ impl Verifier { &forwarder_nuri, "PREFIX ng: SELECT ?from_profile ?from_inbox ?from_forwarder ?ended WHERE - {{ <> ng:social_query_from_profile ?from_profile . - <> ng:social_query_from_inbox ?from_inbox . - <> ng:social_query_forwarder ?from_forwarder . - <> ng:social_query_ended ?ended . + {{ OPTIONAL {{ <> ng:social_query_from_profile ?from_profile . }} + OPTIONAL {{ <> ng:social_query_from_inbox ?from_inbox .}} + OPTIONAL {{ <> ng:social_query_forwarder ?from_forwarder .}} + OPTIONAL {{ <> ng:social_query_ended ?ended . }} }}".to_string(), Some(forwarder_nuri_string)).await? { QueryResults::Solutions(mut sols) => { match sols.next() { None => { - log_info!("at origin"); + //log_info!("at origin and not ended"); (None, None, None) } Some(Err(e)) => { @@ -442,7 +445,7 @@ impl Verifier { }}", NuriV0::inbox(&msg.body.from_inbox.unwrap()) ); - log_info!("{spar}"); + //log_info!("{spar}"); let token = match self.sparql_query( &forwarder_nuri, //<> ng:social_query_id <{}> NuriV0::inbox(&msg.body.from_inbox.unwrap()), @@ -470,7 +473,7 @@ impl Verifier { } _ => return Err(VerifierError::SparqlError(NgError::InvalidResponse.to_string())), }; - log_info!("token = {token}"); + //log_info!("token = {token}"); let at_origin = forwarded_from_profile.is_none() || forwarded_from_inbox.is_none() || from_forwarder.is_none(); diff --git a/ng-verifier/src/request_processor.rs b/ng-verifier/src/request_processor.rs index 0847c05..814d1e7 100644 --- a/ng-verifier/src/request_processor.rs +++ b/ng-verifier/src/request_processor.rs @@ -264,7 +264,7 @@ impl Verifier { } } - async fn open_for_target( + pub(crate) async fn open_for_target( &mut self, target: &NuriTargetV0, as_publisher: bool, @@ -823,7 +823,7 @@ impl Verifier { OPTIONAL {{ ?c ng:protected ?profile_id . ?c ng:protected_inbox ?inbox_id }} FILTER ( bound(?profile_id) {extra_conditions} ) }}"); - log_info!("{sparql}"); + //log_info!("{sparql}"); let sols = match self.sparql_query( &NuriV0::new_entire_user_site(), sparql, None).await? diff --git a/ng-verifier/src/verifier.rs b/ng-verifier/src/verifier.rs index d93b71f..cf75e25 100644 --- a/ng-verifier/src/verifier.rs +++ b/ng-verifier/src/verifier.rs @@ -1644,7 +1644,7 @@ impl Verifier { pub async fn inbox(&mut self, msg: InboxMsg, from_queue: bool) { - log_info!("RECEIVED INBOX MSG {:?}", msg); + //log_info!("RECEIVED INBOX MSG {:?}", msg); match self.inboxes.get(&msg.body.to_inbox) { Some(repo_id) => { @@ -1653,7 +1653,7 @@ impl Verifier { if let Some(privkey) = &repo.inbox { match msg.get_content(privkey) { Ok(content) => { - log_info!("received msg content {:?}", content); + //log_info!("received msg content {:?}", content); let res = self.process_inbox(msg, content).await; if let Err(e) = res { log_err!("Error during process_inbox {e}");