~qaul/community

Prerequisite to file sharing API v1 PROPOSED

Dear team members:

I am abiding by the sacred rules and sending the changes asked by
Katharina, namely, to rename files.rs to types.rs. Hope you enjoy this
refactoring.

V1:

First of all, I hope you and your family is doing well in these times.

Second, Qaul is a great project and I hope this comes to fuition soon.

Third, I am sending this patch via email for two reasons -

1. I started working on the File sharing API. This patch is mostly a
prerequisite for that coming work as this refactors the code to move
the required File types from `libqaul/src/api` to
`libqaul/service/files` and "fixes" the `rpc` errors by pointing them
to the new Files types location.

2. Spacekookie loves patches by email and I kind enjoy stuff like this
myself. You should all try it too, she documented that here
https://spacekookie.de/blog/collaborating-with-git-send-email/. Makes
sense, given this project is truly decentralized comms, we do the code
sharing in a decentralized fashion. xD

Cheering for all of us!


Aman
(آمن  Apparently this is what they say my name is in Arabic script)

Amanjeev Sethi (1):
  service/files: refactors - files types to service/files

 Cargo.lock                                    | 16 ++++++-----
 libqaul/rpc/Cargo.toml                        |  4 ++-
 libqaul/rpc/src/api/files.rs                  |  3 ++-
 libqaul/service/files/Cargo.toml              |  1 +
 libqaul/service/files/src/lib.rs              | 22 +++++----------
 .../files.rs => service/files/src/types.rs}   | 27 +++++++++----------
 libqaul/src/api/mod.rs                        |  3 ---
 libqaul/src/files.rs                          |  3 ---
 libqaul/src/lib.rs                            |  1 -
 9 files changed, 34 insertions(+), 46 deletions(-)
 rename libqaul/{src/api/files.rs => service/files/src/types.rs} (86%)
 delete mode 100644 libqaul/src/files.rs

-- 
2.23.1
Katharina Fey
Amanjeev Sethi <aj@amanjeev.com> writes:
Next
My deepest thank you! On to now doing the actual work!

<yells at himself: move on from yak shaving for once!>

On Sun, May 24, 2020, at 10:54 AM, Katharina Fey wrote:
> Amanjeev Sethi <aj@amanjeev.com> writes:
> 
> > service/files: moves files types from libqaul to service/files
> 
> 
> Cool, thanks. Merged!
> 
> 
> ~k
> 
> Attachments:
> * signature.asc
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~qaul/community/patches/10779/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH 1/1] service/files: refactors - files types to service/files Export this patch

service/files: moves files types from libqaul to service/files
service/files: refactors name from files.rs to types.rs
---
 Cargo.lock                                    | 16 ++++++-----
 libqaul/rpc/Cargo.toml                        |  4 ++-
 libqaul/rpc/src/api/files.rs                  |  3 ++-
 libqaul/service/files/Cargo.toml              |  1 +
 libqaul/service/files/src/lib.rs              | 22 +++++----------
 .../files.rs => service/files/src/types.rs}   | 27 +++++++++----------
 libqaul/src/api/mod.rs                        |  3 ---
 libqaul/src/files.rs                          |  3 ---
 libqaul/src/lib.rs                            |  1 -
 9 files changed, 34 insertions(+), 46 deletions(-)
 rename libqaul/{src/api/files.rs => service/files/src/types.rs} (86%)
 delete mode 100644 libqaul/src/files.rs

diff --git a/Cargo.lock b/Cargo.lock
index 4dde908c..56fcd839 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -647,7 +647,7 @@ dependencies = [
 "clear_on_drop",
 "curve25519-dalek",
 "rand 0.7.3",
 "sha2 0.8.1",
 "sha2 0.8.2",
]

