Move utils to mitra-utils crate
This commit is contained in:
parent
bcef9bb989
commit
7d3c558ede
77 changed files with 246 additions and 153 deletions
38
Cargo.lock
generated
38
Cargo.lock
generated
|
@ -1703,13 +1703,10 @@ dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"actix-web-httpauth",
|
"actix-web-httpauth",
|
||||||
"ammonia",
|
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64",
|
"base64",
|
||||||
"blake2",
|
"blake2",
|
||||||
"bs58",
|
|
||||||
"chrono",
|
"chrono",
|
||||||
"comrak",
|
|
||||||
"deadpool",
|
"deadpool",
|
||||||
"deadpool-postgres",
|
"deadpool-postgres",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
@ -1718,24 +1715,19 @@ dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"hex",
|
"hex",
|
||||||
"log",
|
"log",
|
||||||
"mime-sniffer",
|
"mitra-utils",
|
||||||
"mime_guess",
|
|
||||||
"monero-rpc",
|
"monero-rpc",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"pem",
|
|
||||||
"postgres-protocol",
|
"postgres-protocol",
|
||||||
"postgres-types",
|
"postgres-types",
|
||||||
"postgres_query",
|
"postgres_query",
|
||||||
"postgres_query_macro",
|
"postgres_query_macro",
|
||||||
"rand 0.8.4",
|
|
||||||
"refinery",
|
"refinery",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rsa",
|
"rsa",
|
||||||
"rust-argon2",
|
|
||||||
"secp256k1",
|
"secp256k1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_jcs",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"serial_test",
|
"serial_test",
|
||||||
|
@ -1744,7 +1736,6 @@ dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-postgres",
|
"tokio-postgres",
|
||||||
"ulid",
|
|
||||||
"url 2.2.2",
|
"url 2.2.2",
|
||||||
"uuid",
|
"uuid",
|
||||||
"web3",
|
"web3",
|
||||||
|
@ -1758,10 +1749,37 @@ dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"log",
|
"log",
|
||||||
"mitra",
|
"mitra",
|
||||||
|
"mitra-utils",
|
||||||
"tokio",
|
"tokio",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mitra-utils"
|
||||||
|
version = "1.13.1"
|
||||||
|
dependencies = [
|
||||||
|
"ammonia",
|
||||||
|
"base64",
|
||||||
|
"bs58",
|
||||||
|
"chrono",
|
||||||
|
"comrak",
|
||||||
|
"mime-sniffer",
|
||||||
|
"mime_guess",
|
||||||
|
"pem",
|
||||||
|
"rand 0.8.4",
|
||||||
|
"regex",
|
||||||
|
"rsa",
|
||||||
|
"rust-argon2",
|
||||||
|
"serde",
|
||||||
|
"serde_jcs",
|
||||||
|
"serde_json",
|
||||||
|
"sha2 0.9.9",
|
||||||
|
"thiserror",
|
||||||
|
"ulid",
|
||||||
|
"url 2.2.2",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "monero"
|
name = "monero"
|
||||||
version = "0.17.2"
|
version = "0.17.2"
|
||||||
|
|
23
Cargo.toml
23
Cargo.toml
|
@ -12,6 +12,7 @@ default-run = "mitra"
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
".",
|
".",
|
||||||
|
"mitra-utils",
|
||||||
"mitra-cli",
|
"mitra-cli",
|
||||||
]
|
]
|
||||||
default-members = [
|
default-members = [
|
||||||
|
@ -20,23 +21,19 @@ default-members = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
mitra-utils = { path = "mitra-utils" }
|
||||||
|
|
||||||
# Used to handle incoming HTTP requests
|
# Used to handle incoming HTTP requests
|
||||||
actix-cors = "0.6.2"
|
actix-cors = "0.6.2"
|
||||||
actix-files = "0.6.2"
|
actix-files = "0.6.2"
|
||||||
actix-web = "4.1.0"
|
actix-web = "4.1.0"
|
||||||
actix-web-httpauth = "0.8.0"
|
actix-web-httpauth = "0.8.0"
|
||||||
# Used for HTML sanitization
|
|
||||||
ammonia = "3.2.0"
|
|
||||||
# Used for catching errors
|
# Used for catching errors
|
||||||
anyhow = "1.0.58"
|
anyhow = "1.0.58"
|
||||||
# Used for working with RSA keys, HTTP signatures and file uploads
|
# Used for working with RSA keys, HTTP signatures and file uploads
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
# Used to decode base58btc
|
|
||||||
bs58 = "0.4.0"
|
|
||||||
# Used for working with dates
|
# Used for working with dates
|
||||||
chrono = { version = "0.4.23", default-features = false, features = ["std", "serde"] }
|
chrono = { version = "0.4.23", default-features = false, features = ["std", "serde"] }
|
||||||
# Used for parsing markdown
|
|
||||||
comrak = { version = "0.15.0", default-features = false }
|
|
||||||
# Used for pooling database connections
|
# Used for pooling database connections
|
||||||
deadpool = "0.9.2"
|
deadpool = "0.9.2"
|
||||||
deadpool-postgres = { version = "0.10.2", default-features = false }
|
deadpool-postgres = { version = "0.10.2", default-features = false }
|
||||||
|
@ -51,33 +48,23 @@ env_logger = { version = "0.9.0", default-features = false }
|
||||||
ed25519-dalek = "1.0.1"
|
ed25519-dalek = "1.0.1"
|
||||||
ed25519 = "1.5.2"
|
ed25519 = "1.5.2"
|
||||||
blake2 = "0.10.5"
|
blake2 = "0.10.5"
|
||||||
# Used to guess media type of a file
|
|
||||||
mime_guess = "2.0.3"
|
|
||||||
mime-sniffer = "0.1.2"
|
|
||||||
# Used to query Monero node
|
# Used to query Monero node
|
||||||
monero-rpc = "0.3.2"
|
monero-rpc = "0.3.2"
|
||||||
# Used to determine the number of CPUs on the system
|
# Used to determine the number of CPUs on the system
|
||||||
num_cpus = "1.13.0"
|
num_cpus = "1.13.0"
|
||||||
# Used for working with regular expressions
|
# Used for working with regular expressions
|
||||||
regex = "1.6.0"
|
regex = "1.6.0"
|
||||||
# Used to generate random numbers
|
|
||||||
rand = "0.8.4"
|
|
||||||
# Used for managing database migrations
|
# Used for managing database migrations
|
||||||
refinery = { version = "0.8.4", features = ["tokio-postgres"] }
|
refinery = { version = "0.8.4", features = ["tokio-postgres"] }
|
||||||
# Used for making async HTTP requests
|
# Used for making async HTTP requests
|
||||||
reqwest = { version = "0.11.10", features = ["json", "multipart", "socks"] }
|
reqwest = { version = "0.11.10", features = ["json", "multipart", "socks"] }
|
||||||
# Used for working with RSA keys
|
# Used for working with RSA keys
|
||||||
rsa = "0.5.0"
|
rsa = "0.5.0"
|
||||||
pem = "1.0.2"
|
|
||||||
# Used for hashing passwords
|
|
||||||
rust-argon2 = "1.0.0"
|
|
||||||
# Used for working with ethereum keys
|
# Used for working with ethereum keys
|
||||||
secp256k1 = { version = "0.21.3", features = ["rand", "rand-std"] }
|
secp256k1 = { version = "0.21.3", features = ["rand", "rand-std"] }
|
||||||
# Used for serialization/deserialization
|
# Used for serialization/deserialization
|
||||||
serde = { version = "1.0.136", features = ["derive"] }
|
serde = { version = "1.0.136", features = ["derive"] }
|
||||||
serde_json = "1.0.89"
|
serde_json = "1.0.89"
|
||||||
# Used to create JCS representations
|
|
||||||
serde_jcs = "0.1.0"
|
|
||||||
# Used to parse config file
|
# Used to parse config file
|
||||||
serde_yaml = "0.8.17"
|
serde_yaml = "0.8.17"
|
||||||
# Used to calculate SHA2 hashes
|
# Used to calculate SHA2 hashes
|
||||||
|
@ -97,15 +84,13 @@ postgres_query = { git = "https://github.com/nolanderc/rust-postgres-query", rev
|
||||||
postgres_query_macro = { git = "https://github.com/nolanderc/rust-postgres-query", rev = "b4422051c8a31fbba4a35f88004c1cefb1878dd5" }
|
postgres_query_macro = { git = "https://github.com/nolanderc/rust-postgres-query", rev = "b4422051c8a31fbba4a35f88004c1cefb1878dd5" }
|
||||||
# Used to work with URLs
|
# Used to work with URLs
|
||||||
url = "2.2.2"
|
url = "2.2.2"
|
||||||
# Used to generate lexicographically sortable IDs
|
|
||||||
ulid = { version = "1.0.0", features = ["uuid"] }
|
|
||||||
# Used to work with UUIDs
|
# Used to work with UUIDs
|
||||||
uuid = { version = "1.1.2", features = ["serde", "v4"] }
|
uuid = { version = "1.1.2", features = ["serde", "v4"] }
|
||||||
# Used to query ethereum node
|
# Used to query ethereum node
|
||||||
web3 = { version = "0.18.0", default-features = false, features = ["http", "http-tls", "signing"] }
|
web3 = { version = "0.18.0", default-features = false, features = ["http", "http-tls", "signing"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = { version = "0.8.4", features = ["small_rng"] }
|
mitra-utils = { path = "mitra-utils", features = ["test-utils"] }
|
||||||
serial_test = "0.7.0"
|
serial_test = "0.7.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -10,6 +10,7 @@ name = "mitractl"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
mitra-utils = { path = "../mitra-utils" }
|
||||||
mitra = { path = ".." }
|
mitra = { path = ".." }
|
||||||
|
|
||||||
# Used for catching errors
|
# Used for catching errors
|
||||||
|
|
|
@ -48,7 +48,7 @@ use mitra::monero::{
|
||||||
helpers::check_expired_invoice,
|
helpers::check_expired_invoice,
|
||||||
wallet::create_monero_wallet,
|
wallet::create_monero_wallet,
|
||||||
};
|
};
|
||||||
use mitra::utils::{
|
use mitra_utils::{
|
||||||
crypto_rsa::{
|
crypto_rsa::{
|
||||||
generate_rsa_key,
|
generate_rsa_key,
|
||||||
serialize_private_key,
|
serialize_private_key,
|
||||||
|
|
48
mitra-utils/Cargo.toml
Normal file
48
mitra-utils/Cargo.toml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
[package]
|
||||||
|
name = "mitra-utils"
|
||||||
|
version = "1.13.1"
|
||||||
|
license = "AGPL-3.0"
|
||||||
|
edition = "2021"
|
||||||
|
rust-version = "1.56"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
# Used for HTML sanitization
|
||||||
|
ammonia = "3.2.0"
|
||||||
|
# Used for working with RSA keys, HTTP signatures and file uploads
|
||||||
|
base64 = "0.13.0"
|
||||||
|
# Used to decode base58btc
|
||||||
|
bs58 = "0.4.0"
|
||||||
|
# Used for working with dates
|
||||||
|
chrono = { version = "0.4.23", default-features = false, features = ["std"] }
|
||||||
|
# Used for parsing markdown
|
||||||
|
comrak = { version = "0.15.0", default-features = false }
|
||||||
|
# Used to guess media type of a file
|
||||||
|
mime_guess = "2.0.3"
|
||||||
|
mime-sniffer = "0.1.2"
|
||||||
|
# Used to generate random numbers
|
||||||
|
rand = "0.8.4"
|
||||||
|
# Used for working with regular expressions
|
||||||
|
regex = "1.6.0"
|
||||||
|
# Used for working with RSA keys
|
||||||
|
rsa = "0.5.0"
|
||||||
|
pem = "1.0.2"
|
||||||
|
# Used for hashing passwords
|
||||||
|
rust-argon2 = "1.0.0"
|
||||||
|
# Used for serialization/deserialization
|
||||||
|
serde = { version = "1.0.136", features = ["derive"] }
|
||||||
|
serde_json = "1.0.89"
|
||||||
|
# Used to create JCS representations
|
||||||
|
serde_jcs = "0.1.0"
|
||||||
|
# Used to calculate SHA2 hashes
|
||||||
|
sha2 = "0.9.5"
|
||||||
|
# Used for creating error types
|
||||||
|
thiserror = "1.0.37"
|
||||||
|
# Used to generate lexicographically sortable IDs
|
||||||
|
ulid = { version = "1.0.0", features = ["uuid"] }
|
||||||
|
# Used to work with URLs
|
||||||
|
url = "2.2.2"
|
||||||
|
# Used to work with UUIDs
|
||||||
|
uuid = "1.1.2"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
test-utils = ["rand/small_rng"]
|
|
@ -8,7 +8,7 @@ pub fn generate_rsa_key() -> Result<RsaPrivateKey, rsa::errors::Error> {
|
||||||
RsaPrivateKey::new(&mut rng, bits)
|
RsaPrivateKey::new(&mut rng, bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(feature = "test-utils")]
|
||||||
pub fn generate_weak_rsa_key() -> Result<RsaPrivateKey, rsa::errors::Error> {
|
pub fn generate_weak_rsa_key() -> Result<RsaPrivateKey, rsa::errors::Error> {
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
let mut rng = rand::rngs::SmallRng::seed_from_u64(0);
|
let mut rng = rand::rngs::SmallRng::seed_from_u64(0);
|
|
@ -158,7 +158,7 @@ pub fn parse_extra_field(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::{
|
use mitra_utils::{
|
||||||
caip2::ChainId,
|
caip2::ChainId,
|
||||||
id::generate_ulid,
|
id::generate_ulid,
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,11 @@ use serde::{
|
||||||
};
|
};
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
crypto_rsa::{deserialize_private_key, get_public_key_pem},
|
||||||
|
urls::get_hostname,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
constants::{
|
constants::{
|
||||||
AP_CONTEXT,
|
AP_CONTEXT,
|
||||||
|
@ -31,10 +36,6 @@ use crate::models::{
|
||||||
},
|
},
|
||||||
users::types::User,
|
users::types::User,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
crypto_rsa::{deserialize_private_key, get_public_key_pem},
|
|
||||||
urls::get_hostname,
|
|
||||||
};
|
|
||||||
use crate::webfinger::types::ActorAddress;
|
use crate::webfinger::types::ActorAddress;
|
||||||
use super::attachments::{
|
use super::attachments::{
|
||||||
attach_extra_field,
|
attach_extra_field,
|
||||||
|
@ -378,11 +379,11 @@ pub fn get_instance_actor(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use mitra_utils::crypto_rsa::{
|
||||||
use crate::utils::crypto_rsa::{
|
|
||||||
generate_weak_rsa_key,
|
generate_weak_rsa_key,
|
||||||
serialize_private_key,
|
serialize_private_key,
|
||||||
};
|
};
|
||||||
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_HOSTNAME: &str = "example.com";
|
const INSTANCE_HOSTNAME: &str = "example.com";
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use actix_web::HttpRequest;
|
use actix_web::HttpRequest;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use mitra_utils::crypto_rsa::deserialize_public_key;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::{DatabaseClient, DatabaseError};
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::http_signatures::verify::{
|
use crate::http_signatures::verify::{
|
||||||
|
@ -21,7 +23,6 @@ use crate::models::{
|
||||||
profiles::queries::get_profile_by_remote_actor_id,
|
profiles::queries::get_profile_by_remote_actor_id,
|
||||||
profiles::types::DbActorProfile,
|
profiles::types::DbActorProfile,
|
||||||
};
|
};
|
||||||
use crate::utils::crypto_rsa::deserialize_public_key;
|
|
||||||
use super::fetcher::helpers::get_or_import_profile_by_actor_id;
|
use super::fetcher::helpers::get_or_import_profile_by_actor_id;
|
||||||
use super::receiver::HandlerError;
|
use super::receiver::HandlerError;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
deliverer::OutgoingActivity,
|
deliverer::OutgoingActivity,
|
||||||
|
@ -12,7 +14,6 @@ use crate::models::{
|
||||||
profiles::types::DbActorProfile,
|
profiles::types::DbActorProfile,
|
||||||
users::types::User,
|
users::types::User,
|
||||||
};
|
};
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct AcceptFollow {
|
struct AcceptFollow {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
deliverer::OutgoingActivity,
|
deliverer::OutgoingActivity,
|
||||||
|
@ -9,7 +11,6 @@ use crate::activitypub::{
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct AddOrRemovePerson {
|
struct AddOrRemovePerson {
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub fn prepare_follow(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::id::generate_ulid;
|
use mitra_utils::id::generate_ulid;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.com";
|
const INSTANCE_URL: &str = "https://example.com";
|
||||||
|
|
|
@ -112,7 +112,7 @@ pub async fn prepare_like(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::id::generate_ulid;
|
use mitra_utils::id::generate_ulid;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.com";
|
const INSTANCE_URL: &str = "https://example.com";
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
deliverer::OutgoingActivity,
|
deliverer::OutgoingActivity,
|
||||||
|
@ -10,7 +12,6 @@ use crate::activitypub::{
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::models::users::types::User;
|
use crate::models::users::types::User;
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct MovePerson {
|
pub struct MovePerson {
|
||||||
|
@ -77,8 +78,8 @@ pub fn prepare_move_person(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.com";
|
const INSTANCE_URL: &str = "https://example.com";
|
||||||
|
|
|
@ -90,7 +90,7 @@ pub async fn prepare_undo_announce(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::id::generate_ulid;
|
use mitra_utils::id::generate_ulid;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.com";
|
const INSTANCE_URL: &str = "https://example.com";
|
||||||
|
|
|
@ -87,7 +87,7 @@ pub fn prepare_undo_follow(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::id::generate_ulid;
|
use mitra_utils::id::generate_ulid;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.com";
|
const INSTANCE_URL: &str = "https://example.com";
|
||||||
|
|
|
@ -88,8 +88,8 @@ pub async fn prepare_undo_like(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
use crate::activitypub::constants::AP_PUBLIC;
|
use crate::activitypub::constants::AP_PUBLIC;
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.com";
|
const INSTANCE_URL: &str = "https://example.com";
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::{get_local_actor, Actor, ActorKeyError},
|
actors::types::{get_local_actor, Actor, ActorKeyError},
|
||||||
constants::AP_PUBLIC,
|
constants::AP_PUBLIC,
|
||||||
|
@ -15,7 +17,6 @@ use crate::models::{
|
||||||
relationships::queries::get_followers,
|
relationships::queries::get_followers,
|
||||||
users::types::User,
|
users::types::User,
|
||||||
};
|
};
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct UpdatePerson {
|
pub struct UpdatePerson {
|
||||||
|
@ -92,11 +93,11 @@ pub async fn prepare_update_person(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use mitra_utils::crypto_rsa::{
|
||||||
use crate::utils::crypto_rsa::{
|
|
||||||
generate_weak_rsa_key,
|
generate_weak_rsa_key,
|
||||||
serialize_private_key,
|
serialize_private_key,
|
||||||
};
|
};
|
||||||
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.com";
|
const INSTANCE_URL: &str = "https://example.com";
|
||||||
|
|
|
@ -8,6 +8,8 @@ use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
|
use mitra_utils::crypto_rsa::deserialize_private_key;
|
||||||
|
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
get_database_client,
|
get_database_client,
|
||||||
|
@ -28,7 +30,6 @@ use crate::models::{
|
||||||
profiles::queries::set_reachability_status,
|
profiles::queries::set_reachability_status,
|
||||||
users::types::User,
|
users::types::User,
|
||||||
};
|
};
|
||||||
use crate::utils::crypto_rsa::deserialize_private_key;
|
|
||||||
use super::actors::types::Actor;
|
use super::actors::types::Actor;
|
||||||
use super::constants::AP_MEDIA_TYPE;
|
use super::constants::AP_MEDIA_TYPE;
|
||||||
use super::identifiers::{local_actor_id, local_actor_key_id};
|
use super::identifiers::{local_actor_id, local_actor_key_id};
|
||||||
|
|
|
@ -4,6 +4,11 @@ use std::time::Duration;
|
||||||
use reqwest::{Client, Method, Proxy, RequestBuilder};
|
use reqwest::{Client, Method, Proxy, RequestBuilder};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
files::sniff_media_type,
|
||||||
|
urls::guess_protocol,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
constants::AP_MEDIA_TYPE,
|
constants::AP_MEDIA_TYPE,
|
||||||
|
@ -16,10 +21,6 @@ use crate::http_signatures::create::{
|
||||||
HttpSignatureError,
|
HttpSignatureError,
|
||||||
};
|
};
|
||||||
use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
|
use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
|
||||||
use crate::utils::{
|
|
||||||
files::sniff_media_type,
|
|
||||||
urls::guess_protocol,
|
|
||||||
};
|
|
||||||
use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor};
|
use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor};
|
||||||
|
|
||||||
const FETCHER_CONNECTION_TIMEOUT: u64 = 30;
|
const FETCHER_CONNECTION_TIMEOUT: u64 = 30;
|
||||||
|
|
|
@ -4,6 +4,11 @@ use chrono::Utc;
|
||||||
use serde_json::{Value as JsonValue};
|
use serde_json::{Value as JsonValue};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
html::clean_html,
|
||||||
|
urls::get_hostname,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
constants::{AP_MEDIA_TYPE, AP_PUBLIC, AS_MEDIA_TYPE},
|
constants::{AP_MEDIA_TYPE, AP_PUBLIC, AS_MEDIA_TYPE},
|
||||||
fetcher::fetchers::{fetch_file, FetchError},
|
fetcher::fetchers::{fetch_file, FetchError},
|
||||||
|
@ -49,10 +54,6 @@ use crate::models::{
|
||||||
profiles::types::DbActorProfile,
|
profiles::types::DbActorProfile,
|
||||||
users::queries::get_user_by_name,
|
users::queries::get_user_by_name,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
html::clean_html,
|
|
||||||
urls::get_hostname,
|
|
||||||
};
|
|
||||||
use super::HandlerResult;
|
use super::HandlerResult;
|
||||||
|
|
||||||
fn get_object_attributed_to(object: &Object)
|
fn get_object_attributed_to(object: &Object)
|
||||||
|
|
|
@ -116,7 +116,7 @@ pub fn parse_local_object_id(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::id::generate_ulid;
|
use mitra_utils::id::generate_ulid;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const INSTANCE_URL: &str = "https://example.org";
|
const INSTANCE_URL: &str = "https://example.org";
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
|
use mitra_utils::{
|
||||||
|
datetime::get_min_datetime,
|
||||||
|
html::{clean_html_all, escape_html},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::activitypub::identifiers::{local_actor_id, local_object_id};
|
use crate::activitypub::identifiers::{local_actor_id, local_object_id};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
posts::types::Post,
|
posts::types::Post,
|
||||||
profiles::types::DbActorProfile,
|
profiles::types::DbActorProfile,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
datetime::get_min_datetime,
|
|
||||||
html::{clean_html_all, escape_html},
|
|
||||||
};
|
|
||||||
|
|
||||||
const ENTRY_TITLE_MAX_LENGTH: usize = 75;
|
const ENTRY_TITLE_MAX_LENGTH: usize = 75;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::utils::caip2::{ChainId, ChainIdError};
|
use mitra_utils::caip2::{ChainId, ChainIdError};
|
||||||
|
|
||||||
fn default_chain_sync_step() -> u64 { 1000 }
|
fn default_chain_sync_step() -> u64 { 1000 }
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use rsa::RsaPrivateKey;
|
use rsa::RsaPrivateKey;
|
||||||
|
|
||||||
use crate::utils::{
|
use mitra_utils::{
|
||||||
crypto_rsa::{
|
crypto_rsa::{
|
||||||
deserialize_private_key,
|
deserialize_private_key,
|
||||||
generate_rsa_key,
|
generate_rsa_key,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use serde::{
|
||||||
};
|
};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::utils::urls::normalize_url;
|
use mitra_utils::urls::normalize_url;
|
||||||
|
|
||||||
use super::blockchain::BlockchainConfig;
|
use super::blockchain::BlockchainConfig;
|
||||||
use super::environment::Environment;
|
use super::environment::Environment;
|
||||||
|
@ -188,7 +188,7 @@ impl Instance {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
impl Instance {
|
impl Instance {
|
||||||
pub fn for_test(url: &str) -> Self {
|
pub fn for_test(url: &str) -> Self {
|
||||||
use crate::utils::crypto_rsa::generate_weak_rsa_key;
|
use mitra_utils::crypto_rsa::generate_weak_rsa_key;
|
||||||
Self {
|
Self {
|
||||||
_url: Url::parse(url).unwrap(),
|
_url: Url::parse(url).unwrap(),
|
||||||
actor_key: generate_weak_rsa_key().unwrap(),
|
actor_key: generate_weak_rsa_key().unwrap(),
|
||||||
|
@ -200,7 +200,7 @@ impl Instance {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::crypto_rsa::generate_weak_rsa_key;
|
use mitra_utils::crypto_rsa::generate_weak_rsa_key;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub fn verify_eip191_identity_proof(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use web3::signing::{Key, SecretKeyRef};
|
use web3::signing::{Key, SecretKeyRef};
|
||||||
|
use mitra_utils::currencies::Currency;
|
||||||
use crate::ethereum::{
|
use crate::ethereum::{
|
||||||
signatures::{
|
signatures::{
|
||||||
generate_ecdsa_key,
|
generate_ecdsa_key,
|
||||||
|
@ -43,7 +44,6 @@ mod tests {
|
||||||
},
|
},
|
||||||
utils::address_to_string,
|
utils::address_to_string,
|
||||||
};
|
};
|
||||||
use crate::utils::currencies::Currency;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const ETHEREUM: Currency = Currency::Ethereum;
|
const ETHEREUM: Currency = Currency::Ethereum;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use chrono::{DateTime, TimeZone, Utc};
|
use chrono::{DateTime, TimeZone, Utc};
|
||||||
|
|
||||||
use web3::{
|
use web3::{
|
||||||
api::Web3,
|
api::Web3,
|
||||||
contract::{Contract, Options},
|
contract::{Contract, Options},
|
||||||
|
@ -10,6 +9,11 @@ use web3::{
|
||||||
types::{BlockId, BlockNumber, FilterBuilder, U256},
|
types::{BlockId, BlockNumber, FilterBuilder, U256},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
caip2::ChainId,
|
||||||
|
currencies::Currency,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
builders::{
|
builders::{
|
||||||
add_person::prepare_add_person,
|
add_person::prepare_add_person,
|
||||||
|
@ -48,10 +52,6 @@ use crate::models::{
|
||||||
},
|
},
|
||||||
users::types::User,
|
users::types::User,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
caip2::ChainId,
|
|
||||||
currencies::Currency,
|
|
||||||
};
|
|
||||||
use super::contracts::ContractSet;
|
use super::contracts::ContractSet;
|
||||||
use super::errors::EthereumError;
|
use super::errors::EthereumError;
|
||||||
use super::signatures::{
|
use super::signatures::{
|
||||||
|
|
|
@ -3,7 +3,8 @@ use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use web3::{api::Web3, transports::Http, types::Address};
|
use web3::{api::Web3, transports::Http, types::Address};
|
||||||
|
|
||||||
use crate::utils::files::write_file;
|
use mitra_utils::files::write_file;
|
||||||
|
|
||||||
use super::errors::EthereumError;
|
use super::errors::EthereumError;
|
||||||
|
|
||||||
const BLOCK_NUMBER_FILE_NAME: &str = "current_block";
|
const BLOCK_NUMBER_FILE_NAME: &str = "current_block";
|
||||||
|
|
|
@ -2,7 +2,7 @@ use actix_web::http::Method;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use rsa::RsaPrivateKey;
|
use rsa::RsaPrivateKey;
|
||||||
|
|
||||||
use crate::utils::crypto_rsa::{
|
use mitra_utils::crypto_rsa::{
|
||||||
create_rsa_signature,
|
create_rsa_signature,
|
||||||
get_message_digest,
|
get_message_digest,
|
||||||
};
|
};
|
||||||
|
@ -92,7 +92,7 @@ pub fn create_http_signature(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::crypto_rsa::generate_weak_rsa_key;
|
use mitra_utils::crypto_rsa::generate_weak_rsa_key;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -5,7 +5,7 @@ use chrono::{DateTime, Duration, TimeZone, Utc};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rsa::RsaPublicKey;
|
use rsa::RsaPublicKey;
|
||||||
|
|
||||||
use crate::utils::crypto_rsa::verify_rsa_signature;
|
use mitra_utils::crypto_rsa::verify_rsa_signature;
|
||||||
|
|
||||||
const SIGNATURE_PARAMETER_RE: &str = r#"^(?P<key>[a-zA-Z]+)="(?P<value>.+)"$"#;
|
const SIGNATURE_PARAMETER_RE: &str = r#"^(?P<key>[a-zA-Z]+)="(?P<value>.+)"$"#;
|
||||||
|
|
||||||
|
@ -152,8 +152,8 @@ mod tests {
|
||||||
header::{HeaderMap, HeaderName, HeaderValue},
|
header::{HeaderMap, HeaderName, HeaderValue},
|
||||||
Uri,
|
Uri,
|
||||||
};
|
};
|
||||||
|
use mitra_utils::crypto_rsa::generate_weak_rsa_key;
|
||||||
use crate::http_signatures::create::create_http_signature;
|
use crate::http_signatures::create::create_http_signature;
|
||||||
use crate::utils::crypto_rsa::generate_weak_rsa_key;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::utils::canonicalization::{
|
use mitra_utils::canonicalization::{
|
||||||
canonicalize_object,
|
canonicalize_object,
|
||||||
CanonicalizationError,
|
CanonicalizationError,
|
||||||
};
|
};
|
||||||
|
@ -30,8 +30,8 @@ pub fn create_identity_claim(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use mitra_utils::currencies::Currency;
|
||||||
use crate::identity::did_pkh::DidPkh;
|
use crate::identity::did_pkh::DidPkh;
|
||||||
use crate::utils::currencies::Currency;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -4,10 +4,11 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::utils::multibase::{
|
use mitra_utils::multibase::{
|
||||||
decode_multibase_base58btc,
|
decode_multibase_base58btc,
|
||||||
encode_multibase_base58btc,
|
encode_multibase_base58btc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::did::DidParseError;
|
use super::did::DidParseError;
|
||||||
|
|
||||||
const DID_KEY_RE: &str = r"did:key:(?P<key>z[a-km-zA-HJ-NP-Z1-9]+)";
|
const DID_KEY_RE: &str = r"did:key:(?P<key>z[a-km-zA-HJ-NP-Z1-9]+)";
|
||||||
|
|
|
@ -4,8 +4,11 @@ use std::str::FromStr;
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::utils::caip2::ChainId;
|
use mitra_utils::{
|
||||||
use crate::utils::currencies::Currency;
|
caip2::ChainId,
|
||||||
|
currencies::Currency,
|
||||||
|
};
|
||||||
|
|
||||||
use super::did::DidParseError;
|
use super::did::DidParseError;
|
||||||
|
|
||||||
// https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md#syntax
|
// https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md#syntax
|
||||||
|
|
|
@ -5,6 +5,8 @@ use anyhow::Error;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::datetime::days_before_now;
|
||||||
|
|
||||||
use crate::activitypub::queues::{
|
use crate::activitypub::queues::{
|
||||||
process_queued_incoming_activities,
|
process_queued_incoming_activities,
|
||||||
process_queued_outgoing_activities,
|
process_queued_outgoing_activities,
|
||||||
|
@ -28,7 +30,6 @@ use crate::models::{
|
||||||
get_profile_by_id,
|
get_profile_by_id,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::utils::datetime::days_before_now;
|
|
||||||
|
|
||||||
pub async fn nft_monitor(
|
pub async fn nft_monitor(
|
||||||
maybe_blockchain: Option<&mut Blockchain>,
|
maybe_blockchain: Option<&mut Blockchain>,
|
||||||
|
|
|
@ -3,6 +3,15 @@ use rsa::RsaPrivateKey;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
canonicalization::{
|
||||||
|
canonicalize_object,
|
||||||
|
CanonicalizationError,
|
||||||
|
},
|
||||||
|
crypto_rsa::create_rsa_signature,
|
||||||
|
multibase::encode_multibase_base58btc,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::identity::{
|
use crate::identity::{
|
||||||
did_key::DidKey,
|
did_key::DidKey,
|
||||||
did_pkh::DidPkh,
|
did_pkh::DidPkh,
|
||||||
|
@ -12,14 +21,6 @@ use crate::identity::{
|
||||||
PROOF_TYPE_JCS_RSA,
|
PROOF_TYPE_JCS_RSA,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
canonicalization::{
|
|
||||||
canonicalize_object,
|
|
||||||
CanonicalizationError,
|
|
||||||
},
|
|
||||||
crypto_rsa::create_rsa_signature,
|
|
||||||
multibase::encode_multibase_base58btc,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub(super) const PROOF_KEY: &str = "proof";
|
pub(super) const PROOF_KEY: &str = "proof";
|
||||||
pub(super) const PROOF_PURPOSE: &str = "assertionMethod";
|
pub(super) const PROOF_PURPOSE: &str = "assertionMethod";
|
||||||
|
@ -133,7 +134,7 @@ pub fn is_object_signed(object: &Value) -> bool {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use crate::utils::crypto_rsa::generate_weak_rsa_key;
|
use mitra_utils::crypto_rsa::generate_weak_rsa_key;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -4,6 +4,15 @@ use rsa::RsaPublicKey;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
canonicalization::{
|
||||||
|
canonicalize_object,
|
||||||
|
CanonicalizationError,
|
||||||
|
},
|
||||||
|
crypto_rsa::verify_rsa_signature,
|
||||||
|
multibase::{decode_multibase_base58btc, MultibaseError},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::ethereum::identity::verify_eip191_signature;
|
use crate::ethereum::identity::verify_eip191_signature;
|
||||||
use crate::identity::{
|
use crate::identity::{
|
||||||
did::Did,
|
did::Did,
|
||||||
|
@ -12,14 +21,6 @@ use crate::identity::{
|
||||||
minisign::verify_ed25519_signature,
|
minisign::verify_ed25519_signature,
|
||||||
signatures::SignatureType,
|
signatures::SignatureType,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
canonicalization::{
|
|
||||||
canonicalize_object,
|
|
||||||
CanonicalizationError,
|
|
||||||
},
|
|
||||||
crypto_rsa::verify_rsa_signature,
|
|
||||||
multibase::{decode_multibase_base58btc, MultibaseError},
|
|
||||||
};
|
|
||||||
use super::create::{
|
use super::create::{
|
||||||
IntegrityProof,
|
IntegrityProof,
|
||||||
PROOF_KEY,
|
PROOF_KEY,
|
||||||
|
@ -132,11 +133,11 @@ pub fn verify_ed25519_json_signature(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use crate::json_signatures::create::sign_object;
|
use mitra_utils::{
|
||||||
use crate::utils::{
|
|
||||||
crypto_rsa::generate_weak_rsa_key,
|
crypto_rsa::generate_weak_rsa_key,
|
||||||
currencies::Currency,
|
currencies::Currency,
|
||||||
};
|
};
|
||||||
|
use crate::json_signatures::create::sign_object;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -16,6 +16,5 @@ pub mod media;
|
||||||
pub mod models;
|
pub mod models;
|
||||||
pub mod monero;
|
pub mod monero;
|
||||||
pub mod nodeinfo;
|
pub mod nodeinfo;
|
||||||
pub mod utils;
|
|
||||||
pub mod webfinger;
|
pub mod webfinger;
|
||||||
pub mod web_client;
|
pub mod web_client;
|
||||||
|
|
|
@ -4,6 +4,8 @@ use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::markdown::markdown_basic_to_html;
|
||||||
|
|
||||||
use crate::errors::{HttpError, ValidationError};
|
use crate::errors::{HttpError, ValidationError};
|
||||||
use crate::identity::did::Did;
|
use crate::identity::did::Did;
|
||||||
use crate::mastodon_api::{
|
use crate::mastodon_api::{
|
||||||
|
@ -28,7 +30,6 @@ use crate::models::{
|
||||||
User,
|
User,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::utils::markdown::markdown_basic_to_html;
|
|
||||||
|
|
||||||
/// https://docs.joinmastodon.org/entities/field/
|
/// https://docs.joinmastodon.org/entities/field/
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
|
|
@ -5,6 +5,18 @@ use actix_web::{
|
||||||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
caip2::ChainId,
|
||||||
|
canonicalization::canonicalize_object,
|
||||||
|
crypto_rsa::{
|
||||||
|
generate_rsa_key,
|
||||||
|
serialize_private_key,
|
||||||
|
},
|
||||||
|
currencies::Currency,
|
||||||
|
id::generate_ulid,
|
||||||
|
passwords::hash_password,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::activitypub::builders::{
|
use crate::activitypub::builders::{
|
||||||
undo_follow::prepare_undo_follow,
|
undo_follow::prepare_undo_follow,
|
||||||
update_person::{
|
update_person::{
|
||||||
|
@ -75,17 +87,6 @@ use crate::models::{
|
||||||
},
|
},
|
||||||
users::types::{Role, UserCreateData},
|
users::types::{Role, UserCreateData},
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
caip2::ChainId,
|
|
||||||
canonicalization::canonicalize_object,
|
|
||||||
crypto_rsa::{
|
|
||||||
generate_rsa_key,
|
|
||||||
serialize_private_key,
|
|
||||||
},
|
|
||||||
currencies::Currency,
|
|
||||||
id::generate_ulid,
|
|
||||||
passwords::hash_password,
|
|
||||||
};
|
|
||||||
use super::helpers::{follow_or_create_request, get_relationship};
|
use super::helpers::{follow_or_create_request, get_relationship};
|
||||||
use super::types::{
|
use super::types::{
|
||||||
Account,
|
Account,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::{to_value, Value};
|
use serde_json::{to_value, Value};
|
||||||
|
|
||||||
|
use mitra_utils::markdown::markdown_to_html;
|
||||||
|
|
||||||
use crate::config::{
|
use crate::config::{
|
||||||
BlockchainConfig,
|
BlockchainConfig,
|
||||||
Config,
|
Config,
|
||||||
|
@ -14,7 +16,6 @@ use crate::mastodon_api::{
|
||||||
};
|
};
|
||||||
use crate::media::SUPPORTED_MEDIA_TYPES;
|
use crate::media::SUPPORTED_MEDIA_TYPES;
|
||||||
use crate::models::posts::validators::ATTACHMENTS_MAX_NUM;
|
use crate::models::posts::validators::ATTACHMENTS_MAX_NUM;
|
||||||
use crate::utils::markdown::markdown_to_html;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct InstanceStats {
|
struct InstanceStats {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
use crate::utils::random::generate_random_sequence;
|
use mitra_utils::random::generate_random_sequence;
|
||||||
|
|
||||||
pub fn render_authorization_page() -> String {
|
pub fn render_authorization_page() -> String {
|
||||||
let page = r#"<!DOCTYPE html>
|
let page = r#"<!DOCTYPE html>
|
||||||
|
|
|
@ -10,6 +10,8 @@ use actix_web::{
|
||||||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
|
|
||||||
|
use mitra_utils::passwords::verify_password;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::{get_database_client, DatabaseError, DbPool};
|
use crate::database::{get_database_client, DatabaseError, DbPool};
|
||||||
use crate::errors::{HttpError, ValidationError};
|
use crate::errors::{HttpError, ValidationError};
|
||||||
|
@ -30,7 +32,6 @@ use crate::models::{
|
||||||
get_user_by_login_address,
|
get_user_by_login_address,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::utils::passwords::verify_password;
|
|
||||||
use super::auth::get_current_user;
|
use super::auth::get_current_user;
|
||||||
use super::types::{
|
use super::types::{
|
||||||
AuthorizationRequest,
|
AuthorizationRequest,
|
||||||
|
|
|
@ -3,6 +3,8 @@ use std::str::FromStr;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
use mitra_utils::currencies::Currency;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
fetcher::helpers::{
|
fetcher::helpers::{
|
||||||
get_or_import_profile_by_actor_id,
|
get_or_import_profile_by_actor_id,
|
||||||
|
@ -34,7 +36,6 @@ use crate::models::{
|
||||||
types::User,
|
types::User,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::utils::currencies::Currency;
|
|
||||||
use crate::webfinger::types::ActorAddress;
|
use crate::webfinger::types::ActorAddress;
|
||||||
|
|
||||||
enum SearchQuery {
|
enum SearchQuery {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use actix_web::{get, post, web, HttpResponse, Scope};
|
use actix_web::{get, post, web, HttpResponse, Scope};
|
||||||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||||
|
|
||||||
|
use mitra_utils::passwords::hash_password;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
builders::{
|
builders::{
|
||||||
move_person::prepare_move_person,
|
move_person::prepare_move_person,
|
||||||
|
@ -20,7 +22,6 @@ use crate::models::{
|
||||||
relationships::queries::{follow, unfollow},
|
relationships::queries::{follow, unfollow},
|
||||||
users::queries::set_user_password,
|
users::queries::set_user_password,
|
||||||
};
|
};
|
||||||
use crate::utils::passwords::hash_password;
|
|
||||||
use super::helpers::{
|
use super::helpers::{
|
||||||
export_followers,
|
export_followers,
|
||||||
export_follows,
|
export_follows,
|
||||||
|
|
|
@ -4,6 +4,11 @@ use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
currencies::Currency,
|
||||||
|
markdown::markdown_lite_to_html,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::activitypub::builders::{
|
use crate::activitypub::builders::{
|
||||||
announce::prepare_announce,
|
announce::prepare_announce,
|
||||||
create_note::prepare_create_note,
|
create_note::prepare_create_note,
|
||||||
|
@ -45,10 +50,6 @@ use crate::models::{
|
||||||
},
|
},
|
||||||
relationships::queries::get_subscribers,
|
relationships::queries::get_subscribers,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
currencies::Currency,
|
|
||||||
markdown::markdown_lite_to_html,
|
|
||||||
};
|
|
||||||
use super::helpers::{
|
use super::helpers::{
|
||||||
build_status,
|
build_status,
|
||||||
build_status_list,
|
build_status_list,
|
||||||
|
|
|
@ -2,6 +2,8 @@ use actix_web::{get, post, web, HttpResponse, Scope};
|
||||||
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
use actix_web_httpauth::extractors::bearer::BearerAuth;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::currencies::Currency;
|
||||||
|
|
||||||
use crate::activitypub::builders::update_person::prepare_update_person;
|
use crate::activitypub::builders::update_person::prepare_update_person;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::database::{get_database_client, DbPool};
|
use crate::database::{get_database_client, DbPool};
|
||||||
|
@ -37,7 +39,6 @@ use crate::monero::{
|
||||||
helpers::validate_monero_address,
|
helpers::validate_monero_address,
|
||||||
wallet::create_monero_address,
|
wallet::create_monero_address,
|
||||||
};
|
};
|
||||||
use crate::utils::currencies::Currency;
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
Invoice,
|
Invoice,
|
||||||
InvoiceData,
|
InvoiceData,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
use mitra_utils::files::sniff_media_type;
|
||||||
|
|
||||||
use crate::errors::HttpError;
|
use crate::errors::HttpError;
|
||||||
use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
|
use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
|
||||||
use crate::utils::files::sniff_media_type;
|
|
||||||
|
|
||||||
pub const UPLOAD_MAX_SIZE: usize = 1024 * 1024 * 5;
|
pub const UPLOAD_MAX_SIZE: usize = 1024 * 1024 * 5;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::path::Path;
|
||||||
|
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
|
|
||||||
use crate::utils::files::{get_media_type_extension, write_file};
|
use mitra_utils::files::{get_media_type_extension, write_file};
|
||||||
|
|
||||||
pub const SUPPORTED_MEDIA_TYPES: [&str; 8] = [
|
pub const SUPPORTED_MEDIA_TYPES: [&str; 8] = [
|
||||||
"audio/mpeg",
|
"audio/mpeg",
|
||||||
|
@ -61,7 +61,7 @@ pub fn remove_files(files: Vec<String>, from_dir: &Path) -> () {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::utils::files::sniff_media_type;
|
use mitra_utils::files::sniff_media_type;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::database::{DatabaseClient, DatabaseError};
|
use crate::database::{DatabaseClient, DatabaseError};
|
||||||
use crate::models::cleanup::{
|
use crate::models::cleanup::{
|
||||||
find_orphaned_files,
|
find_orphaned_files,
|
||||||
find_orphaned_ipfs_objects,
|
find_orphaned_ipfs_objects,
|
||||||
DeletionQueue,
|
DeletionQueue,
|
||||||
};
|
};
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
use super::types::DbMediaAttachment;
|
use super::types::DbMediaAttachment;
|
||||||
|
|
||||||
pub async fn create_attachment(
|
pub async fn create_attachment(
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
DatabaseClient,
|
DatabaseClient,
|
||||||
|
@ -10,7 +12,6 @@ use crate::models::{
|
||||||
cleanup::{find_orphaned_files, DeletionQueue},
|
cleanup::{find_orphaned_files, DeletionQueue},
|
||||||
instances::queries::create_instance,
|
instances::queries::create_instance,
|
||||||
};
|
};
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
use super::types::{DbEmoji, EmojiImage};
|
use super::types::{DbEmoji, EmojiImage};
|
||||||
|
|
||||||
pub async fn create_emoji(
|
pub async fn create_emoji(
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
caip2::ChainId,
|
||||||
|
id::generate_ulid,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
DatabaseClient,
|
DatabaseClient,
|
||||||
DatabaseError,
|
DatabaseError,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
caip2::ChainId,
|
|
||||||
id::generate_ulid,
|
|
||||||
};
|
|
||||||
use super::types::{DbChainId, DbInvoice, InvoiceStatus};
|
use super::types::{DbChainId, DbInvoice, InvoiceStatus};
|
||||||
|
|
||||||
pub async fn create_invoice(
|
pub async fn create_invoice(
|
||||||
|
|
|
@ -11,11 +11,12 @@ use postgres_types::{
|
||||||
};
|
};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::caip2::ChainId;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
int_enum::{int_enum_from_sql, int_enum_to_sql},
|
int_enum::{int_enum_from_sql, int_enum_to_sql},
|
||||||
DatabaseTypeError,
|
DatabaseTypeError,
|
||||||
};
|
};
|
||||||
use crate::utils::caip2::ChainId;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DbChainId(ChainId);
|
pub struct DbChainId(ChainId);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
query_macro::query,
|
query_macro::query,
|
||||||
|
@ -25,7 +27,6 @@ use crate::models::{
|
||||||
profiles::types::DbActorProfile,
|
profiles::types::DbActorProfile,
|
||||||
relationships::types::RelationshipType,
|
relationships::types::RelationshipType,
|
||||||
};
|
};
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
DbPost,
|
DbPost,
|
||||||
Post,
|
Post,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
use mitra_utils::html::clean_html_strict;
|
||||||
|
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::utils::html::clean_html_strict;
|
|
||||||
|
|
||||||
pub const ATTACHMENTS_MAX_NUM: usize = 15;
|
pub const ATTACHMENTS_MAX_NUM: usize = 15;
|
||||||
pub const EMOJIS_MAX_NUM: usize = 20;
|
pub const EMOJIS_MAX_NUM: usize = 20;
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::{
|
||||||
|
currencies::Currency,
|
||||||
|
id::generate_ulid,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
query_macro::query,
|
query_macro::query,
|
||||||
|
@ -17,10 +22,6 @@ use crate::models::{
|
||||||
instances::queries::create_instance,
|
instances::queries::create_instance,
|
||||||
relationships::types::RelationshipType,
|
relationships::types::RelationshipType,
|
||||||
};
|
};
|
||||||
use crate::utils::{
|
|
||||||
currencies::Currency,
|
|
||||||
id::generate_ulid,
|
|
||||||
};
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
DbActorProfile,
|
DbActorProfile,
|
||||||
ExtraFields,
|
ExtraFields,
|
||||||
|
|
|
@ -11,6 +11,8 @@ use serde::{
|
||||||
};
|
};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::caip2::ChainId;
|
||||||
|
|
||||||
use crate::activitypub::{
|
use crate::activitypub::{
|
||||||
actors::types::Actor,
|
actors::types::Actor,
|
||||||
identifiers::local_actor_id,
|
identifiers::local_actor_id,
|
||||||
|
@ -24,7 +26,6 @@ use crate::identity::{
|
||||||
did::Did,
|
did::Did,
|
||||||
signatures::{PROOF_TYPE_ID_EIP191, PROOF_TYPE_ID_MINISIGN},
|
signatures::{PROOF_TYPE_ID_EIP191, PROOF_TYPE_ID_MINISIGN},
|
||||||
};
|
};
|
||||||
use crate::utils::caip2::ChainId;
|
|
||||||
use crate::webfinger::types::ActorAddress;
|
use crate::webfinger::types::ActorAddress;
|
||||||
use super::validators::{
|
use super::validators::{
|
||||||
validate_username,
|
validate_username,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
use mitra_utils::html::{clean_html, clean_html_strict};
|
||||||
|
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::utils::html::{clean_html, clean_html_strict};
|
|
||||||
use super::types::ExtraField;
|
use super::types::ExtraField;
|
||||||
|
|
||||||
const USERNAME_RE: &str = r"^[a-zA-Z0-9_\.-]+$";
|
const USERNAME_RE: &str = r"^[a-zA-Z0-9_\.-]+$";
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
DatabaseClient,
|
DatabaseClient,
|
||||||
|
@ -12,7 +14,6 @@ use crate::models::{
|
||||||
get_post_author,
|
get_post_author,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
use super::types::DbReaction;
|
use super::types::DbReaction;
|
||||||
|
|
||||||
pub async fn create_reaction(
|
pub async fn create_reaction(
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::id::generate_ulid;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
DatabaseClient,
|
DatabaseClient,
|
||||||
|
@ -14,7 +16,6 @@ use crate::models::{
|
||||||
},
|
},
|
||||||
profiles::types::DbActorProfile,
|
profiles::types::DbActorProfile,
|
||||||
};
|
};
|
||||||
use crate::utils::id::generate_ulid;
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
DbFollowRequest,
|
DbFollowRequest,
|
||||||
DbRelationship,
|
DbRelationship,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::caip2::ChainId;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
DatabaseClient,
|
DatabaseClient,
|
||||||
|
@ -12,7 +14,6 @@ use crate::models::{
|
||||||
relationships::queries::{subscribe, subscribe_opt},
|
relationships::queries::{subscribe, subscribe_opt},
|
||||||
relationships::types::RelationshipType,
|
relationships::types::RelationshipType,
|
||||||
};
|
};
|
||||||
use crate::utils::caip2::ChainId;
|
|
||||||
use super::types::{DbSubscription, Subscription};
|
use super::types::{DbSubscription, Subscription};
|
||||||
|
|
||||||
pub async fn create_subscription(
|
pub async fn create_subscription(
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::currencies::Currency;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
catch_unique_violation,
|
catch_unique_violation,
|
||||||
DatabaseClient,
|
DatabaseClient,
|
||||||
|
@ -10,7 +12,6 @@ use crate::models::{
|
||||||
profiles::queries::create_profile,
|
profiles::queries::create_profile,
|
||||||
profiles::types::{DbActorProfile, ProfileCreateData},
|
profiles::types::{DbActorProfile, ProfileCreateData},
|
||||||
};
|
};
|
||||||
use crate::utils::currencies::Currency;
|
|
||||||
use super::types::{DbUser, Role, User, UserCreateData};
|
use super::types::{DbUser, Role, User, UserCreateData};
|
||||||
use super::utils::generate_invite_code;
|
use super::utils::generate_invite_code;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ use postgres_types::FromSql;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use mitra_utils::currencies::Currency;
|
||||||
|
|
||||||
use crate::database::{
|
use crate::database::{
|
||||||
int_enum::{int_enum_from_sql, int_enum_to_sql},
|
int_enum::{int_enum_from_sql, int_enum_to_sql},
|
||||||
DatabaseTypeError,
|
DatabaseTypeError,
|
||||||
|
@ -10,7 +12,6 @@ use crate::database::{
|
||||||
use crate::errors::ValidationError;
|
use crate::errors::ValidationError;
|
||||||
use crate::identity::did::Did;
|
use crate::identity::did::Did;
|
||||||
use crate::models::profiles::types::DbActorProfile;
|
use crate::models::profiles::types::DbActorProfile;
|
||||||
use crate::utils::currencies::Currency;
|
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum Permission {
|
pub enum Permission {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use hex;
|
use hex;
|
||||||
|
|
||||||
use crate::utils::random::generate_random_sequence;
|
use mitra_utils::random::generate_random_sequence;
|
||||||
|
|
||||||
const INVITE_CODE_LENGTH: usize = 32;
|
const INVITE_CODE_LENGTH: usize = 32;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue