Skip to content

Commit

Permalink
chore: apply clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
olichwiruk committed Jul 10, 2023
1 parent bfdcd0f commit 50fd1f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
25 changes: 11 additions & 14 deletions src/routes/namespaces.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use said::version::Encode;
use std::collections::HashMap;
use rand::RngCore;
use oca_dag::data_storage::DataStorage;
use crate::ledger::Ledger;
use actix_web::{http::header::ContentType, web, HttpRequest, HttpResponse, HttpMessage};
use oca_rust::state::oca::{overlay, OCA};
use oca_rust::state::oca::OCA;
use serde::{Deserialize, Serialize};

use keri::keys::{PrivateKey, PublicKey};
use rand::rngs::OsRng;
use base64::{Engine as _, engine::{self, general_purpose}, alphabet};

use meilisearch_sdk::client::*;

use std::hash::Hash;

#[derive(Deserialize)]
pub struct SearchBundleQuery {
Expand All @@ -29,7 +25,7 @@ struct OCASearchIndex {
}

impl OCASearchIndex {
fn new(capture_base_said: String, name: String, description: String) -> Self {
fn _new(capture_base_said: String, name: String, description: String) -> Self {
Self {
uuid: uuid::Uuid::new_v4().to_string(),
capture_base_said,
Expand Down Expand Up @@ -92,21 +88,21 @@ pub async fn get_namespace(
db: web::Data<Box<dyn DataStorage>>,
req: HttpRequest,
) -> HttpResponse {
let mut result: HashMap<&str, serde_json::Value> = HashMap::new();
let result: HashMap<&str, serde_json::Value> = HashMap::new();
let namespace = req.match_info().get("namespace").unwrap();
let token = req.extensions().get::<String>().unwrap().clone();
println!("req: {req:?}");
println!("token: {}", token);

let public_key = db
let _public_key = db
.get(&format!("namespace.{namespace}.public_key"))
.unwrap()
.unwrap();

const CUSTOM_ENGINE: engine::GeneralPurpose =
engine::GeneralPurpose::new(&alphabet::URL_SAFE, general_purpose::NO_PAD);

let seed = CUSTOM_ENGINE.decode(token).unwrap();
let _seed = CUSTOM_ENGINE.decode(token).unwrap();

/*
let mut ed25519_seed = [0u8; 32];
Expand Down Expand Up @@ -141,7 +137,7 @@ pub async fn get_namespace(
pub async fn add_oca_file(
db: web::Data<Box<dyn DataStorage>>,
item: web::Bytes,
req: HttpRequest,
_req: HttpRequest,
) -> HttpResponse {
let oca_ast = oca_file::ocafile::parse_from_string(
String::from_utf8(item.to_vec()).unwrap()
Expand Down Expand Up @@ -174,6 +170,7 @@ pub async fn get_oca_file_history(
req: HttpRequest,
) -> HttpResponse {
let mut said = req.match_info().get("said").unwrap().to_string();
#[allow(clippy::borrowed_box)]
fn extract_operation(db: &Box<dyn DataStorage>, said: &String) -> (String, String) {
let r = db.get(&format!("oca.{}.operation", said)).unwrap().unwrap();

Expand Down Expand Up @@ -218,8 +215,8 @@ pub async fn get_oca_bundle(

pub async fn add_bundle(
db: web::Data<Box<dyn DataStorage>>,
search_engine_client: web::Data<Box<Client>>,
item: web::Json<OCA>,
_search_engine_client: web::Data<Box<Client>>,
_item: web::Json<OCA>,
req: HttpRequest,
) -> HttpResponse {
let namespace = req.match_info().get("namespace").unwrap();
Expand All @@ -229,9 +226,9 @@ pub async fn add_bundle(
engine::GeneralPurpose::new(&alphabet::URL_SAFE, general_purpose::NO_PAD);
let seed = CUSTOM_ENGINE.decode(token).unwrap();
let secret_key = ed25519_dalek::SecretKey::from_bytes(&seed).unwrap();
let public_key = ed25519_dalek::PublicKey::from(&secret_key);
let _public_key = ed25519_dalek::PublicKey::from(&secret_key);

let stored_public_key = db
let _stored_public_key = db
.get(&format!("namespace.{namespace}.public_key"))
.unwrap()
.unwrap();
Expand Down
3 changes: 1 addition & 2 deletions src/startup.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use actix_web::HttpResponse;
use oca_dag::data_storage::DataStorage;
use crate::routes::health_check;
use crate::routes::namespaces;
use std::sync::Arc;

use actix_web::dev::Server;
use actix_web::{dev::ServiceRequest, Error, web, App, HttpServer, HttpMessage};
use actix_web_httpauth::{extractors::{bearer::{BearerAuth, Config}, AuthenticationError}, middleware::HttpAuthentication};
use actix_web_httpauth::{extractors::{bearer::{BearerAuth}}, middleware::HttpAuthentication};
use std::net::TcpListener;

use meilisearch_sdk::client::*;
Expand Down

0 comments on commit 50fd1f2

Please sign in to comment.