Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Switch toruma-api's request/response macro to reduce HTTP boilerplate #36

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[workspace]
members = [
"crates/core",
"crates/matrix",
"crates/server",
"crates/test"
]
members = ["crates/core", "crates/matrix", "crates/server", "crates/test"]
default-members = ["crates/server"]
resolver = "1"
resolver = "2"

[workspace.dependencies]
async-trait = "0.1.74"
hex = "0.4.3"
hmac = "0.12.1"
serde_path_to_error = "0.1.14"
serde_qs = "0.12.0"
sha1 = "0.10.6"
anyhow = "1.0.75"
axum = { version = "0.7.4", features = ["tokio"] }
chrono = { version = "0.4.34", features = ["serde"] }
Expand All @@ -17,7 +18,12 @@ http = "0.2.11"
mime = "0.3.17"
openssl = { version = "0.10.63", features = ["vendored"] }
openssl-sys = { version = "0.9.99", features = ["vendored"] }
reqwest = { version = "0.11.22", default-features = false, features = ["blocking", "json", "rustls", "multipart"] }
reqwest = { version = "0.11.22", default-features = false, features = [
"blocking",
"json",
"rustls",
"multipart",
] }
serde = "1.0.192"
serde_json = "1.0.108"
tokio = "1.34.0"
Expand Down
14 changes: 6 additions & 8 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pub mod account;
//! This library deals with our core logic, such as authorizing user interactions,
//! forwarding regular events and constructing custom requests.

pub mod session;
pub mod auth;
pub mod error;
pub mod mail;
Expand All @@ -9,14 +12,11 @@ pub use error::{Error, HttpStatusCode, Result};

use mail::service::MailService;
use room::service::RoomService;
use tokio::sync::mpsc::Receiver;
use url::Url;

use std::{fmt::Debug, str::FromStr, sync::Arc};

use matrix::Client as MatrixAdminClient;

use self::{account::service::AccountService, auth::service::AuthService};

pub mod env {
pub const COMMUNE_SYNAPSE_HOST: &str = "COMMUNE_SYNAPSE_HOST";
pub const COMMUNE_SYNAPSE_ADMIN_TOKEN: &str = "COMMUNE_SYNAPSE_ADMIN_TOKEN";
Expand Down Expand Up @@ -92,9 +92,7 @@ impl CommuneConfig {
}

pub struct Commune {
pub account: Arc<AccountService>,
pub auth: Arc<AuthService>,
pub room: Arc<RoomService>,

}

impl Commune {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 20 additions & 11 deletions crates/matrix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,31 @@ edition = "2021"
publish = false

[dependencies]
async-trait = "0.1.74"
hex = "0.4.3"
hmac = "0.12.1"
serde_path_to_error = "0.1.14"
serde_qs = "0.12.0"
sha1 = "0.10.6"
ruma-events = { version = "0.27.11", features = ["html", "markdown"] }
ruma-common = { version = "0.12.1", features = ["rand"] }
ruma-macros = "0.12.0"
ruma-events = { version = "0.27.11", default_features = false, features = [
"html",
"markdown",
] }
ruma-common = { version = "0.12.0", default_features = false, features = [
"api",
"rand",
] }
ruma-macros = { version = "0.12.0", default_features = false }
ruma-client = { version = "0.12.0", default_features = false }

# Workspace Dependencies
anyhow = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
mime = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
serde = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
sha1 = { workspace = true }
url = { workspace = true, features = ["serde"] }
hex = { workspace = true }
hmac = { workspace = true }
http.workspace = true
bytes = "1.5.0"
async-trait = "0.1.77"

[features]
client = []
server = []
8 changes: 7 additions & 1 deletion crates/matrix/src/admin/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
pub mod resources;
//! This module is the root of the admin API.
//!
//! reference: https://matrix-org.github.io/synapse/latest/usage/administration/admin_api/index.html

pub mod room;
pub mod session;
pub mod user;
3 changes: 0 additions & 3 deletions crates/matrix/src/admin/resources/mod.rs

This file was deleted.

Loading
Loading