Skip to content

Commit

Permalink
Use on every service
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed May 9, 2024
1 parent 3eac046 commit 45d931a
Show file tree
Hide file tree
Showing 30 changed files with 87 additions and 67 deletions.
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/kitsune-derive/impl/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ fn expand_builder(
let attrs = quote! {
#[derive(::kitsune_derive::typed_builder::TypedBuilder)]
#[builder(build_method(into = #struct_name))]
#[builder(crate_module_path = ::kitsune_derive::typed_builder)]
};
let impls = quote! {
impl #struct_name {
Expand Down
1 change: 0 additions & 1 deletion crates/kitsune-embed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ kitsune-http-client = { path = "../kitsune-http-client" }
once_cell = "1.19.0"
scraper = { version = "0.19.0", default-features = false }
smol_str = "0.2.1"
typed-builder = "0.18.2"

[lints]
workspace = true
3 changes: 1 addition & 2 deletions crates/kitsune-embed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use kitsune_http_client::Client as HttpClient;
use once_cell::sync::Lazy;
use scraper::{Html, Selector};
use smol_str::SmolStr;
use typed_builder::TypedBuilder;

pub use embed_sdk;
pub use embed_sdk::Embed;
Expand All @@ -33,7 +32,7 @@ fn first_link_from_fragment(fragment: &str) -> Option<String> {
.and_then(|element| element.value().attr("href").map(ToString::to_string))
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 35 in crates/kitsune-embed/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-embed/src/lib.rs#L35

Added line #L35 was not covered by tests
pub struct Client {
db_pool: PgPool,
#[builder(setter(into))]
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-federation-filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license.workspace = true
[dependencies]
globset = "0.4.14"
kitsune-config = { path = "../kitsune-config" }
kitsune-derive = { version = "0.0.1-pre.6", path = "../kitsune-derive" }
kitsune-derive = { path = "../kitsune-derive" }
kitsune-error = { path = "../kitsune-error" }
kitsune-type = { path = "../kitsune-type" }
url = "2.5.0"
Expand Down
1 change: 1 addition & 0 deletions crates/kitsune-oidc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum_dispatch = "0.3.13"
http = "1.1.0"
http-body-util = "0.1.1"
kitsune-config = { path = "../kitsune-config" }
kitsune-derive = { path = "../kitsune-derive" }
kitsune-error = { path = "../kitsune-error" }
kitsune-http-client = { path = "../kitsune-http-client" }
moka = { version = "0.12.7", features = ["future"] }
Expand Down
8 changes: 5 additions & 3 deletions crates/kitsune-oidc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::state::{
LoginState, OAuth2LoginState, Store,
};
use kitsune_config::oidc::{Configuration, StoreConfiguration};
use kitsune_derive::kitsune_service;
use kitsune_error::{bail, kitsune_error, Result};
use multiplex_pool::RoundRobinStrategy;
use openidconnect::{
Expand Down Expand Up @@ -66,7 +67,7 @@ pub struct UserInfo {
pub oauth2: OAuth2Info,
}

#[derive(Clone)]
#[kitsune_service(omit_builder)]

Check warning on line 70 in crates/kitsune-oidc/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-oidc/src/lib.rs#L70

Added line #L70 was not covered by tests
pub struct OidcService {
client: OidcClient,
login_state_store: self::state::AnyStore,
Expand Down Expand Up @@ -103,10 +104,11 @@ impl OidcService {
}
};

Ok(Self {
Ok(__OidcService__Inner {

Check warning on line 107 in crates/kitsune-oidc/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-oidc/src/lib.rs#L107

Added line #L107 was not covered by tests
client,
login_state_store,
})
}
.into())

Check warning on line 111 in crates/kitsune-oidc/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-oidc/src/lib.rs#L110-L111

Added lines #L110 - L111 were not covered by tests
}

pub async fn authorisation_url(
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-search/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ futures-util = "0.3.30"
http = "1.1.0"
kitsune-config = { path = "../kitsune-config" }
kitsune-db = { path = "../kitsune-db" }
kitsune-derive = { path = "../kitsune-derive" }
kitsune-error = { path = "../kitsune-error" }
kitsune-http-client = { path = "../kitsune-http-client" }
kitsune-language = { path = "../kitsune-language" }
Expand All @@ -27,7 +28,6 @@ serde_urlencoded = "0.7.1"
speedy-uuid = { path = "../../lib/speedy-uuid" }
strum = { version = "0.26.2", features = ["derive"] }
tracing = "0.1.40"
typed-builder = "0.18.2"

[lints]
workspace = true
7 changes: 4 additions & 3 deletions crates/kitsune-search/src/meilisearch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use self::http_client::HttpClient;
use super::{Result, SearchBackend, SearchIndex, SearchItem, SearchResultReference};
use kitsune_derive::kitsune_service;
use meilisearch_sdk::{client::Client, indexes::Index, settings::Settings};
use serde::Deserialize;
use speedy_uuid::Uuid;
Expand All @@ -12,7 +13,7 @@ struct MeilisearchResult {
id: Uuid,
}

#[derive(Clone)]
#[kitsune_service(omit_builder)]

Check warning on line 16 in crates/kitsune-search/src/meilisearch/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-search/src/meilisearch/mod.rs#L16

Added line #L16 was not covered by tests
pub struct MeiliSearchService {
client: Client<HttpClient>,
}
Expand All @@ -29,9 +30,9 @@ impl MeiliSearchService {
.content_length_limit(None)
.build(),
};
let service = Self {
let service = Self::from(__MeiliSearchService__Inner {

Check warning on line 33 in crates/kitsune-search/src/meilisearch/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-search/src/meilisearch/mod.rs#L33

Added line #L33 was not covered by tests
client: Client::new_with_client(host, Some(api_key), http_client),
};
});

Check warning on line 35 in crates/kitsune-search/src/meilisearch/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-search/src/meilisearch/mod.rs#L35

Added line #L35 was not covered by tests

let settings = Settings::new()
.with_filterable_attributes(["created_at"])
Expand Down
4 changes: 2 additions & 2 deletions crates/kitsune-search/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use kitsune_db::{
schema::{accounts, posts},
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use speedy_uuid::Uuid;
use typed_builder::TypedBuilder;

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 17 in crates/kitsune-search/src/sql.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-search/src/sql.rs#L17

Added line #L17 was not covered by tests
pub struct SearchService {
db_pool: PgPool,
language_detection_config: LanguageDetectionConfig,
Expand Down
1 change: 1 addition & 0 deletions crates/kitsune-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ kitsune-captcha = { path = "../kitsune-captcha" }
kitsune-config = { path = "../kitsune-config" }
kitsune-core = { path = "../kitsune-core" }
kitsune-db = { path = "../kitsune-db" }
kitsune-derive = { path = "../kitsune-derive" }
kitsune-email = { path = "../kitsune-email" }
kitsune-embed = { path = "../kitsune-embed" }
kitsune-error = { path = "../kitsune-error" }
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use kitsune_db::{
schema::{accounts, accounts_follows, accounts_preferences, notifications, posts},
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::{Error, Result};
use kitsune_jobs::deliver::{
accept::DeliverAccept,
Expand Down Expand Up @@ -178,7 +179,7 @@ impl<A, H> Update<A, H> {
}
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]
pub struct AccountService {
attachment_service: AttachmentService,
db_pool: PgPool,
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use kitsune_db::{
schema::media_attachments,
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::{kitsune_error, Error, ErrorType, Result};
use kitsune_http_client::Client;
use kitsune_storage::{AnyStorageBackend, StorageBackend};
Expand Down Expand Up @@ -73,7 +74,7 @@ impl<S> Upload<S> {
}
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]
pub struct AttachmentService {
#[builder(default =
Client::builder()
Expand Down
4 changes: 2 additions & 2 deletions crates/kitsune-service/src/captcha.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use kitsune_captcha::{AnyCaptcha, CaptchaBackend, ChallengeStatus};
use kitsune_derive::kitsune_service;
use kitsune_error::Result;
use typed_builder::TypedBuilder;

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 5 in crates/kitsune-service/src/captcha.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-service/src/captcha.rs#L5

Added line #L5 was not covered by tests
pub struct CaptchaService {
#[builder(setter(into))]
pub backend: Option<AnyCaptcha>,
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/custom_emoji.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use kitsune_db::{
schema::{custom_emojis, media_attachments, posts, posts_custom_emojis},
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::{Error, Result};
use kitsune_url::UrlService;
use speedy_uuid::Uuid;
Expand Down Expand Up @@ -60,7 +61,7 @@ pub struct EmojiUpload<S> {
stream: S,
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]
pub struct CustomEmojiService {
attachment_service: AttachmentService,
db_pool: PgPool,
Expand Down
4 changes: 2 additions & 2 deletions crates/kitsune-service/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use kitsune_db::{
schema::{accounts, posts, users},
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::{Error, Result};
use smol_str::SmolStr;
use typed_builder::TypedBuilder;

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 11 in crates/kitsune-service/src/instance.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-service/src/instance.rs#L11

Added line #L11 was not covered by tests
pub struct InstanceService {
db_pool: PgPool,
#[builder(setter(into))]
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/job.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use athena::{JobDetails, JobQueue};
use iso8601_timestamp::Timestamp;
use kitsune_derive::kitsune_service;
use kitsune_error::Result;
use kitsune_jobs::{Job, KitsuneContextRepo};
use std::sync::Arc;
Expand All @@ -12,7 +13,7 @@ pub struct Enqueue<T> {
run_at: Option<Timestamp>,
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]
pub struct JobService {
job_queue: Arc<dyn JobQueue<ContextRepository = KitsuneContextRepo>>,
}
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ use kitsune_db::{
schema::{accounts, accounts_follows, accounts_preferences, notifications, posts},
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::{Error, Result};
use speedy_uuid::Uuid;
use typed_builder::TypedBuilder;

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 19 in crates/kitsune-service/src/notification.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-service/src/notification.rs#L19

Added line #L19 was not covered by tests
pub struct NotificationService {
db_pool: PgPool,
}
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/post/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use kitsune_db::{
},
with_connection, with_transaction, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_embed::Client as EmbedClient;
use kitsune_error::{bail, Error, ErrorType, Result};
use kitsune_jobs::deliver::{
Expand Down Expand Up @@ -294,7 +295,7 @@ pub struct GetAccountsInteractingWithPost {
max_id: Option<Uuid>,
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 298 in crates/kitsune-service/src/post/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-service/src/post/mod.rs#L298

Added line #L298 was not covered by tests
pub struct PostService {
db_pool: PgPool,
embed_client: Option<EmbedClient>,
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use kitsune_db::{
schema::{accounts, posts},
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::Result;
use kitsune_search::{SearchBackend, SearchIndex};
use speedy_uuid::Uuid;
Expand Down Expand Up @@ -37,7 +38,7 @@ pub struct Search<'a> {
max_id: Option<Uuid>,
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 41 in crates/kitsune-service/src/search.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-service/src/search.rs#L41

Added line #L41 was not covered by tests
pub struct SearchService {
db_pool: PgPool,
fetcher: Arc<dyn Fetcher>,
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use kitsune_db::{
schema::{accounts_follows, posts, posts_mentions},
with_connection, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::{Error, Result};
use speedy_uuid::Uuid;
use typed_builder::TypedBuilder;
Expand Down Expand Up @@ -62,7 +63,7 @@ pub struct GetPublic {
only_remote: bool,
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 66 in crates/kitsune-service/src/timeline.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-service/src/timeline.rs#L66

Added line #L66 was not covered by tests
pub struct TimelineService {
db_pool: PgPool,
}
Expand Down
3 changes: 2 additions & 1 deletion crates/kitsune-service/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use kitsune_db::{
schema::{accounts, accounts_preferences, users},
with_transaction, PgPool,
};
use kitsune_derive::kitsune_service;
use kitsune_error::{bail, kitsune_error, Error, ErrorType, Result};
use kitsune_jobs::mailing::confirmation::SendConfirmationMail;
use kitsune_url::UrlService;
Expand Down Expand Up @@ -112,7 +113,7 @@ pub struct Register {
force_registration: bool,
}

#[derive(Clone, TypedBuilder)]
#[kitsune_service]

Check warning on line 116 in crates/kitsune-service/src/user.rs

View check run for this annotation

Codecov / codecov/patch

crates/kitsune-service/src/user.rs#L116

Added line #L116 was not covered by tests
pub struct UserService {
allow_non_ascii_usernames: bool,
captcha_service: CaptchaService,
Expand Down
Loading

0 comments on commit 45d931a

Please sign in to comment.