[[package]]
@@ -1180,9 +1180,9 @@ dependencies = [

[[package]]
name = "kv-log-macro"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a2d3beed37e5483887d81eb39de6de03a8346531410e1306ca48a9a89bd3a51"
checksum = "4ff57d6d215f7ca7eb35a9a64d656ba4d9d2bef114d741dc08048e75e2f5d418"
dependencies = [
 "log",
]
@@ -1315,6 +1315,7 @@ dependencies = [
 "futures 0.3.5",
 "libqaul",
 "qaul-chat",
 "qaul-files",
 "qaul-voices",
 "ratman",
 "ratman-harness",
@@ -1827,9 +1828,9 @@ checksum = "8e946095f9d3ed29ec38de908c22f95d9ac008e424c7bcae54c75a79c527c694"

[[package]]
name = "proc-macro2"
version = "1.0.15"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70a50b9351bfa8d65a7d93ce712dc63d2fd15ddbf2c36990fc7cac344859c04f"
checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101"
dependencies = [
 "unicode-xid",
]
@@ -1859,6 +1860,7 @@ dependencies = [
 "libqaul",
 "mime",
 "ratman-identity",
 "serde",
]

[[package]]
@@ -2246,9 +2248,9 @@ dependencies = [

[[package]]
name = "sha2"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0"
checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69"
dependencies = [
 "block-buffer 0.7.3",
 "digest 0.8.1",
diff --git a/libqaul/rpc/Cargo.toml b/libqaul/rpc/Cargo.toml
index a87ed046..80fd2751 100644
--- a/libqaul/rpc/Cargo.toml
+++ b/libqaul/rpc/Cargo.toml
@@ -6,14 +6,16 @@ authors = ["Katharina Fey <kookie@spacekookie.de>", "jess 3jane <me@jess.coffee>
edition = "2018"

[features]
default = ["proto", "json", "chat"]
default = ["proto", "json", "chat", "files", "voices"]
proto = ["capnp"]
json = ["serde_json"]
chat = ["qaul-chat"]
files = ["qaul-files"]
voices = ["qaul-voices"]

[dependencies]
qaul-chat = { path = "../service/chat", optional = true }
qaul-files = { path = "../service/files", optional = true }
qaul-voices = { path = "../service/voices", optional = true }

libqaul = { version = "*", path = ".." }
diff --git a/libqaul/rpc/src/api/files.rs b/libqaul/rpc/src/api/files.rs
index 24017f36..4d33b725 100644
--- a/libqaul/rpc/src/api/files.rs
+++ b/libqaul/rpc/src/api/files.rs
@@ -2,7 +2,8 @@

use crate::QaulRpc;
use async_trait::async_trait;
use libqaul::{files::FileFilter, users::UserAuth, Identity};
use libqaul::{users::UserAuth, Identity};
use qaul_files::types::FileFilter;

/// Send a file store query
#[derive(PartialEq)]
diff --git a/libqaul/service/files/Cargo.toml b/libqaul/service/files/Cargo.toml
index 82256735..b45944ce 100644
--- a/libqaul/service/files/Cargo.toml
+++ b/libqaul/service/files/Cargo.toml
@@ -9,3 +9,4 @@ license = "AGPL-3.0"
identity = { path = "../../../ratman/identity", package = "ratman-identity" }
libqaul = { path = "../../" }
mime = "0.3"
serde = { version = "1.0" }
diff --git a/libqaul/service/files/src/lib.rs b/libqaul/service/files/src/lib.rs
index 089621b6..3a801e83 100644
--- a/libqaul/service/files/src/lib.rs
+++ b/libqaul/service/files/src/lib.rs
@@ -1,26 +1,16 @@
//! `qaul.net` filesharing service
//!
//! Provides a simple interface to announce and broadcast binary
//! payload recipient messages.  Files can either be directly sent, or
//! they can be advertised, then pulled with a unique file ID,
//! contained in the announcement.

// #![allow(unused)]
use std::sync::Arc;

use libqaul::{error::Result, Qaul};
use std::sync::Arc;

const ASC_NAME: &'static str = "net.qaul.filesharing";
pub mod types;

// /// A typed file that can be sent across the network
// pub struct File {
//     pub name: String,
//     pub mime: Mime,
//     pub data: Vec<u8>,
// }
// TODO: Partial files
// TODO: file progress
// TODO: Download links with tokens

// // TODO: Partial files/ file progress
// // TODO: Download links with tokens
const ASC_NAME: &'static str = "net.qaul.filesharing";

/// Filesharing service state
#[derive(Clone)]
diff --git a/libqaul/src/api/files.rs b/libqaul/service/files/src/types.rs
similarity index 86%
rename from libqaul/src/api/files.rs
rename to libqaul/service/files/src/types.rs
index 2edc28bf..4ffb8e93 100644
--- a/libqaul/src/api/files.rs
+++ b/libqaul/service/files/src/types.rs
@@ -1,10 +1,9 @@
#![allow(unused)]

use crate::error::Result;
use crate::users::UserAuth;
use crate::Identity;
use serde::{Deserialize, Serialize};

use libqaul::error::Result;
use libqaul::Identity;
use libqaul::users::UserAuth;

pub type FileId = Identity;

/// Local file abstraction
@@ -74,37 +73,37 @@ pub struct Files<'chain> {
impl<'qaul> Files<'qaul> {
    /// Query the local file store for a specific constraint
    pub fn query<I>(&self, user: UserAuth, filter: FileFilter) -> Result<I>
    where
        I: Iterator<Item = FileMeta>,
        where
            I: Iterator<Item=FileMeta>,
    {
        self.q.auth.trusted(user)?;
        // self.q.auth.trusted(user)?;
        unimplemented!()
    }

    /// List all available files
    pub fn list<I>(&self, user: UserAuth) -> Result<I>
    where
        I: Iterator<Item = FileMeta>,
        where
            I: Iterator<Item=FileMeta>,
    {
        self.q.auth.trusted(user)?;
        // self.q.auth.trusted(user)?;
        unimplemented!()
    }

    /// Stream one particular file from storage
    pub async fn get(&self, user: UserAuth, file: FileId) -> Result<File> {
        self.q.auth.trusted(user)?;
        // self.q.auth.trusted(user)?;
        unimplemented!()
    }

    /// Adds a new file to the local user's storage
    pub fn add(&self, user: UserAuth, name: &str, file: File) -> Result<FileId> {
        self.q.auth.trusted(user)?;
        // self.q.auth.trusted(user)?;
        unimplemented!()
    }

    /// Delete a file from the local user store
    pub fn delete(&self, user: UserAuth, name: FileId) -> Result<()> {
        self.q.auth.trusted(user)?;
        // self.q.auth.trusted(user)?;
        unimplemented!()
    }
}
diff --git a/libqaul/src/api/mod.rs b/libqaul/src/api/mod.rs
index 1858c7eb..d8b5dc73 100644
--- a/libqaul/src/api/mod.rs
+++ b/libqaul/src/api/mod.rs
@@ -21,9 +21,6 @@
pub use contacts::Contacts;
pub(crate) mod contacts;

pub use files::Files;
pub(crate) mod files;

pub use messages::Messages;
pub(crate) mod messages;

diff --git a/libqaul/src/files.rs b/libqaul/src/files.rs
deleted file mode 100644
index fb2c3a19..00000000
--- a/libqaul/src/files.rs
@@ -1,3 +0,0 @@
//! API fascade module?

pub use crate::api::files::{FileFilter, FileId, FileMeta};
diff --git a/libqaul/src/lib.rs b/libqaul/src/lib.rs
index 1deeb379..a02ce205 100644
--- a/libqaul/src/lib.rs
+++ b/libqaul/src/lib.rs
@@ -50,7 +50,6 @@ mod utils;
pub mod api;
pub mod contacts;
pub mod error;
pub mod files;
pub mod messages;
pub mod services;
pub mod users;
-- 
2.23.1
Katharina Fey
Amanjeev Sethi <aj@amanjeev.com> writes: