refactor: rename 'kenapi' to 'app' across the project
ZhenYi committed
This change is very large, so some diffs are not shown. Clone the repository to see the full change.
Modified app/src/main.rs app/src/main.rs +8 −7 View app/src/main.rs
@@ -43,6 +43,7 @@
4343 info!("apihost is disabled by config; exiting");
4444 return Ok(());
4545 }
46 push::protocol::set_push_enabled(cfg.push.enabled);
4647
4748 let cancel = CancellationToken::new();
4849 let app_config = cfg.clone();
@@ -51,7 +52,7 @@
5152 .await
5253 .context("connecting the session store")?;
5354 let database = std::sync::Arc::new(
54 export::AppDatabase::connect(app_config.database.clone())
55 db::AppDatabase::connect(app_config.database.clone())
5556 .await
5657 .context("connecting to the shared database")?,
5758 );
@@ -75,7 +76,7 @@
7576 .unwrap_or_default();
7677 let mail =
7778 auth::email::MailPublisher::new(queue::Publisher::new(conn.clone()), email_pool.mail_topic);
78 let state = export::AppState::with_identity(
79 let state = bootstrap::AppState::with_identity(
7980 app_config,
8081 database,
8182 Some(mail),
@@ -91,8 +92,8 @@
9192 spawn_queue_depth_reporter(
9293 state.redis.clone(),
9394 &[
94 ("push.jobs", export::push::QUEUE_TOPIC.to_string()),
95 ("push.jobs.dlq", export::push::DLQ_TOPIC.to_string()),
95 ("push.jobs", push::protocol::QUEUE_TOPIC.to_string()),
96 ("push.jobs.dlq", push::protocol::DLQ_TOPIC.to_string()),
9697 ],
9798 );
9899
@@ -153,7 +154,7 @@
153154 .app_data(
154155 web::JsonConfig::default()
155156 .limit(webapi::MAX_REQUEST_BODY_BYTES)
156 .error_handler(export::http::json_error),
157 .error_handler(api::http::json_error),
157158 )
158159 .app_data(web::PayloadConfig::new(webapi::MAX_REQUEST_BODY_BYTES));
159160 app.wrap(from_fn(webapi::middleware::revalidate::revalidate))
@@ -164,7 +165,7 @@
164165 .wrap(webapi::build_cors(&state.config.web))
165166 .wrap(from_fn(webapi::middleware::csrf::csrf))
166167 .wrap(oltp::actix::HttpTelemetry::new("gitdata"))
167 .wrap(from_fn(export::middleware::trace_request))
168 .wrap(from_fn(api::middleware::trace_request))
168169 .service(web::resource("/api/docs").route(web::get().to(|| async {
169170 actix_web::HttpResponse::Found()
170171 .insert_header((actix_web::http::header::LOCATION, "/api/docs/"))
@@ -413,7 +414,7 @@
413414const QUEUE_DEPTH_INTERVAL: std::time::Duration = std::time::Duration::from_secs(30);
414415
415416/// 周期性上报队列与死信队列的积压深度;进程退出时随运行时一起结束。
416fn spawn_queue_depth_reporter(redis: export::AppRedis, queues: &[(&'static str, String)]) {
417fn spawn_queue_depth_reporter(redis: cache::AppRedis, queues: &[(&'static str, String)]) {
417418 if queues.is_empty() {
418419 return;
419420 }
Modified app/Cargo.toml app/Cargo.toml +4 −1 View app/Cargo.toml
@@ -5,6 +5,10 @@
55publish = false
66
77[dependencies]
8api = { workspace = true }
9bootstrap = { workspace = true }
10cache = { workspace = true }
11db = { workspace = true }
812serde_json = { workspace = true }
913anyhow = { workspace = true }
1014auth = { workspace = true }
@@ -16,7 +20,6 @@
1620config = { workspace = true }
1721deletion = { workspace = true }
1822events = { workspace = true, features = ["gateway"] }
19export = { workspace = true }
2023space = { workspace = true }
2124internal = { workspace = true }
2225session = { workspace = true }
Modified lib/infra/cache/src/conn.rs lib/infra/cache/src/conn.rs +3 −7 View lib/infra/cache/src/conn.rs
@@ -57,8 +57,8 @@
5757 .ok_or_else(|| CacheError::config("redis requires at least one node"))?;
5858 let info = connection_info(&host, port, cfg)?;
5959 let client = redis::Client::open(info).map_err(CacheError::from)?;
60 let manager_config = ConnectionManagerConfig::new()
61 .set_connection_timeout(Some(cfg.create_timeout()));
60 let manager_config =
61 ConnectionManagerConfig::new().set_connection_timeout(Some(cfg.create_timeout()));
6262
6363 let mut connections = Vec::with_capacity(pool_size);
6464 for _ in 0..pool_size {
@@ -114,11 +114,7 @@
114114 }
115115}
116116
117fn connection_info(
118 host: &str,
119 port: u16,
120 cfg: &RedisConfig,
121) -> CacheResult<ConnectionInfo> {
117fn connection_info(host: &str, port: u16, cfg: &RedisConfig) -> CacheResult<ConnectionInfo> {
122118 let host = if host.contains(':') && !host.starts_with('[') {
123119 format!("[{host}]")
124120 } else {
Modified lib/infra/cache/src/lib.rs lib/infra/cache/src/lib.rs +13 −0 View lib/infra/cache/src/lib.rs
@@ -1,3 +1,4 @@
1pub mod client;
12pub mod conn;
23pub mod error;
34pub mod exec;
@@ -13,6 +14,7 @@
1314
1415mod kv;
1516
17pub use client::{AppRedis, RedisConnection};
1618pub use conn::{CacheConn, CacheConnection};
1719pub use error::{CacheError, CacheResult};
1820pub use keys::{CacheKey, SEPARATOR, join, join_tagged, same_slot, slot_tag};
@@ -22,3 +24,14 @@
2224pub use scripts::{LuaScripts, RateLimit, unix_millis};
2325
2426pub use redis;
27
28#[macro_export]
29macro_rules! redis_error_conversion {
30 ($name:ident) => {
31 impl From<::redis::RedisError> for $name {
32 fn from(error: ::redis::RedisError) -> Self {
33 Self::Internal(format!("redis error: {error}"))
34 }
35 }
36 };
37}
Modified lib/infra/db/src/lib.rs lib/infra/db/src/lib.rs +2 −0 View lib/infra/db/src/lib.rs
@@ -1,3 +1,4 @@
1mod app;
12pub mod conn;
23pub mod error;
34pub mod exec;
@@ -6,5 +7,6 @@
67
78pub use routing::requires_primary;
89
10pub use app::{AppDatabase, DatabaseRole, ensure_local_user};
911pub use conn::DbConn;
1012pub use error::{DbError, DbResult};
Modified lib/infra/db/Cargo.toml lib/infra/db/Cargo.toml +3 −0 View lib/infra/db/Cargo.toml
@@ -5,7 +5,10 @@
55
66[dependencies]
77async-trait = { workspace = true }
8config = { workspace = true }
9models = { workspace = true }
810sea-orm = { workspace = true }
911sqlparser = { version = "0.63.0", default-features = false, features = ["std"] }
1012thiserror = { workspace = true }
13time = { workspace = true }
1114tracing = { workspace = true }
Modified lib/infra/internal/src/client.rs lib/infra/internal/src/client.rs +1 −1 View lib/infra/internal/src/client.rs
@@ -90,5 +90,5 @@
9090 }
9191}
9292
93/// 请求号提供函数别名,方便 `app` 传 `export::middleware::request_id`。
93/// 请求号提供函数别名,方便 `app` 传 `api::middleware::request_id`。
9494pub type RequestIdProvider = fn() -> Option<String>;
Modified lib/infra/storage/src/lib.rs lib/infra/storage/src/lib.rs +11 −0 View lib/infra/storage/src/lib.rs
@@ -3,3 +3,14 @@
33
44pub use error::StorageError;
55pub use s3::{MAX_PRESIGN_EXPIRY_SECS, ObjectInfo, ObjectPage, S3Client};
6
7#[macro_export]
8macro_rules! storage_error_conversion {
9 ($name:ident) => {
10 impl From<::storage::StorageError> for $name {
11 fn from(error: ::storage::StorageError) -> Self {
12 Self::Internal(format!("storage error: {error}"))
13 }
14 }
15 };
16}
Modified lib/service/auth/src/handlers/accept_agreement.rs lib/service/auth/src/handlers/accept_agreement.rs +2 −2 View lib/service/auth/src/handlers/accept_agreement.rs
@@ -1,7 +1,7 @@
1use export::http::{Json, Path, State};
1use api::http::{Json, Path, State};
22
33use ::session::Session;
4use export::rest::{AppResponseData, NoData};
4use api::rest::{AppResponseData, NoData};
55use serde::{Deserialize, Serialize};
66use utoipa::ToSchema;
77
Modified lib/service/auth/src/handlers/agreement_page.rs lib/service/auth/src/handlers/agreement_page.rs +1 −1 View lib/service/auth/src/handlers/agreement_page.rs
@@ -1,4 +1,4 @@
1use export::http::{HeaderMap, Html, Path, State};
1use api::http::{HeaderMap, Html, Path, State};
22use i18n::catalog;
33
44use crate::errors::ApiError;
Modified lib/service/auth/src/handlers/challenge.rs lib/service/auth/src/handlers/challenge.rs +3 −3 View lib/service/auth/src/handlers/challenge.rs
@@ -1,8 +1,8 @@
11use crate::errors::ApiError;
22pub use crate::services::pow::*;
3use export::http::{Extension, State};
4use export::middleware::RequestId;
5use export::rest::{AppResponseData, NoData};
3use api::http::{Extension, State};
4use api::middleware::RequestId;
5use api::rest::{AppResponseData, NoData};
66use session::Session;
77
88#[utoipa::path(
Modified lib/service/auth/src/handlers/create_report.rs lib/service/auth/src/handlers/create_report.rs +2 −2 View lib/service/auth/src/handlers/create_report.rs
@@ -1,7 +1,7 @@
1use export::http::{Json, State};
1use api::http::{Json, State};
22
33use ::session::Session;
4use export::rest::{AppResponseData, NoData};
4use api::rest::{AppResponseData, NoData};
55
66use crate::AuthService;
77use crate::errors::ApiError;
Modified lib/service/auth/src/handlers/delete_notification.rs lib/service/auth/src/handlers/delete_notification.rs +2 −2 View lib/service/auth/src/handlers/delete_notification.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44use uuid::Uuid;
55
66use crate::AuthService;
Modified lib/service/auth/src/handlers/devices.rs lib/service/auth/src/handlers/devices.rs +3 −3 View lib/service/auth/src/handlers/devices.rs
@@ -1,9 +1,9 @@
11use crate::protos::auth::common::v1::PageRequest;
22use ::session::Session;
33use ::session::share::session;
4use export::http::{Query, State};
5use export::pagination::PageQuery;
6use export::rest::AppResponseData;
4use api::http::{Query, State};
5use api::pagination::PageQuery;
6use api::rest::AppResponseData;
77use serde::{Deserialize, Serialize};
88use sha2::{Digest, Sha256};
99use time::OffsetDateTime;
Modified lib/service/auth/src/handlers/get_preferences.rs lib/service/auth/src/handlers/get_preferences.rs +2 −2 View lib/service/auth/src/handlers/get_preferences.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::State;
3use export::rest::{AppResponseData, NoData};
2use api::http::State;
3use api::rest::{AppResponseData, NoData};
44
55use crate::AuthService;
66use crate::errors::ApiError;
Modified lib/service/auth/src/handlers/get_user.rs lib/service/auth/src/handlers/get_user.rs +2 −2 View lib/service/auth/src/handlers/get_user.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Path, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Path, State};
4use api::rest::{AppResponseData, NoData};
55
66use crate::AuthService;
77use crate::errors::ApiError;
Modified lib/service/auth/src/handlers/identity_me.rs lib/service/auth/src/handlers/identity_me.rs +3 −3 View lib/service/auth/src/handlers/identity_me.rs
@@ -1,8 +1,8 @@
11use crate::errors::ApiError;
22use crate::services::me::MeResponse;
3use export::http::{Extension, State};
4use export::middleware::RequestId;
5use export::rest::{AppResponseData, NoData};
3use api::http::{Extension, State};
4use api::middleware::RequestId;
5use api::rest::{AppResponseData, NoData};
66use session::Session;
77
88#[utoipa::path(
Modified lib/service/auth/src/handlers/list_agreements.rs lib/service/auth/src/handlers/list_agreements.rs +2 −2 View lib/service/auth/src/handlers/list_agreements.rs
@@ -1,5 +1,5 @@
1use export::http::State;
2use export::rest::{AppResponseData, NoData};
1use api::http::State;
2use api::rest::{AppResponseData, NoData};
33
44use crate::AuthService;
55use crate::errors::ApiError;
Modified lib/service/auth/src/handlers/list_notifications.rs lib/service/auth/src/handlers/list_notifications.rs +5 −5 View lib/service/auth/src/handlers/list_notifications.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44use serde::Deserialize;
55use utoipa::IntoParams;
66
@@ -25,7 +25,7 @@
2525 description = "分页读取当前用户站内通知,可按类型或未读状态过滤。",
2626 params(ListNotificationsQuery),
2727 responses(
28 (status = 200, description = "notifications for the current user", body = AppResponseData<export::pagination::Page<NotificationDto>>),
28 (status = 200, description = "notifications for the current user", body = AppResponseData<api::pagination::Page<NotificationDto>>),
2929 (status = 404, description = "resource not found", body = AppResponseData<NoData>),
3030 (status = 401, description = "authentication required", body = AppResponseData<NoData>)
3131 )
@@ -34,7 +34,7 @@
3434 State(service): State<AuthService>,
3535 session: Session,
3636 Query(query): Query<ListNotificationsQuery>,
37) -> Result<AppResponseData<export::pagination::Page<NotificationDto>>, ApiError> {
37) -> Result<AppResponseData<api::pagination::Page<NotificationDto>>, ApiError> {
3838 let uid = session::require_uid(&session)?;
3939 let notifications = service
4040 .list_notifications(
@@ -54,7 +54,7 @@
5454 .skip(offset as usize)
5555 .take(limit as usize)
5656 .collect();
57 Ok(AppResponseData::ok(export::pagination::Page {
57 Ok(AppResponseData::ok(api::pagination::Page {
5858 items,
5959 total,
6060 limit,
Modified lib/service/auth/src/handlers/login.rs lib/service/auth/src/handlers/login.rs +3 −3 View lib/service/auth/src/handlers/login.rs
@@ -1,8 +1,8 @@
11use crate::errors::ApiError;
22pub use crate::services::login::*;
3use export::http::{Extension, Json, State};
4use export::middleware::RequestId;
5use export::rest::{AppResponseData, NoData};
3use api::http::{Extension, Json, State};
4use api::middleware::RequestId;
5use api::rest::{AppResponseData, NoData};
66use session::Session;
77
88#[utoipa::path(
Modified lib/service/auth/src/handlers/logout.rs lib/service/auth/src/handlers/logout.rs +3 −3 View lib/service/auth/src/handlers/logout.rs
@@ -1,8 +1,8 @@
11use crate::errors::ApiError;
22pub use crate::services::logout::*;
3use export::http::{Extension, State};
4use export::middleware::RequestId;
5use export::rest::{AppResponseData, NoData};
3use api::http::{Extension, State};
4use api::middleware::RequestId;
5use api::rest::{AppResponseData, NoData};
66use session::Session;
77
88#[utoipa::path(
Modified lib/service/auth/src/handlers/mark_notifications_read.rs lib/service/auth/src/handlers/mark_notifications_read.rs +2 −2 View lib/service/auth/src/handlers/mark_notifications_read.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, State};
3use api::rest::{AppResponseData, NoData};
44use serde::Deserialize;
55use uuid::Uuid;
66
Modified lib/service/auth/src/handlers/me.rs lib/service/auth/src/handlers/me.rs +2 −2 View lib/service/auth/src/handlers/me.rs
@@ -1,5 +1,5 @@
1use export::http::State;
2use export::rest::{AppResponseData, NoData};
1use api::http::State;
2use api::rest::{AppResponseData, NoData};
33use serde::Serialize;
44use utoipa::ToSchema;
55
Modified lib/service/auth/src/handlers/password.rs lib/service/auth/src/handlers/password.rs +2 −2 View lib/service/auth/src/handlers/password.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{HeaderMap, Json, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{HeaderMap, Json, State};
4use api::rest::{AppResponseData, NoData};
55use serde::Deserialize;
66use utoipa::ToSchema;
77
Modified lib/service/auth/src/handlers/password_reset.rs lib/service/auth/src/handlers/password_reset.rs +3 −3 View lib/service/auth/src/handlers/password_reset.rs
@@ -1,8 +1,8 @@
11use crate::errors::ApiError;
22pub use crate::services::password::*;
3use export::http::{Extension, Json, State};
4use export::middleware::RequestId;
5use export::rest::{AppResponseData, NoData};
3use api::http::{Extension, Json, State};
4use api::middleware::RequestId;
5use api::rest::{AppResponseData, NoData};
66use session::Session;
77
88#[utoipa::path(
Modified lib/service/auth/src/handlers/register.rs lib/service/auth/src/handlers/register.rs +3 −3 View lib/service/auth/src/handlers/register.rs
@@ -1,8 +1,8 @@
11use crate::errors::ApiError;
22pub use crate::services::register::*;
3use export::http::{Extension, Json, State};
4use export::middleware::RequestId;
5use export::rest::{AppResponseData, NoData};
3use api::http::{Extension, Json, State};
4use api::middleware::RequestId;
5use api::rest::{AppResponseData, NoData};
66use session::Session;
77
88#[utoipa::path(
Modified lib/service/auth/src/handlers/sessions.rs lib/service/auth/src/handlers/sessions.rs +3 −3 View lib/service/auth/src/handlers/sessions.rs
@@ -2,9 +2,9 @@
22use crate::protos::auth::v1::ListUserSessionsResponse;
33use ::session::Session;
44use ::session::share::session;
5use export::http::{Path, Query, State};
6use export::pagination::{Page, PageQuery, paginate};
7use export::rest::{AppResponseData, NoData};
5use api::http::{Path, Query, State};
6use api::pagination::{Page, PageQuery, paginate};
7use api::rest::{AppResponseData, NoData};
88use serde::{Deserialize, Serialize};
99use time::OffsetDateTime;
1010use utoipa::ToSchema;
Modified lib/service/auth/src/handlers/two_factor.rs lib/service/auth/src/handlers/two_factor.rs +2 −2 View lib/service/auth/src/handlers/two_factor.rs
@@ -1,8 +1,8 @@
11use crate::protos::auth::common::v1::MfaStatus;
22use ::session::Session;
33use ::session::share::session;
4use export::http::{HeaderMap, Json, State};
5use export::rest::{AppResponseData, NoData};
4use api::http::{HeaderMap, Json, State};
5use api::rest::{AppResponseData, NoData};
66use serde::{Deserialize, Serialize};
77use utoipa::ToSchema;
88
Modified lib/service/auth/src/handlers/unread_notifications_count.rs lib/service/auth/src/handlers/unread_notifications_count.rs +2 −2 View lib/service/auth/src/handlers/unread_notifications_count.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::State;
3use export::rest::{AppResponseData, NoData};
2use api::http::State;
3use api::rest::{AppResponseData, NoData};
44use serde::Serialize;
55use utoipa::ToSchema;
66
Modified lib/service/auth/src/handlers/update_preferences.rs lib/service/auth/src/handlers/update_preferences.rs +2 −2 View lib/service/auth/src/handlers/update_preferences.rs
@@ -1,7 +1,7 @@
1use export::http::{Json, State};
1use api::http::{Json, State};
22
33use ::session::Session;
4use export::rest::{AppResponseData, NoData};
4use api::rest::{AppResponseData, NoData};
55
66use crate::AuthService;
77use crate::errors::ApiError;
Modified lib/service/auth/src/handlers/update_profile.rs lib/service/auth/src/handlers/update_profile.rs +2 −2 View lib/service/auth/src/handlers/update_profile.rs
@@ -1,7 +1,7 @@
1use export::http::{Json, State};
1use api::http::{Json, State};
22
33use ::session::Session;
4use export::rest::{AppResponseData, NoData};
4use api::rest::{AppResponseData, NoData};
55
66use crate::AuthService;
77use crate::errors::ApiError;
Modified lib/service/auth/src/handlers/users.rs lib/service/auth/src/handlers/users.rs +2 −2 View lib/service/auth/src/handlers/users.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use serde::Deserialize;
66use utoipa::IntoParams;
77
Modified lib/service/auth/src/services/account_identity.rs lib/service/auth/src/services/account_identity.rs +1 −1 View lib/service/auth/src/services/account_identity.rs
@@ -1,7 +1,7 @@
1use crate::KenAuthError;
12use crate::models::users::users;
23use crate::protos::auth::v1::*;
34use chrono::Utc;
4use export::KenAuthError;
55use rand::RngExt as _;
66use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
77
Modified lib/service/auth/src/services/account_operations.rs lib/service/auth/src/services/account_operations.rs +1 −2 View lib/service/auth/src/services/account_operations.rs
@@ -1,6 +1,5 @@
1use crate::Accounts;
21use crate::protos::auth as proto;
3use export::KenAuthError;
2use crate::{Accounts, KenAuthError};
43impl Accounts {
54 pub async fn check_health(&self) -> Result<(), KenAuthError> {
65 self.cache()
Modified lib/service/auth/src/services/authority_store.rs lib/service/auth/src/services/authority_store.rs +1 −1 View lib/service/auth/src/services/authority_store.rs
@@ -1,3 +1,4 @@
1use crate::KenAuthError;
12use crate::models::users::users;
23use crate::protos::auth::common::v1::Code;
34use crate::protos::auth::internal::v1::{
@@ -6,7 +7,6 @@
67 DeleteAccountResponse, GetSessionRequest, GetSessionResponse, GetUserRequest, GetUserResponse,
78 PurgeAccountRequest, PurgeAccountResponse, UpdateUserRequest, UpdateUserResponse,
89};
9use export::KenAuthError;
1010
1111use crate::Accounts;
1212use crate::errors::AuthError;
Modified lib/service/auth/src/services/identity.rs lib/service/auth/src/services/identity.rs +1 −1 View lib/service/auth/src/services/identity.rs
@@ -1,6 +1,6 @@
1use crate::KenAuthError;
12use crate::models::users::users;
23use crate::protos::auth::v1::*;
3use export::KenAuthError;
44use sea_orm::sea_query::{Expr, ExprTrait};
55use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
66
Modified lib/service/auth/src/services/local.rs lib/service/auth/src/services/local.rs +1 −2 View lib/service/auth/src/services/local.rs
@@ -1,6 +1,5 @@
1use crate::AuthService;
21use crate::protos::auth as proto;
3use export::KenAuthError;
2use crate::{AuthService, KenAuthError};
43impl AuthService {
54 #[allow(clippy::too_many_arguments)]
65 pub async fn change_password(
Modified lib/service/auth/src/services/preferences.rs lib/service/auth/src/services/preferences.rs +1 −1 View lib/service/auth/src/services/preferences.rs
@@ -36,7 +36,7 @@
3636 /// 声明的 PATCH 语义一致)。
3737 #[serde(
3838 default,
39 deserialize_with = "export::serde_datetime::deserialize_opt_opt_datetime"
39 deserialize_with = "api::serde_datetime::deserialize_opt_opt_datetime"
4040 )]
4141 pub mute_until: Option<Option<OffsetDateTime>>,
4242 pub allow_dms_from: Option<Audience>,
Modified lib/service/auth/src/services/profile.rs lib/service/auth/src/services/profile.rs +4 −4 View lib/service/auth/src/services/profile.rs
@@ -69,7 +69,7 @@
6969 &self,
7070 uid: i64,
7171 ) -> Result<(UserMeDto, Option<ProfileDto>), AuthBusinessError> {
72 export::users::ensure_local_user(self.db(), uid).await?;
72 db::ensure_local_user(self.db(), uid).await?;
7373 let db = self.db();
7474 let Some(user) = user::Entity::find_by_id(uid).one(db.read()).await? else {
7575 return Err(AuthBusinessError::NotFound);
@@ -109,7 +109,7 @@
109109 user_id: uid,
110110 username: public.username,
111111 display_name,
112 avatar_url: export::urls::resolve_user_avatar_url(uid, &avatar_raw),
112 avatar_url: api::urls::resolve_user_avatar_url(uid, &avatar_raw),
113113 is_active: status.allow_use && status.deleted_at.is_none(),
114114 is_restricted: user.is_restricted,
115115 prohibit_login: authority.forbid_login,
@@ -143,7 +143,7 @@
143143 uid: i64,
144144 cmd: UpdateProfileCmd,
145145 ) -> Result<(), AuthBusinessError> {
146 export::users::ensure_local_user(self.db(), uid).await?;
146 db::ensure_local_user(self.db(), uid).await?;
147147 let db = self.db();
148148 let Some(user) = user::Entity::find_by_id(uid).one(db.write()).await? else {
149149 return Err(AuthBusinessError::NotFound);
@@ -312,7 +312,7 @@
312312 user_id: uid,
313313 username: updated.username,
314314 display_name,
315 avatar_url: export::urls::resolve_user_avatar_url(uid, avatar_raw),
315 avatar_url: api::urls::resolve_user_avatar_url(uid, avatar_raw),
316316 })
317317 }
318318}
Modified lib/service/auth/src/services/sessions.rs lib/service/auth/src/services/sessions.rs +1 −1 View lib/service/auth/src/services/sessions.rs
@@ -1,7 +1,7 @@
1use crate::KenAuthError;
12use crate::models::users::user_events::UserEventType;
23use crate::models::users::{user_sessions, users};
34use crate::protos::auth::v1::*;
4use export::KenAuthError;
55use sea_orm::sea_query::{Expr, ExprTrait};
66use sea_orm::{ColumnTrait, EntityTrait, QueryFilter, QueryOrder, QuerySelect};
77use uuid::Uuid;
Modified lib/service/auth/src/services/users.rs lib/service/auth/src/services/users.rs +1 −1 View lib/service/auth/src/services/users.rs
@@ -40,7 +40,7 @@
4040 user_id: public.user_id,
4141 username: public.username.clone(),
4242 display_name,
43 avatar_url: export::urls::resolve_user_avatar_url(public.user_id, avatar_raw),
43 avatar_url: api::urls::resolve_user_avatar_url(public.user_id, avatar_raw),
4444 })
4545 }
4646
Modified lib/service/auth/src/share/account/types.rs lib/service/auth/src/share/account/types.rs +1 −1 View lib/service/auth/src/share/account/types.rs
@@ -20,7 +20,7 @@
2020 pub avatar_url: String,
2121}
2222
23pub type ListQuery = export::pagination::PageQuery;
23pub type ListQuery = api::pagination::PageQuery;
2424
2525#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
2626pub struct AgreementDoc {
Modified lib/service/auth/src/share/account_helpers.rs lib/service/auth/src/share/account_helpers.rs +1 −1 View lib/service/auth/src/share/account_helpers.rs
@@ -1,4 +1,4 @@
1use export::http::HeaderMap;
1use api::http::HeaderMap;
22use sha2::{Digest, Sha256};
33use time::OffsetDateTime;
44
Modified lib/service/auth/src/share/auth_error.rs lib/service/auth/src/share/auth_error.rs +1 −1 View lib/service/auth/src/share/auth_error.rs
@@ -1,6 +1,6 @@
11use crate::errors::AuthError;
22use crate::protos::auth::common::v1::Code;
3use export::KenAuthError;
3use crate::share::identity_error::KenAuthError;
44pub fn code_of(error: &AuthError) -> Code {
55 match error {
66 AuthError::Expired => Code::ExpiredChallenge,
Modified lib/service/auth/src/share/mod.rs lib/service/auth/src/share/mod.rs +1 −0 View lib/service/auth/src/share/mod.rs
@@ -4,6 +4,7 @@
44pub mod codes;
55pub mod crypto;
66pub mod guard;
7pub mod identity_error;
78pub mod mfa;
89pub mod net;
910pub mod password;
Modified lib/service/auth/src/templates/common.rs lib/service/auth/src/templates/common.rs +1 −1 View lib/service/auth/src/templates/common.rs
@@ -1,4 +1,4 @@
1use export::http::Html;
1use api::http::Html;
22use i18n::UiLocale;
33use maud::{DOCTYPE, Markup, html};
44
Modified lib/service/auth/src/templates/page.rs lib/service/auth/src/templates/page.rs +1 −1 View lib/service/auth/src/templates/page.rs
@@ -1,4 +1,4 @@
1use export::http::Html;
1use api::http::Html;
22use i18n::{UiLocale, catalog};
33use maud::html;
44
Modified lib/service/auth/src/errors.rs lib/service/auth/src/errors.rs +7 −7 View lib/service/auth/src/errors.rs
@@ -1,4 +1,4 @@
1pub use export::KenAuthError;
1pub use crate::share::identity_error::KenAuthError;
22
33use actix_web::http::StatusCode;
44
@@ -377,12 +377,12 @@
377377
378378impl std::error::Error for AuthBusinessError {}
379379
380export::db_error_conversions!(AuthBusinessError);
381export::redis_error_conversion!(AuthBusinessError);
382export::export_error_conversion!(AuthBusinessError);
383export::json_payload_conversion!(AuthBusinessError);
380crate::auth_error_conversion!(AuthBusinessError);
381api::db_error_conversions!(AuthBusinessError);
382cache::redis_error_conversion!(AuthBusinessError);
383api::json_payload_conversion!(AuthBusinessError);
384384
385export::api_error! {
385api::api_error! {
386386 log: "auth",
387387 pub enum ApiError {
388388 BadRequest(400, "request failed validation"),
@@ -451,7 +451,7 @@
451451 if error.is_internal() {
452452 tracing::warn!(%error, "auth handler failed");
453453 }
454 let mut response = export::rest::AppResponseData::err(i32::from(status), error.message())
454 let mut response = api::rest::AppResponseData::err(i32::from(status), error.message())
455455 .with_error_code(error.code());
456456 if let AuthError::RateLimited { retry_after_secs } = &error {
457457 response = response.with_retry_after(*retry_after_secs);
Modified lib/service/auth/src/openapi.rs lib/service/auth/src/openapi.rs +4 −4 View lib/service/auth/src/openapi.rs
@@ -25,7 +25,7 @@
2525)]
2626pub struct ApiDoc;
2727
28use export::rest::NoData;
28use api::rest::NoData;
2929use models::users::user_notifications::NotificationType;
3030
3131use crate::handlers;
@@ -71,8 +71,8 @@
7171 handlers::devices::list_devices,
7272 ),
7373 components(schemas(
74 export::pagination::PageQuery,
75 export::pagination::Page<NotificationDto>,
74 api::pagination::PageQuery,
75 api::pagination::Page<NotificationDto>,
7676 handlers::mark_notifications_read::MarkNotificationsReadCmd,
7777 handlers::mark_notifications_read::MarkedCountResp,
7878 NoData,
@@ -101,7 +101,7 @@
101101 handlers::sessions::SessionDto,
102102 handlers::sessions::SessionKind,
103103 handlers::sessions::CountResp,
104 export::pagination::Page<handlers::sessions::SessionDto>,
104 api::pagination::Page<handlers::sessions::SessionDto>,
105105 handlers::devices::DeviceDto,
106106 ))
107107)]
Modified lib/service/auth/src/routes.rs lib/service/auth/src/routes.rs +3 −3 View lib/service/auth/src/routes.rs
@@ -1,5 +1,5 @@
1use export::http::Router;
2use export::http::routing::{delete, get, post, put};
1use api::http::Router;
2use api::http::routing::{delete, get, post, put};
33
44use crate::AuthService;
55use crate::handlers::accept_agreement::accept_agreement;
@@ -112,7 +112,7 @@
112112 delete(crate::handlers::sessions::revoke_session),
113113 )
114114 .route("/me/devices", get(crate::handlers::devices::list_devices))
115 .wrap(export::http::Guard::Session);
115 .wrap(api::http::Guard::Session);
116116
117117 public.merge(authed)
118118}
Modified lib/service/auth/src/users.rs lib/service/auth/src/users.rs +11 −14 View lib/service/auth/src/users.rs
@@ -1,12 +1,12 @@
11use crate::Accounts;
2use crate::errors::KenAuthError;
23use crate::protos::auth::common::v1::UserPublic;
3use export::ExportError;
4use export::users::UserDto;
4use api::users::UserDto;
55use std::collections::HashMap;
66pub async fn load_user_briefs(
77 accounts: &Accounts,
88 uids: &[i64],
9) -> Result<HashMap<i64, UserDto>, ExportError> {
9) -> Result<HashMap<i64, UserDto>, KenAuthError> {
1010 let users = load_public_users(accounts, uids).await?;
1111 Ok(users
1212 .into_iter()
@@ -19,7 +19,7 @@
1919pub async fn load_public_users(
2020 accounts: &Accounts,
2121 uids: &[i64],
22) -> Result<HashMap<i64, UserPublic>, ExportError> {
22) -> Result<HashMap<i64, UserPublic>, KenAuthError> {
2323 if uids.is_empty() {
2424 return Ok(HashMap::new());
2525 }
@@ -27,29 +27,26 @@
2727 ids.sort_unstable();
2828 ids.dedup();
2929 let client = accounts;
30 let users = client
31 .batch_get_user_public(ids)
32 .await
33 .map_err(|error| ExportError::Connection(error.to_string()))?;
30 let users = client.batch_get_user_public(ids).await?;
3431 Ok(users.into_iter().map(|user| (user.user_id, user)).collect())
3532}
3633
3734pub async fn get_public_user(
3835 accounts: &Accounts,
3936 uid: i64,
40) -> Result<Option<UserPublic>, ExportError> {
37) -> Result<Option<UserPublic>, KenAuthError> {
4138 let client = accounts;
4239 match client.get_user_public(uid).await {
4340 Ok(user) => Ok(Some(user)),
4441 Err(crate::errors::KenAuthError::NotFound) => Ok(None),
45 Err(error) => Err(ExportError::Connection(error.to_string())),
42 Err(error) => Err(error),
4643 }
4744}
4845
4946pub async fn find_by_email(
5047 accounts: &Accounts,
5148 email: &str,
52) -> Result<Option<UserPublic>, ExportError> {
49) -> Result<Option<UserPublic>, KenAuthError> {
5350 let client = accounts;
5451 match client
5552 .get_user_public_by_ref(proto::auth::common::v1::user_ref::Key::Email(
@@ -59,14 +56,14 @@
5956 {
6057 Ok(user) => Ok(Some(user)),
6158 Err(crate::errors::KenAuthError::NotFound) => Ok(None),
62 Err(error) => Err(ExportError::Connection(error.to_string())),
59 Err(error) => Err(error),
6360 }
6461}
6562
6663pub async fn find_by_username(
6764 accounts: &Accounts,
6865 username: &str,
69) -> Result<Option<UserPublic>, ExportError> {
66) -> Result<Option<UserPublic>, KenAuthError> {
7067 let client = accounts;
7168 match client
7269 .get_user_public_by_ref(proto::auth::common::v1::user_ref::Key::Username(
@@ -76,6 +73,6 @@
7673 {
7774 Ok(user) => Ok(Some(user)),
7875 Err(crate::errors::KenAuthError::NotFound) => Ok(None),
79 Err(error) => Err(ExportError::Connection(error.to_string())),
76 Err(error) => Err(error),
8077 }
8178}
Modified lib/service/auth/Cargo.toml lib/service/auth/Cargo.toml +1 −1 View lib/service/auth/Cargo.toml
@@ -7,8 +7,8 @@
77license = "MIT"
88
99[dependencies]
10api = { workspace = true }
1011models = { workspace = true }
11export = { workspace = true }
1212i18n = { workspace = true }
1313config = { workspace = true }
1414crypt = { workspace = true }
Modified lib/service/chat/src/handlers/attachments.rs lib/service/chat/src/handlers/attachments.rs +2 −2 View lib/service/chat/src/handlers/attachments.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, Response, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, Response, State};
4use api::rest::{AppResponseData, NoData};
55use imaging::layout::ImageVariant;
66use serde::Deserialize;
77use utoipa::{IntoParams, ToSchema};
Modified lib/service/chat/src/handlers/bookmarks.rs lib/service/chat/src/handlers/bookmarks.rs +7 −7 View lib/service/chat/src/handlers/bookmarks.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
@@ -13,9 +13,9 @@
1313 path = "/chat/rooms/{room_id}/bookmarks",
1414 tag = "chat",
1515 description = "按排序位置读取指定房间的书签列表。",
16 params(("room_id" = Uuid, Path, description = "room id"), export::pagination::PageQuery),
16 params(("room_id" = Uuid, Path, description = "room id"), api::pagination::PageQuery),
1717 responses(
18 (status = 200, description = "bookmark list", body = AppResponseData<export::pagination::Page<BookmarkDto>>),
18 (status = 200, description = "bookmark list", body = AppResponseData<api::pagination::Page<BookmarkDto>>),
1919 (status = 404, description = "not found", body = AppResponseData<NoData>),
2020 (status = 401, description = "authentication required", body = AppResponseData<NoData>)
2121 )
@@ -24,11 +24,11 @@
2424 State(service): State<ChatService>,
2525 session: Session,
2626 Path(room_id): Path<Uuid>,
27 Query(page): Query<export::pagination::PageQuery>,
28) -> Result<AppResponseData<export::pagination::Page<BookmarkDto>>, ApiError> {
27 Query(page): Query<api::pagination::PageQuery>,
28) -> Result<AppResponseData<api::pagination::Page<BookmarkDto>>, ApiError> {
2929 let uid = session::require_uid(&session)?;
3030 let bookmarks = service.list_bookmarks(uid, room_id).await?;
31 Ok(AppResponseData::ok(export::pagination::paginate(
31 Ok(AppResponseData::ok(api::pagination::paginate(
3232 bookmarks, &page,
3333 )))
3434}
Modified lib/service/chat/src/handlers/connection.rs lib/service/chat/src/handlers/connection.rs +2 −2 View lib/service/chat/src/handlers/connection.rs
@@ -1,5 +1,5 @@
1use export::http::{Json, State};
2use export::rest::{AppResponseData, NoData};
1use api::http::{Json, State};
2use api::rest::{AppResponseData, NoData};
33use serde::Deserialize;
44use utoipa::ToSchema;
55
Modified lib/service/chat/src/handlers/dms.rs lib/service/chat/src/handlers/dms.rs +7 −9 View lib/service/chat/src/handlers/dms.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
@@ -38,9 +38,9 @@
3838 path = "/chat/dms",
3939 tag = "chat",
4040 description = "列出当前用户仍有效的私聊会话及其未读信息。",
41 params(export::pagination::PageQuery),
41 params(api::pagination::PageQuery),
4242 responses(
43 (status = 200, description = "my dms", body = AppResponseData<export::pagination::Page<DmDto>>),
43 (status = 200, description = "my dms", body = AppResponseData<api::pagination::Page<DmDto>>),
4444 (status = 401, description = "unauthorized", body = AppResponseData<NoData>),
4545 (status = 404, description = "resource not found", body = AppResponseData<NoData>)
4646 )
@@ -48,13 +48,11 @@
4848pub async fn list_dms(
4949 State(service): State<ChatService>,
5050 session: Session,
51 Query(page): Query<export::pagination::PageQuery>,
52) -> Result<AppResponseData<export::pagination::Page<DmDto>>, ApiError> {
51 Query(page): Query<api::pagination::PageQuery>,
52) -> Result<AppResponseData<api::pagination::Page<DmDto>>, ApiError> {
5353 let uid = session::require_uid(&session)?;
5454 let dms = service.list_dms(uid).await?;
55 Ok(AppResponseData::ok(export::pagination::paginate(
56 dms, &page,
57 )))
55 Ok(AppResponseData::ok(api::pagination::paginate(dms, &page)))
5856}
5957
6058#[utoipa::path(
Modified lib/service/chat/src/handlers/drafts.rs lib/service/chat/src/handlers/drafts.rs +6 −6 View lib/service/chat/src/handlers/drafts.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
@@ -66,7 +66,7 @@
6666 tag = "chat",
6767 description = "分页列出当前用户保存的全部聊天草稿。",
6868 responses(
69 (status = 200, description = "my drafts", body = AppResponseData<export::pagination::Page<DraftDto>>),
69 (status = 200, description = "my drafts", body = AppResponseData<api::pagination::Page<DraftDto>>),
7070 (status = 401, description = "unauthorized", body = AppResponseData<NoData>),
7171 (status = 404, description = "resource not found", body = AppResponseData<NoData>)
7272 )
@@ -74,11 +74,11 @@
7474pub async fn list_my_drafts(
7575 State(service): State<ChatService>,
7676 session: Session,
77 Query(page): Query<export::pagination::PageQuery>,
78) -> Result<AppResponseData<export::pagination::Page<DraftDto>>, ApiError> {
77 Query(page): Query<api::pagination::PageQuery>,
78) -> Result<AppResponseData<api::pagination::Page<DraftDto>>, ApiError> {
7979 let uid = session::require_uid(&session)?;
8080 let drafts = service.list_my_drafts(uid).await?;
81 Ok(AppResponseData::ok(export::pagination::paginate(
81 Ok(AppResponseData::ok(api::pagination::paginate(
8282 drafts, &page,
8383 )))
8484}
Modified lib/service/chat/src/handlers/emojis.rs lib/service/chat/src/handlers/emojis.rs +3 −3 View lib/service/chat/src/handlers/emojis.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Response, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Response, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
@@ -16,7 +16,7 @@
1616 description = "返回指定空间可用的自定义表情列表。",
1717 params(("space_name" = String, Path, description = "space name")),
1818 responses(
19 (status = 200, description = "emoji list", body = AppResponseData<export::pagination::Page<EmojiDto>>),
19 (status = 200, description = "emoji list", body = AppResponseData<api::pagination::Page<EmojiDto>>),
2020 (status = 404, description = "not found", body = AppResponseData<NoData>),
2121 (status = 401, description = "authentication required", body = AppResponseData<NoData>)
2222 )
Modified lib/service/chat/src/handlers/messages.rs lib/service/chat/src/handlers/messages.rs +3 −3 View lib/service/chat/src/handlers/messages.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
@@ -195,7 +195,7 @@
195195 description = "返回房间内当前置顶且未删除的消息列表。",
196196 params(("room_id" = Uuid, Path, description = "room id")),
197197 responses(
198 (status = 200, description = "pinned messages", body = AppResponseData<export::pagination::Page<MessageDto>>),
198 (status = 200, description = "pinned messages", body = AppResponseData<api::pagination::Page<MessageDto>>),
199199 (status = 404, description = "not found", body = AppResponseData<NoData>),
200200 (status = 401, description = "authentication required", body = AppResponseData<NoData>)
201201 )
Modified lib/service/chat/src/handlers/presence.rs lib/service/chat/src/handlers/presence.rs +2 −2 View lib/service/chat/src/handlers/presence.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, State};
4use api::rest::{AppResponseData, NoData};
55
66use crate::errors::ApiError;
77use crate::services::presence::{PresenceDto, SetPresenceCmd};
Modified lib/service/chat/src/handlers/reactions.rs lib/service/chat/src/handlers/reactions.rs +2 −2 View lib/service/chat/src/handlers/reactions.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
Modified lib/service/chat/src/handlers/read_state.rs lib/service/chat/src/handlers/read_state.rs +2 −2 View lib/service/chat/src/handlers/read_state.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
Modified lib/service/chat/src/handlers/reminders.rs lib/service/chat/src/handlers/reminders.rs +2 −2 View lib/service/chat/src/handlers/reminders.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
Modified lib/service/chat/src/handlers/rooms.rs lib/service/chat/src/handlers/rooms.rs +2 −2 View lib/service/chat/src/handlers/rooms.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
Modified lib/service/chat/src/handlers/settings.rs lib/service/chat/src/handlers/settings.rs +2 −2 View lib/service/chat/src/handlers/settings.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
Modified lib/service/chat/src/handlers/threads.rs lib/service/chat/src/handlers/threads.rs +7 −7 View lib/service/chat/src/handlers/threads.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
@@ -67,9 +67,9 @@
6767 path = "/chat/threads",
6868 tag = "chat",
6969 description = "列出当前用户参与的最近话题。",
70 params(export::pagination::PageQuery),
70 params(api::pagination::PageQuery),
7171 responses(
72 (status = 200, description = "my threads", body = AppResponseData<export::pagination::Page<ThreadDto>>),
72 (status = 200, description = "my threads", body = AppResponseData<api::pagination::Page<ThreadDto>>),
7373 (status = 401, description = "unauthorized", body = AppResponseData<NoData>),
7474 (status = 404, description = "resource not found", body = AppResponseData<NoData>)
7575 )
@@ -77,11 +77,11 @@
7777pub async fn list_my_threads(
7878 State(service): State<ChatService>,
7979 session: Session,
80 Query(page): Query<export::pagination::PageQuery>,
81) -> Result<AppResponseData<export::pagination::Page<ThreadDto>>, ApiError> {
80 Query(page): Query<api::pagination::PageQuery>,
81) -> Result<AppResponseData<api::pagination::Page<ThreadDto>>, ApiError> {
8282 let uid = session::require_uid(&session)?;
8383 let threads = service.list_my_threads(uid).await?;
84 Ok(AppResponseData::ok(export::pagination::paginate(
84 Ok(AppResponseData::ok(api::pagination::paginate(
8585 threads, &page,
8686 )))
8787}
Modified lib/service/chat/src/handlers/voice.rs lib/service/chat/src/handlers/voice.rs +2 −2 View lib/service/chat/src/handlers/voice.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{HeaderMap, Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{HeaderMap, Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use livekit_api::access_token::TokenVerifier;
66use livekit_api::webhooks::WebhookReceiver;
77use serde::Deserialize;
Modified lib/service/chat/src/handlers/webhooks.rs lib/service/chat/src/handlers/webhooks.rs +7 −9 View lib/service/chat/src/handlers/webhooks.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Json, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Json, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55use uuid::Uuid;
66
77use crate::errors::ApiError;
@@ -42,9 +42,9 @@
4242 path = "/chat/rooms/{room_id}/webhooks",
4343 tag = "chat",
4444 description = "列出房间 Webhook 的元数据,但不返回令牌。",
45 params(("room_id" = Uuid, Path, description = "room id"), export::pagination::PageQuery),
45 params(("room_id" = Uuid, Path, description = "room id"), api::pagination::PageQuery),
4646 responses(
47 (status = 200, description = "webhook list", body = AppResponseData<export::pagination::Page<WebhookDto>>),
47 (status = 200, description = "webhook list", body = AppResponseData<api::pagination::Page<WebhookDto>>),
4848 (status = 403, description = "forbidden", body = AppResponseData<NoData>),
4949 (status = 401, description = "authentication required", body = AppResponseData<NoData>)
5050 )
@@ -53,13 +53,11 @@
5353 State(service): State<ChatService>,
5454 session: Session,
5555 Path(room_id): Path<Uuid>,
56 Query(page): Query<export::pagination::PageQuery>,
57) -> Result<AppResponseData<export::pagination::Page<WebhookDto>>, ApiError> {
56 Query(page): Query<api::pagination::PageQuery>,
57) -> Result<AppResponseData<api::pagination::Page<WebhookDto>>, ApiError> {
5858 let uid = session::require_uid(&session)?;
5959 let rows = service.list_webhooks(uid, room_id).await?;
60 Ok(AppResponseData::ok(export::pagination::paginate(
61 rows, &page,
62 )))
60 Ok(AppResponseData::ok(api::pagination::paginate(rows, &page)))
6361}
6462
6563#[utoipa::path(
Modified lib/service/chat/src/services/attachments.rs lib/service/chat/src/services/attachments.rs +1 −1 View lib/service/chat/src/services/attachments.rs
@@ -317,7 +317,7 @@
317317 /// Remove both encodings of an attachment's derivative. Safe to call for any
318318 /// key: a non-image attachment has nothing stored under these names.
319319 async fn delete_attachment_previews(&self, original_key: &str) {
320 let key_base = export::imaging::preview_key_base_of(original_key);
320 let key_base = ::media::preview_key_base_of(original_key);
321321 for candidate in imaging::layout::preview_candidate_keys(&key_base) {
322322 if let Err(error) = self.media.client.as_ref().delete(&candidate).await {
323323 tracing::warn!(%error, key = %candidate, "failed to delete attachment preview");
Modified lib/service/chat/src/services/audience.rs lib/service/chat/src/services/audience.rs +4 −4 View lib/service/chat/src/services/audience.rs
@@ -1,12 +1,12 @@
11use crate::errors::ChatError;
2use api::users::UserDto;
23use auth::Accounts;
3use export::users::UserDto;
44use std::collections::HashMap;
55
66#[derive(Clone)]
77pub struct Audience {
88 pub(crate) accounts: Accounts,
9 pub(crate) notifications: export::notify::Notifications,
9 pub(crate) notifications: push::notify::Notifications,
1010 mail: Option<email::MailPublisher>,
1111 pub(crate) realtime: crate::share::realtime::Realtime,
1212 pub(crate) default_locale: i18n::UiLocale,
@@ -14,7 +14,7 @@
1414impl Audience {
1515 pub fn new(
1616 accounts: Accounts,
17 notifications: export::notify::Notifications,
17 notifications: push::notify::Notifications,
1818 mail: Option<email::MailPublisher>,
1919 realtime: crate::share::realtime::Realtime,
2020 default_locale: i18n::UiLocale,
@@ -59,7 +59,7 @@
5959 text: &str,
6060 html: &str,
6161 ) -> Result<(), ChatError> {
62 let request_id = export::middleware::request_id();
62 let request_id = api::middleware::request_id();
6363 email::send_optional(
6464 self.mail.as_ref(),
6565 to,
Modified lib/service/chat/src/services/dms.rs lib/service/chat/src/services/dms.rs +1 −1 View lib/service/chat/src/services/dms.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::chat::{read_states, room_seq};
33use models::room::room_members;
44use models::room::rooms::{self, RoomKind};
Modified lib/service/chat/src/services/media.rs lib/service/chat/src/services/media.rs +4 −4 View lib/service/chat/src/services/media.rs
@@ -1,6 +1,6 @@
11use crate::services::attachments::{attachment_stream_content_type, is_inline_image};
2use export::AppRedis;
3use export::database::AppDatabase;
2use cache::AppRedis;
3use db::AppDatabase;
44use imaging::layout::{ImageVariant, PreviewState};
55use imaging::preset::PreviewPreset;
66use models::chat::attachments;
@@ -29,8 +29,8 @@
2929 row: &attachments::Model,
3030 recorded: Option<&PreviewState>,
3131 ) -> Option<PreviewState> {
32 let key_base = export::imaging::preview_key_base_of(&row.s3_key);
33 export::imaging::ensure_preview(
32 let key_base = ::media::preview_key_base_of(&row.s3_key);
33 ::media::ensure_preview(
3434 self.client.as_ref(),
3535 &self.previews,
3636 &key_base,
Modified lib/service/chat/src/services/messages.rs lib/service/chat/src/services/messages.rs +15 −15 View lib/service/chat/src/services/messages.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::chat::attachments::{self as attachment_rows};
33use models::chat::messages::{self, AuthorType, ChatMessageType};
44use models::chat::thread_members::{self, ThreadNotifyLevel};
@@ -22,7 +22,7 @@
2222/// its original disappears. Declared here because message deletion owns the
2323/// lifetime of the attachment rows.
2424async fn delete_attachment_previews(service: &ChatService, original_key: &str) {
25 let key_base = export::imaging::preview_key_base_of(original_key);
25 let key_base = ::media::preview_key_base_of(original_key);
2626 for candidate in imaging::layout::preview_candidate_keys(&key_base) {
2727 if let Err(error) = service.media.client.as_ref().delete(&candidate).await {
2828 tracing::warn!(%error, key = %candidate, "failed to delete attachment preview");
@@ -77,11 +77,11 @@
7777 DirectMessageKind::Direct => i18n::catalog::notification_direct_message_title(locale),
7878 DirectMessageKind::Group => i18n::catalog::notification_group_dm_title(locale),
7979 };
80 export::push::enqueue(
80 push::protocol::enqueue(
8181 &service.participants.redis,
82 &export::push::PushJob {
82 &push::protocol::PushJob {
8383 user_id: uid,
84 category: export::push::PushCategory::Dm,
84 category: push::protocol::PushCategory::Dm,
8585 title: title.to_string(),
8686 body: Some(body.clone()),
8787 data: Some(json!({
@@ -92,7 +92,7 @@
9292 actor_id: Some(actor),
9393 notification_id: None,
9494 trace: oltp::propagation::traceparent(),
95 request_id: export::middleware::request_id(),
95 request_id: api::middleware::request_id(),
9696 },
9797 )
9898 .await;
@@ -492,7 +492,7 @@
492492 let svc = self.clone();
493493 let space_id = room.space_id;
494494 let nonce_retry = cmd.nonce.clone();
495 let pending = export::notify::PendingNotifications::default();
495 let pending = push::notify::PendingNotifications::default();
496496 let pending_txn = pending.clone();
497497
498498 let txn_result = self
@@ -736,9 +736,9 @@
736736 let explicit = mention_uids.clone();
737737 let is_private = ctx.room.is_private;
738738 let space_id = ctx.room.space_id;
739 let request_id = export::middleware::request_id();
739 let request_id = api::middleware::request_id();
740740 tokio::spawn(async move {
741 export::middleware::with_request_id(
741 api::middleware::with_request_id(
742742 request_id.as_deref(),
743743 fanout_everyone_mentions(
744744 &svc,
@@ -792,10 +792,10 @@
792792 } else {
793793 content_for_email.clone()
794794 };
795 let request_id = export::middleware::request_id();
795 let request_id = api::middleware::request_id();
796796 if !recipients.is_empty() {
797797 tokio::spawn(async move {
798 export::middleware::with_request_id(
798 api::middleware::with_request_id(
799799 request_id.as_deref(),
800800 broadcast_direct_message_push(
801801 &svc,
@@ -826,7 +826,7 @@
826826 content_for_email.clone()
827827 };
828828 let email_svc = self.clone();
829 let request_id = export::middleware::request_id();
829 let request_id = api::middleware::request_id();
830830 tokio::spawn(async move {
831831 let base_url = email_svc.settings.web.web_base_url.clone();
832832 for uid in email_recipients {
@@ -855,7 +855,7 @@
855855 r#"<p>{subject}</p><p>{email_body}</p><p><a href="{link}">{}</a></p>"#,
856856 i18n::catalog::view_channel(locale)
857857 );
858 let sent = export::middleware::with_request_id(
858 let sent = api::middleware::with_request_id(
859859 request_id.as_deref(),
860860 email_svc.audience.send_email(&addr, &subject, &text, &html),
861861 )
@@ -878,7 +878,7 @@
878878 ) -> Result<MessagePage, ChatError> {
879879 let _ctx = require_room_readable(self, room_id, caller).await?;
880880
881 let (limit, _) = export::pagination::page_bounds(
881 let (limit, _) = api::pagination::page_bounds(
882882 q.limit,
883883 None,
884884 self.settings.chat.default_pagination,
@@ -1024,7 +1024,7 @@
10241024
10251025 let this = self.clone();
10261026 let this_txn = self.clone();
1027 let pending = export::notify::PendingNotifications::default();
1027 let pending = push::notify::PendingNotifications::default();
10281028 let pending_txn = pending.clone();
10291029 self.database
10301030 .primary()
Modified lib/service/chat/src/services/outbound.rs lib/service/chat/src/services/outbound.rs +1 −1 View lib/service/chat/src/services/outbound.rs
@@ -375,7 +375,7 @@
375375
376376 let span = oltp::client::http_client_span("POST", &webhook.url);
377377 let delivery_request_id = delivery.id.to_string();
378 let response = export::middleware::with_request_id(
378 let response = api::middleware::with_request_id(
379379 Some(delivery_request_id.as_str()),
380380 oltp::client::send(
381381 span,
Modified lib/service/chat/src/services/presence.rs lib/service/chat/src/services/presence.rs +18 −17 View lib/service/chat/src/services/presence.rs
@@ -12,13 +12,14 @@
1212
1313use crate::errors::ChatError;
1414use crate::services::audience::Audience;
15use export::{AppDatabase, AppRedis};
15use cache::AppRedis;
16use db::AppDatabase;
1617use std::sync::Arc;
1718
1819#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
1920pub struct PresenceDto {
2021 pub user_id: i64,
21 pub user: Option<export::users::UserDto>,
22 pub user: Option<api::users::UserDto>,
2223 pub status: PresenceStatus,
2324 pub activities: serde_json::Value,
2425 pub last_seen_at: Option<OffsetDateTime>,
@@ -80,8 +81,8 @@
8081 let key = presence_key(caller);
8182 let value = serde_json::to_string(&payload)?;
8283 let result: Result<(), redis::RedisError> = match &mut conn {
83 export::RedisConnection::Standalone(c) => c.set_ex(&key, &value, ttl).await,
84 export::RedisConnection::Cluster(c) => c.set_ex(&key, &value, ttl).await,
84 cache::RedisConnection::Standalone(c) => c.set_ex(&key, &value, ttl).await,
85 cache::RedisConnection::Cluster(c) => c.set_ex(&key, &value, ttl).await,
8586 };
8687 if let Err(error) = result {
8788 tracing::warn!(%error, "failed to write presence to redis");
@@ -143,7 +144,7 @@
143144 let Some(value) = encode_presence(PresenceStatus::Active, serde_json::json!([])) else {
144145 return;
145146 };
146 match export::redis::set_nx_ex(&self.redis, &key, &value, ttl).await {
147 match cache::client::set_nx_ex(&self.redis, &key, &value, ttl).await {
147148 Ok(true) => {
148149 self.audience
149150 .realtime
@@ -154,7 +155,7 @@
154155 .await;
155156 }
156157 Ok(false) => {
157 if let Err(error) = export::redis::touch_expire(&self.redis, &key, ttl).await {
158 if let Err(error) = cache::client::touch_expire(&self.redis, &key, ttl).await {
158159 tracing::warn!(%error, "presence renew failed");
159160 }
160161 }
@@ -168,14 +169,14 @@
168169 pub async fn touch_presence(&self, uid: i64) {
169170 let ttl = self.settings.chat.online_ttl_secs();
170171 let key = presence_key(uid);
171 match export::redis::touch_expire(&self.redis, &key, ttl).await {
172 match cache::client::touch_expire(&self.redis, &key, ttl).await {
172173 Ok(true) => {}
173174 Ok(false) => {
174175 let Some(value) = encode_presence(PresenceStatus::Active, serde_json::json!([]))
175176 else {
176177 return;
177178 };
178 if let Err(error) = export::redis::set_nx_ex(&self.redis, &key, &value, ttl).await {
179 if let Err(error) = cache::client::set_nx_ex(&self.redis, &key, &value, ttl).await {
179180 tracing::warn!(%error, "presence re-mark failed");
180181 }
181182 }
@@ -191,12 +192,12 @@
191192 let now = OffsetDateTime::now_utc();
192193 let key = presence_key(uid);
193194 // 先读再删:DB 里留下的是用户最后处在的状态(Active/Away/Dnd/隐身)。
194 let last = export::redis::get_string(&self.redis, &key)
195 let last = cache::client::get_string(&self.redis, &key)
195196 .await
196197 .ok()
197198 .flatten()
198199 .and_then(|value| serde_json::from_str::<PresencePayload>(&value).ok());
199 if let Err(error) = export::redis::delete(&self.redis, &key).await {
200 if let Err(error) = cache::client::delete(&self.redis, &key).await {
200201 tracing::warn!(%error, "presence key delete failed");
201202 }
202203 let (status, activities) = match last {
@@ -266,8 +267,8 @@
266267 let mut conn = self.redis.connection_clone();
267268 let key = presence_key(uid);
268269 let value: Result<Option<String>, redis::RedisError> = match &mut conn {
269 export::RedisConnection::Standalone(c) => c.get(&key).await,
270 export::RedisConnection::Cluster(c) => c.get(&key).await,
270 cache::RedisConnection::Standalone(c) => c.get(&key).await,
271 cache::RedisConnection::Cluster(c) => c.get(&key).await,
271272 };
272273 if let Ok(Some(value)) = value
273274 && let Ok(payload) = serde_json::from_str::<PresencePayload>(&value)
@@ -385,13 +386,13 @@
385386 let mut conn = self.redis.connection_clone();
386387 let keys: Vec<String> = uids.iter().map(|uid| presence_key(*uid)).collect();
387388 let values: Vec<Option<String>> = match &mut conn {
388 export::RedisConnection::Standalone(c) => {
389 cache::RedisConnection::Standalone(c) => {
389390 redis::cmd("MGET")
390391 .arg(keys.clone())
391392 .query_async::<Vec<Option<String>>>(c)
392393 .await?
393394 }
394 export::RedisConnection::Cluster(c) => {
395 cache::RedisConnection::Cluster(c) => {
395396 // 集群里每个键可能落在不同槽位,MGET 不成立,只能逐个 GET。
396397 let mut values = Vec::with_capacity(keys.len());
397398 for key in &keys {
@@ -487,7 +488,7 @@
487488 pub async fn connection_open(&self, uid: i64, session: &str) -> Result<(), ChatError> {
488489 self.mark_online(uid).await;
489490 let ttl = self.settings.chat.online_ttl_secs();
490 export::redis::zset_touch(&self.redis, &export::push::online_key(uid), session, ttl)
491 cache::client::zset_touch(&self.redis, &push::protocol::online_key(uid), session, ttl)
491492 .await?;
492493 Ok(())
493494 }
@@ -496,7 +497,7 @@
496497 pub async fn connection_touch(&self, uid: i64, session: &str) -> Result<(), ChatError> {
497498 self.touch_presence(uid).await;
498499 let ttl = self.settings.chat.online_ttl_secs();
499 export::redis::zset_touch(&self.redis, &export::push::online_key(uid), session, ttl)
500 cache::client::zset_touch(&self.redis, &push::protocol::online_key(uid), session, ttl)
500501 .await?;
501502 Ok(())
502503 }
@@ -507,7 +508,7 @@
507508 /// `mark_offline` 放在 `zset_release` 返回值之后的原因。
508509 pub async fn connection_close(&self, uid: i64, session: &str) -> Result<(), ChatError> {
509510 let live =
510 export::redis::zset_release(&self.redis, &export::push::online_key(uid), session)
511 cache::client::zset_release(&self.redis, &push::protocol::online_key(uid), session)
511512 .await?;
512513 if live == 0 {
513514 self.mark_offline(uid).await;
Modified lib/service/chat/src/services/reactions.rs lib/service/chat/src/services/reactions.rs +1 −1 View lib/service/chat/src/services/reactions.rs
@@ -20,7 +20,7 @@
2020#[derive(Debug, Clone, Serialize, ToSchema)]
2121pub struct ReactionUserDto {
2222 pub emoji: String,
23 pub user: export::users::UserDto,
23 pub user: api::users::UserDto,
2424 pub created_at: OffsetDateTime,
2525}
2626
Modified lib/service/chat/src/services/reminders.rs lib/service/chat/src/services/reminders.rs +3 −3 View lib/service/chat/src/services/reminders.rs
@@ -29,7 +29,7 @@
2929
3030#[derive(Debug, Clone, Deserialize, ToSchema)]
3131pub struct CreateReminderCmd {
32 #[serde(deserialize_with = "export::serde_datetime::deserialize_datetime")]
32 #[serde(deserialize_with = "api::serde_datetime::deserialize_datetime")]
3333 pub remind_at: OffsetDateTime,
3434 #[serde(default)]
3535 pub note: Option<String>,
@@ -39,10 +39,10 @@
3939pub struct UpdateReminderCmd {
4040 #[serde(
4141 default,
42 deserialize_with = "export::serde_datetime::deserialize_opt_datetime"
42 deserialize_with = "api::serde_datetime::deserialize_opt_datetime"
4343 )]
4444 pub remind_at: Option<OffsetDateTime>,
45 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
45 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
4646 pub note: Option<Option<String>>,
4747}
4848
Modified lib/service/chat/src/services/rooms.rs lib/service/chat/src/services/rooms.rs +2 −2 View lib/service/chat/src/services/rooms.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::chat::messages::{self, ChatMessageType};
33use models::chat::{read_states, room_seq, room_user_settings};
44use models::dir::dirs::{self, DirKind};
@@ -61,7 +61,7 @@
6161 pub position: Option<i64>,
6262 /// Move the room under another directory node of the same space; `null` puts
6363 /// it back at the space root. Absent means "leave the parent alone".
64 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
64 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
6565 pub parent_id: Option<Option<Uuid>>,
6666}
6767
Modified lib/service/chat/src/services/service.rs lib/service/chat/src/services/service.rs +1 −1 View lib/service/chat/src/services/service.rs
@@ -1,7 +1,7 @@
11use std::sync::Arc;
22
33use config::AppConfig;
4use export::database::AppDatabase;
4use db::AppDatabase;
55
66#[derive(Clone)]
77pub struct ChatService {
Modified lib/service/chat/src/services/threads.rs lib/service/chat/src/services/threads.rs +3 −3 View lib/service/chat/src/services/threads.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::chat::messages::{self, FLAG_HAS_THREAD};
33use models::chat::thread_members::{self, ThreadNotifyLevel};
44use models::chat::threads;
@@ -36,7 +36,7 @@
3636 pub updated_at: OffsetDateTime,
3737}
3838
39pub type ThreadPage = export::pagination::Page<ThreadDto>;
39pub type ThreadPage = api::pagination::Page<ThreadDto>;
4040
4141#[derive(Debug, Clone, Deserialize, ToSchema)]
4242pub struct CreateThreadCmd {
@@ -248,7 +248,7 @@
248248 q: ListThreadQuery,
249249 ) -> Result<ThreadPage, ChatError> {
250250 let _ctx = lookup::require_room_readable(self, room_id, caller).await?;
251 let (limit, offset) = export::pagination::page_bounds(
251 let (limit, offset) = api::pagination::page_bounds(
252252 q.limit,
253253 q.offset,
254254 self.settings.chat.default_pagination,
Modified lib/service/chat/src/services/unfurl.rs lib/service/chat/src/services/unfurl.rs +2 −2 View lib/service/chat/src/services/unfurl.rs
@@ -136,9 +136,9 @@
136136 return;
137137 }
138138 let service = service.clone();
139 let request_id = export::middleware::request_id();
139 let request_id = api::middleware::request_id();
140140 tokio::spawn(async move {
141 export::middleware::with_request_id(
141 api::middleware::with_request_id(
142142 request_id.as_deref(),
143143 service.unfurl_message(room_id, message_id, content),
144144 )
Modified lib/service/chat/src/services/voice.rs lib/service/chat/src/services/voice.rs +11 −11 View lib/service/chat/src/services/voice.rs
@@ -310,7 +310,7 @@
310310 Err(_) => return map,
311311 };
312312 for (uid, user) in users {
313 let avatar_url = export::resolve_user_avatar_url(uid, &user.avatar_url);
313 let avatar_url = api::resolve_user_avatar_url(uid, &user.avatar_url);
314314 let avatar = if avatar_url.trim().is_empty() {
315315 None
316316 } else {
@@ -335,7 +335,7 @@
335335 let ttl = service.settings.livekit.presence_ttl_secs.max(60);
336336 let value = serde_json::to_string(member)?;
337337 let mut conn = service.participants.redis.connection_clone();
338 use export::RedisConnection;
338 use cache::RedisConnection;
339339 let key = voice_key(room_id);
340340 let field = member.user_id.to_string();
341341 let result: Result<i64, redis::RedisError> = match &mut conn {
@@ -375,7 +375,7 @@
375375 uid: i64,
376376) -> Result<(), ChatError> {
377377 let mut conn = service.participants.redis.connection_clone();
378 use export::RedisConnection;
378 use cache::RedisConnection;
379379 let key = voice_key(room_id);
380380 let field = uid.to_string();
381381 let _: Result<i64, redis::RedisError> = match &mut conn {
@@ -416,7 +416,7 @@
416416
417417pub async fn clear_room(service: &ChatService, room_id: Uuid) -> Result<(), ChatError> {
418418 let mut conn = service.participants.redis.connection_clone();
419 use export::RedisConnection;
419 use cache::RedisConnection;
420420 for key in [voice_key(room_id), hands_key(room_id)] {
421421 let _: Result<i64, redis::RedisError> = match &mut conn {
422422 RedisConnection::Standalone(c) => redis::cmd("DEL").arg(&key).query_async(c).await,
@@ -432,7 +432,7 @@
432432 room_id: Uuid,
433433) -> Result<Vec<VoiceMember>, ChatError> {
434434 let mut conn = service.participants.redis.connection_clone();
435 use export::RedisConnection;
435 use cache::RedisConnection;
436436 let key = voice_key(room_id);
437437 let raw: Result<HashMap<String, String>, redis::RedisError> = match &mut conn {
438438 RedisConnection::Standalone(c) => redis::cmd("HGETALL").arg(&key).query_async(c).await,
@@ -453,7 +453,7 @@
453453 uid: i64,
454454) -> Result<Option<HandEntry>, ChatError> {
455455 let mut conn = service.participants.redis.connection_clone();
456 use export::RedisConnection;
456 use cache::RedisConnection;
457457 let key = hands_key(room_id);
458458 let field = uid.to_string();
459459 let raw: Result<Option<String>, redis::RedisError> = match &mut conn {
@@ -483,7 +483,7 @@
483483 room_id: Uuid,
484484) -> Result<HashMap<i64, HandEntry>, ChatError> {
485485 let mut conn = service.participants.redis.connection_clone();
486 use export::RedisConnection;
486 use cache::RedisConnection;
487487 let key = hands_key(room_id);
488488 let raw: Result<HashMap<String, String>, redis::RedisError> = match &mut conn {
489489 RedisConnection::Standalone(c) => redis::cmd("HGETALL").arg(&key).query_async(c).await,
@@ -510,7 +510,7 @@
510510 let ttl = service.settings.livekit.hand_ttl_secs.max(60);
511511 let value = serde_json::to_string(entry)?;
512512 let mut conn = service.participants.redis.connection_clone();
513 use export::RedisConnection;
513 use cache::RedisConnection;
514514 let key = hands_key(room_id);
515515 let field = uid.to_string();
516516 let result: Result<i64, redis::RedisError> = match &mut conn {
@@ -773,7 +773,7 @@
773773 /// 纯读取,不做权限校验:调用方要么刚校验过,要么只用于合并写入。
774774 async fn voice_layout_raw(&self, room_id: Uuid) -> Result<VoiceLayoutDto, ChatError> {
775775 let mut conn = self.participants.redis.connection_clone();
776 use export::RedisConnection;
776 use cache::RedisConnection;
777777 let key = layout_key(room_id);
778778 let raw: Result<Option<String>, redis::RedisError> = match &mut conn {
779779 RedisConnection::Standalone(c) => redis::cmd("GET").arg(&key).query_async(c).await,
@@ -806,7 +806,7 @@
806806 .to_string();
807807 let ttl = self.settings.livekit.presence_ttl_secs.max(60);
808808 let mut conn = self.participants.redis.connection_clone();
809 use export::RedisConnection;
809 use cache::RedisConnection;
810810 let key = layout_key(room_id);
811811 let mut command = redis::cmd("EVAL");
812812 command
@@ -883,7 +883,7 @@
883883 ));
884884 }
885885 let mut conn = self.participants.redis.connection_clone();
886 use export::RedisConnection;
886 use cache::RedisConnection;
887887 let key = hands_key(room_id);
888888 let field = caller.to_string();
889889 let _: Result<i64, redis::RedisError> = match &mut conn {
Modified lib/service/chat/src/share/events.rs lib/service/chat/src/share/events.rs +1 −1 View lib/service/chat/src/share/events.rs
@@ -1,4 +1,4 @@
1use export::AppDatabase;
1use db::AppDatabase;
22use models::chat::messages;
33use models::room::rooms;
44use sea_orm::EntityTrait;
Modified lib/service/chat/src/share/notify.rs lib/service/chat/src/share/notify.rs +2 −2 View lib/service/chat/src/share/notify.rs
@@ -84,7 +84,7 @@
8484#[allow(clippy::too_many_arguments)]
8585pub async fn notify_user(
8686 db: &impl ConnectionTrait,
87 pending: &export::notify::PendingNotifications,
87 pending: &push::notify::PendingNotifications,
8888 recipient: i64,
8989 ntype: NotificationType,
9090 title: String,
@@ -94,7 +94,7 @@
9494) -> Result<(), ChatError> {
9595 // The row stores already-rendered text: there is no schema column for the
9696 // language, so callers resolve it per recipient and pass finished copy in.
97 let row = export::notify::insert(db, recipient, ntype, title, body, data, actor_uid).await?;
97 let row = push::notify::insert(db, recipient, ntype, title, body, data, actor_uid).await?;
9898 pending.push(recipient, row.to_event_value());
9999 Ok(())
100100}
Modified lib/service/chat/src/share/realtime.rs lib/service/chat/src/share/realtime.rs +2 −2 View lib/service/chat/src/share/realtime.rs
@@ -119,11 +119,11 @@
119119/// KenEvent(MQ → socket),本服务只负责把"发生了什么"持久化下来。
120120#[derive(Clone)]
121121pub struct Realtime {
122 database: std::sync::Arc<export::AppDatabase>,
122 database: std::sync::Arc<db::AppDatabase>,
123123}
124124
125125impl Realtime {
126 pub fn new(database: std::sync::Arc<export::AppDatabase>) -> Self {
126 pub fn new(database: std::sync::Arc<db::AppDatabase>) -> Self {
127127 Self { database }
128128 }
129129
Modified lib/service/chat/src/errors.rs lib/service/chat/src/errors.rs +8 −8 View lib/service/chat/src/errors.rs
@@ -1,6 +1,6 @@
11use std::fmt;
22
3pub use export::is_unique_violation;
3pub use api::is_unique_violation;
44
55#[derive(Debug)]
66pub enum ChatError {
@@ -29,12 +29,12 @@
2929
3030impl std::error::Error for ChatError {}
3131
32export::db_error_conversions!(ChatError);
33export::storage_error_conversion!(ChatError);
34export::redis_error_conversion!(ChatError);
35export::export_error_conversion!(ChatError);
36export::json_payload_conversion!(ChatError);
37export::access_error_conversion!(ChatError, BadRequest);
32auth::auth_error_conversion!(ChatError);
33api::db_error_conversions!(ChatError);
34storage::storage_error_conversion!(ChatError);
35cache::redis_error_conversion!(ChatError);
36api::json_payload_conversion!(ChatError);
37api::access_error_conversion!(ChatError, BadRequest);
3838
3939impl From<dir::Error> for ChatError {
4040 fn from(error: dir::Error) -> Self {
@@ -46,7 +46,7 @@
4646 }
4747}
4848
49export::api_error! {
49api::api_error! {
5050 log: "chat",
5151 pub enum ApiError {
5252 BadRequest(400, "request failed validation"),
Modified lib/service/chat/src/openapi.rs lib/service/chat/src/openapi.rs +13 −13 View lib/service/chat/src/openapi.rs
@@ -1,4 +1,4 @@
1use export::rest::AppResponseData;
1use api::rest::AppResponseData;
22use utoipa::OpenApi;
33
44#[derive(OpenApi)]
@@ -90,19 +90,19 @@
9090 crate::handlers::voice::livekit_webhook,
9191 ),
9292 components(schemas(
93 export::pagination::PageQuery,
93 api::pagination::PageQuery,
9494 imaging::layout::ImageVariant,
95 export::pagination::Page<crate::services::dms::DmDto>,
96 export::pagination::Page<crate::services::threads::ThreadDto>,
97 export::pagination::Page<crate::services::drafts::DraftDto>,
98 export::pagination::Page<crate::services::webhooks::WebhookDto>,
99 export::pagination::Page<crate::services::bookmarks::BookmarkDto>,
100 export::pagination::Page<crate::services::emojis::EmojiDto>,
101 export::pagination::Page<crate::services::messages::MessageDto>,
102 export::pagination::Page<crate::services::rooms::RoomBriefDto>,
103 AppResponseData<export::rest::NoData>,
104 export::rest::NoData,
105 export::users::UserDto,
95 api::pagination::Page<crate::services::dms::DmDto>,
96 api::pagination::Page<crate::services::threads::ThreadDto>,
97 api::pagination::Page<crate::services::drafts::DraftDto>,
98 api::pagination::Page<crate::services::webhooks::WebhookDto>,
99 api::pagination::Page<crate::services::bookmarks::BookmarkDto>,
100 api::pagination::Page<crate::services::emojis::EmojiDto>,
101 api::pagination::Page<crate::services::messages::MessageDto>,
102 api::pagination::Page<crate::services::rooms::RoomBriefDto>,
103 AppResponseData<api::rest::NoData>,
104 api::rest::NoData,
105 api::users::UserDto,
106106 models::chat::messages::AuthorType,
107107 models::chat::messages::ChatMessageType,
108108 models::chat::attachments::AttachmentStatus,
Modified lib/service/chat/src/routes.rs lib/service/chat/src/routes.rs +13 −16 View lib/service/chat/src/routes.rs
@@ -1,5 +1,5 @@
1use export::http::Router;
2use export::http::routing::{delete, get, post};
1use api::http::Router;
2use api::http::routing::{delete, get, post};
33
44use crate::handlers::attachments::{
55 create_attachment, download_attachment, finalize_attachment, get_attachment,
@@ -60,7 +60,7 @@
6060 )
6161 .route(
6262 "/chat/rooms/{room_id}/messages/{message_id}/pin",
63 export::http::routing::put(set_message_pin),
63 api::http::routing::put(set_message_pin),
6464 )
6565 .route("/chat/rooms/{room_id}/pins", get(list_pins))
6666 .route(
@@ -83,11 +83,11 @@
8383 )
8484 .route(
8585 "/chat/threads/{thread_id}/members/@me",
86 export::http::routing::put(follow_thread).delete(unfollow_thread),
86 api::http::routing::put(follow_thread).delete(unfollow_thread),
8787 )
8888 .route(
8989 "/chat/threads/{thread_id}/read-state",
90 export::http::routing::put(mark_thread_read),
90 api::http::routing::put(mark_thread_read),
9191 )
9292 .route(
9393 "/chat/rooms/{room_id}/messages/{message_id}/reactions",
@@ -95,7 +95,7 @@
9595 )
9696 .route(
9797 "/chat/rooms/{room_id}/messages/{message_id}/reactions/@me",
98 export::http::routing::put(add_reaction).delete(remove_reaction),
98 api::http::routing::put(add_reaction).delete(remove_reaction),
9999 )
100100 .route(
101101 "/chat/rooms/{room_id}/messages/{message_id}/reminders",
@@ -104,7 +104,7 @@
104104 .route("/chat/reminders", get(list_reminders))
105105 .route(
106106 "/chat/reminders/{reminder_id}",
107 export::http::routing::delete(cancel_reminder)
107 api::http::routing::delete(cancel_reminder)
108108 .patch(crate::handlers::reminders::update_reminder),
109109 )
110110 .route(
@@ -116,10 +116,7 @@
116116 get(list_space_read_states),
117117 )
118118 .route("/chat/dms", get(list_dms).post(open_dm))
119 .route(
120 "/chat/dms/{room_id}",
121 export::http::routing::delete(close_dm),
122 )
119 .route("/chat/dms/{room_id}", api::http::routing::delete(close_dm))
123120 .route("/chat/attachments", post(create_attachment))
124121 .route("/chat/attachments/{attachment_id}", get(get_attachment))
125122 .route(
@@ -148,7 +145,7 @@
148145 )
149146 .route(
150147 "/chat/rooms/{room_id}/bookmarks/{bookmark_id}",
151 export::http::routing::patch(update_bookmark).delete(delete_bookmark),
148 api::http::routing::patch(update_bookmark).delete(delete_bookmark),
152149 )
153150 .route(
154151 "/chat/rooms/{room_id}/draft",
@@ -157,7 +154,7 @@
157154 .delete(crate::handlers::drafts::delete_draft),
158155 )
159156 .route("/chat/drafts", get(list_my_drafts))
160 .route("/chat/presence", export::http::routing::put(set_presence))
157 .route("/chat/presence", api::http::routing::put(set_presence))
161158 .route("/chat/users/{user_id}/presence", get(get_presence))
162159 .route(
163160 "/chat/spaces/{space_name}/presences",
@@ -173,7 +170,7 @@
173170 )
174171 .route(
175172 "/chat/rooms/{room_id}/webhooks/{webhook_id}",
176 export::http::routing::delete(delete_webhook)
173 api::http::routing::delete(delete_webhook)
177174 .patch(crate::handlers::webhooks::update_webhook),
178175 )
179176 .route(
@@ -183,7 +180,7 @@
183180 )
184181 .route(
185182 "/chat/rooms/{room_id}/outbound-webhooks/{webhook_id}",
186 export::http::routing::patch(crate::handlers::webhooks::update_outbound_webhook)
183 api::http::routing::patch(crate::handlers::webhooks::update_outbound_webhook)
187184 .delete(crate::handlers::webhooks::delete_outbound_webhook),
188185 )
189186 .route("/chat/voice/config", get(voice_config))
@@ -233,7 +230,7 @@
233230 "/chat/rooms/{room_id}/voice/recording/stop",
234231 post(stop_recording),
235232 )
236 .wrap(export::http::Guard::Session);
233 .wrap(api::http::Guard::Session);
237234
238235 let open = Router::<ChatService>::new()
239236 .route("/chat/hooks/{token}", post(post_via_webhook))
Modified lib/service/chat/src/worker.rs lib/service/chat/src/worker.rs +4 −4 View lib/service/chat/src/worker.rs
@@ -30,7 +30,7 @@
3030 interval.tick().await;
3131 let request_id = uuid::Uuid::now_v7().to_string();
3232 let span = tracing::info_span!("chat.background", request_id = %request_id);
33 if let Err(error) = export::middleware::with_request_id(
33 if let Err(error) = api::middleware::with_request_id(
3434 Some(request_id.as_str()),
3535 service.deliver_due_reminders().instrument(span),
3636 )
@@ -39,7 +39,7 @@
3939 tracing::warn!(%error, "chat reminder delivery failed");
4040 }
4141 let span = tracing::info_span!("chat.background", request_id = %request_id);
42 if let Err(error) = export::middleware::with_request_id(
42 if let Err(error) = api::middleware::with_request_id(
4343 Some(request_id.as_str()),
4444 service.deliver_pending_webhook_events().instrument(span),
4545 )
@@ -49,7 +49,7 @@
4949 }
5050 tick = tick.wrapping_add(1);
5151 if tick.is_multiple_of(120) {
52 if let Err(error) = export::middleware::with_request_id(
52 if let Err(error) = api::middleware::with_request_id(
5353 Some(request_id.as_str()),
5454 service.prune_old_mentions(),
5555 )
@@ -57,7 +57,7 @@
5757 {
5858 tracing::warn!(%error, "chat mention prune failed");
5959 }
60 if let Err(error) = export::middleware::with_request_id(
60 if let Err(error) = api::middleware::with_request_id(
6161 Some(request_id.as_str()),
6262 service.cleanup_stale_attachments(),
6363 )
Modified lib/service/chat/Cargo.toml lib/service/chat/Cargo.toml +5 −1 View lib/service/chat/Cargo.toml
@@ -4,12 +4,16 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8cache = { workspace = true }
9db = { workspace = true }
10media = { workspace = true }
11push = { workspace = true }
712auth = { workspace = true }
813dir = { workspace = true }
914email = { workspace = true }
1015async-trait = { workspace = true }
1116config = { workspace = true }
12export = { workspace = true }
1317events = { workspace = true }
1418i18n = { workspace = true }
1519imaging = { workspace = true }
Modified lib/service/deletion/src/lib.rs lib/service/deletion/src/lib.rs +4 −3 View lib/service/deletion/src/lib.rs
@@ -1,6 +1,7 @@
11use std::time::Duration;
22
3use export::{AppState, KenAuthError};
3use auth::KenAuthError;
4use bootstrap::AppState;
45use models::dir::{dir_overwrite_group, dir_overwrite_users, dirs};
56use models::repo::repos;
67use models::room::rooms;
@@ -224,7 +225,7 @@
224225 interval.tick().await;
225226 let request_id = Uuid::now_v7().to_string();
226227 let span = tracing::info_span!("deletion.worker", request_id = %request_id);
227 let result = export::middleware::with_request_id(
228 let result = api::middleware::with_request_id(
228229 Some(&request_id),
229230 purge_due(&state, &accounts).instrument(span),
230231 )
@@ -294,7 +295,7 @@
294295 &cfg.kenshell_rpc_key,
295296 Duration::from_secs(cfg.kenshell_timeout_secs.max(1)),
296297 )
297 .map(|client| client.with_request_id(export::middleware::request_id))
298 .map(|client| client.with_request_id(api::middleware::request_id))
298299 .map_err(ken_shell)
299300 }?;
300301 let repos = shell
Modified lib/service/deletion/Cargo.toml lib/service/deletion/Cargo.toml +2 −1 View lib/service/deletion/Cargo.toml
@@ -4,9 +4,10 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8bootstrap = { workspace = true }
79auth = { workspace = true }
810config = { workspace = true }
9export = { workspace = true }
1011proto = { workspace = true }
1112models = { workspace = true }
1213sea-orm = { workspace = true }
Modified lib/service/git/src/context/facade.rs lib/service/git/src/context/facade.rs +1 −1 View lib/service/git/src/context/facade.rs
@@ -2,7 +2,7 @@
22use std::sync::Arc;
33
44use ::cache::Cache;
5use export::AppDatabase;
5use db::AppDatabase;
66use models::repo::repos;
77use proto::kenshell::common::v1::{GitActor, RepositoryRef, WriteOptions};
88
Modified lib/service/git/src/handler/analysis/code_activity.rs lib/service/git/src/handler/analysis/code_activity.rs +2 −2 View lib/service/git/src/handler/analysis/code_activity.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/analysis/contributors.rs lib/service/git/src/handler/analysis/contributors.rs +2 −2 View lib/service/git/src/handler/analysis/contributors.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/analysis/languages.rs lib/service/git/src/handler/analysis/languages.rs +2 −2 View lib/service/git/src/handler/analysis/languages.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/analysis/languages_read.rs lib/service/git/src/handler/analysis/languages_read.rs +2 −2 View lib/service/git/src/handler/analysis/languages_read.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/archives/create.rs lib/service/git/src/handler/archives/create.rs +2 −2 View lib/service/git/src/handler/archives/create.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPath, require_writer};
Modified lib/service/git/src/handler/archives/create_bundle.rs lib/service/git/src/handler/archives/create_bundle.rs +2 −2 View lib/service/git/src/handler/archives/create_bundle.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPath, require_writer};
Modified lib/service/git/src/handler/archives/download.rs lib/service/git/src/handler/archives/download.rs +2 −2 View lib/service/git/src/handler/archives/download.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPathRev, resolve_reader};
Modified lib/service/git/src/handler/blobs/content.rs lib/service/git/src/handler/blobs/content.rs +2 −2 View lib/service/git/src/handler/blobs/content.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/blobs/list_lfs_pointers.rs lib/service/git/src/handler/blobs/list_lfs_pointers.rs +2 −2 View lib/service/git/src/handler/blobs/list_lfs_pointers.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/blobs/metadata.rs lib/service/git/src/handler/blobs/metadata.rs +2 −2 View lib/service/git/src/handler/blobs/metadata.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branch_protection/create_policy.rs lib/service/git/src/handler/branch_protection/create_policy.rs +2 −2 View lib/service/git/src/handler/branch_protection/create_policy.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPath, require_repo_admin};
Modified lib/service/git/src/handler/branch_protection/delete_policy.rs lib/service/git/src/handler/branch_protection/delete_policy.rs +2 −2 View lib/service/git/src/handler/branch_protection/delete_policy.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branch_protection/get_policy.rs lib/service/git/src/handler/branch_protection/get_policy.rs +2 −2 View lib/service/git/src/handler/branch_protection/get_policy.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branch_protection/list_policies.rs lib/service/git/src/handler/branch_protection/list_policies.rs +2 −2 View lib/service/git/src/handler/branch_protection/list_policies.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPath, require_repo_admin};
Modified lib/service/git/src/handler/branch_protection/update_policy.rs lib/service/git/src/handler/branch_protection/update_policy.rs +2 −2 View lib/service/git/src/handler/branch_protection/update_policy.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branches/create.rs lib/service/git/src/handler/branches/create.rs +2 −2 View lib/service/git/src/handler/branches/create.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branches/delete.rs lib/service/git/src/handler/branches/delete.rs +2 −2 View lib/service/git/src/handler/branches/delete.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branches/get.rs lib/service/git/src/handler/branches/get.rs +2 −2 View lib/service/git/src/handler/branches/get.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branches/list.rs lib/service/git/src/handler/branches/list.rs +7 −7 View lib/service/git/src/handler/branches/list.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
@@ -12,17 +12,17 @@
1212 path = "/repos/{space_name}/{repo_name}/branches",
1313 tag = "branches",
1414 description = "列出 Git 分支并同步保护状态与数据库镜像后分页返回。",
15 params(crate::handler::RepoPath, export::pagination::PageQuery),
15 params(crate::handler::RepoPath, api::pagination::PageQuery),
1616 responses(
17 (status = 200, description = "list branches", body = AppResponseData<export::pagination::Page<BranchDto>>)
17 (status = 200, description = "list branches", body = AppResponseData<api::pagination::Page<BranchDto>>)
1818 )
1919)]
2020pub async fn list_branches(
2121 State(service): State<GitService>,
2222 session: Session,
2323 Path(path): Path<crate::handler::RepoPath>,
24 Query(page): Query<export::pagination::PageQuery>,
25) -> Result<AppResponseData<export::pagination::Page<BranchDto>>, ApiError> {
24 Query(page): Query<api::pagination::PageQuery>,
25) -> Result<AppResponseData<api::pagination::Page<BranchDto>>, ApiError> {
2626 let (ctx, _) = handler::resolve_reader(
2727 &service,
2828 &session,
@@ -41,7 +41,7 @@
4141 .skip(offset as usize)
4242 .take(limit as usize)
4343 .collect();
44 Ok(AppResponseData::ok(export::pagination::Page {
44 Ok(AppResponseData::ok(api::pagination::Page {
4545 items,
4646 total,
4747 limit,
Modified lib/service/git/src/handler/branches/rename.rs lib/service/git/src/handler/branches/rename.rs +2 −2 View lib/service/git/src/handler/branches/rename.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/branches/set_default.rs lib/service/git/src/handler/branches/set_default.rs +2 −2 View lib/service/git/src/handler/branches/set_default.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/code_comments/create_code_comment.rs lib/service/git/src/handler/code_comments/create_code_comment.rs +2 −2 View lib/service/git/src/handler/code_comments/create_code_comment.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/code_comments/list_code_comments.rs lib/service/git/src/handler/code_comments/list_code_comments.rs +2 −2 View lib/service/git/src/handler/code_comments/list_code_comments.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/code_comments/modify.rs lib/service/git/src/handler/code_comments/modify.rs +2 −2 View lib/service/git/src/handler/code_comments/modify.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44use uuid::Uuid;
55
66use crate::errors::{ApiError, GitApiError};
Modified lib/service/git/src/handler/code_comments/resolve_code_comment.rs lib/service/git/src/handler/code_comments/resolve_code_comment.rs +2 −2 View lib/service/git/src/handler/code_comments/resolve_code_comment.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/commits/get.rs lib/service/git/src/handler/commits/get.rs +2 −2 View lib/service/git/src/handler/commits/get.rs
@@ -1,7 +1,7 @@
11use crate::rpcgit::commit::types::CommitInfo;
22use ::session::Session;
3use export::http::{Path, State};
4use export::rest::AppResponseData;
3use api::http::{Path, State};
4use api::rest::AppResponseData;
55
66use crate::errors::{ApiError, GitApiError};
77use crate::handler;
Modified lib/service/git/src/handler/commits/is_ancestor.rs lib/service/git/src/handler/commits/is_ancestor.rs +2 −2 View lib/service/git/src/handler/commits/is_ancestor.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44use serde::Serialize;
55
66use crate::errors::{ApiError, GitApiError};
Modified lib/service/git/src/handler/commits/list.rs lib/service/git/src/handler/commits/list.rs +2 −2 View lib/service/git/src/handler/commits/list.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/commits/list_commit_statuses.rs lib/service/git/src/handler/commits/list_commit_statuses.rs +2 −2 View lib/service/git/src/handler/commits/list_commit_statuses.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/commits/rev_parse.rs lib/service/git/src/handler/commits/rev_parse.rs +2 −2 View lib/service/git/src/handler/commits/rev_parse.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/commits/set_commit_status.rs lib/service/git/src/handler/commits/set_commit_status.rs +2 −2 View lib/service/git/src/handler/commits/set_commit_status.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/commits/stats.rs lib/service/git/src/handler/commits/stats.rs +2 −2 View lib/service/git/src/handler/commits/stats.rs
@@ -2,8 +2,8 @@
22
33use crate::rpcgit::commit::types::CommitStats;
44use ::session::Session;
5use export::http::{Path, Query, State};
6use export::rest::AppResponseData;
5use api::http::{Path, Query, State};
6use api::rest::AppResponseData;
77
88use crate::errors::{ApiError, GitApiError};
99use crate::handler;
Modified lib/service/git/src/handler/commits/sync_commit.rs lib/service/git/src/handler/commits/sync_commit.rs +2 −2 View lib/service/git/src/handler/commits/sync_commit.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::AppResponseData;
2use api::http::{Path, State};
3use api::rest::AppResponseData;
44use serde::Serialize;
55
66use crate::errors::{ApiError, GitApiError};
Modified lib/service/git/src/handler/conflicts/detail.rs lib/service/git/src/handler/conflicts/detail.rs +2 −2 View lib/service/git/src/handler/conflicts/detail.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/conflicts/get_conflicts.rs lib/service/git/src/handler/conflicts/get_conflicts.rs +2 −2 View lib/service/git/src/handler/conflicts/get_conflicts.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/content/caller_signature.rs lib/service/git/src/handler/content/caller_signature.rs +2 −2 View lib/service/git/src/handler/content/caller_signature.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, State};
3use export::rest::AppResponseData;
2use api::http::{Json, State};
3use api::rest::AppResponseData;
44use time::OffsetDateTime;
55
66use crate::errors::{ApiError, GitApiError};
Modified lib/service/git/src/handler/content/commit_object.rs lib/service/git/src/handler/content/commit_object.rs +2 −2 View lib/service/git/src/handler/content/commit_object.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPath, require_writer};
Modified lib/service/git/src/handler/content/write_blob.rs lib/service/git/src/handler/content/write_blob.rs +2 −2 View lib/service/git/src/handler/content/write_blob.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPath, require_writer};
Modified lib/service/git/src/handler/content/write_tree_from_files.rs lib/service/git/src/handler/content/write_tree_from_files.rs +2 −2 View lib/service/git/src/handler/content/write_tree_from_files.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler::{RepoPath, require_writer};
Modified lib/service/git/src/handler/diffs/for_commit.rs lib/service/git/src/handler/diffs/for_commit.rs +2 −2 View lib/service/git/src/handler/diffs/for_commit.rs
@@ -1,7 +1,7 @@
11use crate::rpcgit::diff::types::ChangedPath;
22use ::session::Session;
3use export::http::{Path, State};
4use export::rest::AppResponseData;
3use api::http::{Path, State};
4use api::rest::AppResponseData;
55
66use crate::errors::{ApiError, GitApiError};
77use crate::handler;
Modified lib/service/git/src/handler/diffs/get_diff.rs lib/service/git/src/handler/diffs/get_diff.rs +2 −2 View lib/service/git/src/handler/diffs/get_diff.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44use serde::Deserialize;
55
66use crate::errors::{ApiError, GitApiError};
Modified lib/service/git/src/handler/diffs/range_diff.rs lib/service/git/src/handler/diffs/range_diff.rs +2 −2 View lib/service/git/src/handler/diffs/range_diff.rs
@@ -1,7 +1,7 @@
11use crate::rpcgit::diff::types::RangeDiffSpec;
22use ::session::Session;
3use export::http::{Path, Query, State};
4use export::rest::AppResponseData;
3use api::http::{Path, Query, State};
4use api::rest::AppResponseData;
55
66use crate::errors::{ApiError, GitApiError};
77use crate::handler;
Modified lib/service/git/src/handler/diffs/raw.rs lib/service/git/src/handler/diffs/raw.rs +2 −2 View lib/service/git/src/handler/diffs/raw.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/hooks/execute_script.rs lib/service/git/src/handler/hooks/execute_script.rs +2 −2 View lib/service/git/src/handler/hooks/execute_script.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/hooks/post_receive.rs lib/service/git/src/handler/hooks/post_receive.rs +2 −2 View lib/service/git/src/handler/hooks/post_receive.rs
@@ -1,5 +1,5 @@
1use export::http::{Json, State};
2use export::rest::AppResponseData;
1use api::http::{Json, State};
2use api::rest::AppResponseData;
33
44use crate::errors::{ApiError, GitApiError};
55use crate::service::GitService;
Modified lib/service/git/src/handler/hooks/pre_receive.rs lib/service/git/src/handler/hooks/pre_receive.rs +2 −2 View lib/service/git/src/handler/hooks/pre_receive.rs
@@ -1,5 +1,5 @@
1use export::http::{Json, State};
2use export::rest::AppResponseData;
1use api::http::{Json, State};
2use api::rest::AppResponseData;
33
44use crate::errors::{ApiError, GitApiError};
55use crate::service::GitService;
Modified lib/service/git/src/handler/html/badge.rs lib/service/git/src/handler/html/badge.rs +1 −1 View lib/service/git/src/handler/html/badge.rs
@@ -1,4 +1,4 @@
1use export::http::{Path, Response, State};
1use api::http::{Path, Response, State};
22use maud::html;
33
44use crate::handler::html::{HtmlRepoPath, archived_class, format_size, resolve, response_html};
Modified lib/service/git/src/handler/html/blame.rs lib/service/git/src/handler/html/blame.rs +1 −1 View lib/service/git/src/handler/html/blame.rs
@@ -1,7 +1,7 @@
11use std::path::PathBuf;
22
33use crate::rpcgit::commit::types::TreeEntryMode;
4use export::http::{Path, Query, Response, State};
4use api::http::{Path, Query, Response, State};
55use maud::html;
66
77use crate::handler::html::{
Modified lib/service/git/src/handler/html/blob_content.rs lib/service/git/src/handler/html/blob_content.rs +1 −1 View lib/service/git/src/handler/html/blob_content.rs
@@ -1,5 +1,5 @@
11use crate::rpcgit::commit::types::TreeEntryMode;
2use export::http::{Path, Query, Response, State};
2use api::http::{Path, Query, Response, State};
33use maud::html;
44
55use crate::handler::html::{
Modified lib/service/git/src/handler/html/blob_header.rs lib/service/git/src/handler/html/blob_header.rs +1 −1 View lib/service/git/src/handler/html/blob_header.rs
@@ -1,4 +1,4 @@
1use export::http::{Path, Query, Response, State};
1use api::http::{Path, Query, Response, State};
22use maud::html;
33
44use crate::handler::html::{HtmlRepoPath, archived_class, resolve_view, response_html};
Modified lib/service/git/src/handler/html/blob_pages.rs lib/service/git/src/handler/html/blob_pages.rs +1 −1 View lib/service/git/src/handler/html/blob_pages.rs
@@ -1,5 +1,5 @@
11use actix_web::http::header;
2use export::http::{Path, Query, Response, State};
2use api::http::{Path, Query, Response, State};
33
44use crate::handler::html::{HtmlRepoPath, error, resolve_view};
55use crate::service::{GitService, pdf};
Modified lib/service/git/src/handler/html/breadcrumbs.rs lib/service/git/src/handler/html/breadcrumbs.rs +1 −1 View lib/service/git/src/handler/html/breadcrumbs.rs
@@ -1,4 +1,4 @@
1use export::http::{Path, Query, Response, State};
1use api::http::{Path, Query, Response, State};
22use maud::html;
33
44use crate::handler::html::{HtmlRepoPath, archived_class, error, resolve, response_html};
Modified lib/service/git/src/handler/html/clone_buttons.rs lib/service/git/src/handler/html/clone_buttons.rs +1 −1 View lib/service/git/src/handler/html/clone_buttons.rs
@@ -1,4 +1,4 @@
1use export::http::{Path, Response, State};
1use api::http::{Path, Response, State};
22use maud::html;
33
44use crate::handler::html::{HtmlRepoPath, clone_https_url, clone_ssh_url, resolve, response_html};
Modified lib/service/git/src/handler/html/commit_diff.rs lib/service/git/src/handler/html/commit_diff.rs +1 −1 View lib/service/git/src/handler/html/commit_diff.rs
@@ -1,4 +1,4 @@
1use export::http::{Path, Query, Response, State};
1use api::http::{Path, Query, Response, State};
22use maud::{Markup, html};
33
44use crate::handler::html::{
Modified lib/service/git/src/handler/html/commits.rs lib/service/git/src/handler/html/commits.rs +1 −1 View lib/service/git/src/handler/html/commits.rs
@@ -1,6 +1,6 @@
11use std::path::PathBuf;
22
3use export::http::{Path, Query, Response, State};
3use api::http::{Path, Query, Response, State};
44use maud::html;
55
66use crate::handler::html::{
Modified lib/service/git/src/handler/blame.rs lib/service/git/src/handler/blame.rs +2 −2 View lib/service/git/src/handler/blame.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/licenses.rs lib/service/git/src/handler/licenses.rs +5 −8 View lib/service/git/src/handler/licenses.rs
@@ -1,5 +1,5 @@
1use export::http::{Json, Path, Query, State};
2use export::rest::AppResponseData;
1use api::http::{Json, Path, Query, State};
2use api::rest::AppResponseData;
33use serde::Deserialize;
44use utoipa::IntoParams;
55
@@ -34,12 +34,9 @@
3434) -> Result<AppResponseData<Vec<LicenseDto>>, ApiError> {
3535 let limit = q
3636 .limit
37 .unwrap_or(export::pagination::DEFAULT_PAGE_LIMIT)
38 .clamp(1, export::pagination::MAX_PAGE_LIMIT);
39 let offset = q
40 .offset
41 .unwrap_or(0)
42 .clamp(0, export::pagination::MAX_OFFSET);
37 .unwrap_or(api::pagination::DEFAULT_PAGE_LIMIT)
38 .clamp(1, api::pagination::MAX_PAGE_LIMIT);
39 let offset = q.offset.unwrap_or(0).clamp(0, api::pagination::MAX_OFFSET);
4340 let out = service
4441 .list_licenses(limit, offset)
4542 .await
Modified lib/service/git/src/handler/path_log.rs lib/service/git/src/handler/path_log.rs +2 −2 View lib/service/git/src/handler/path_log.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::{ApiError, GitApiError};
66use crate::handler;
Modified lib/service/git/src/handler/stars.rs lib/service/git/src/handler/stars.rs +3 −6 View lib/service/git/src/handler/stars.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44use serde::Deserialize;
55use utoipa::IntoParams;
66
@@ -106,10 +106,7 @@
106106 .await?
107107 .0;
108108 let limit = q.limit.unwrap_or(50).clamp(1, 100);
109 let offset = q
110 .offset
111 .unwrap_or(0)
112 .clamp(0, export::pagination::MAX_OFFSET);
109 let offset = q.offset.unwrap_or(0).clamp(0, api::pagination::MAX_OFFSET);
113110 let out = service
114111 .list_stargazers(&ctx, limit, offset)
115112 .await
Modified lib/service/git/src/handler/topics.rs lib/service/git/src/handler/topics.rs +4 −10 View lib/service/git/src/handler/topics.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, Query, State};
3use api::rest::{AppResponseData, NoData};
44use serde::{Deserialize, Serialize};
55use utoipa::IntoParams;
66
@@ -68,10 +68,7 @@
6868 Query(q): Query<TopicListQuery>,
6969) -> Result<AppResponseData<Vec<TopicDto>>, ApiError> {
7070 let limit = q.limit.unwrap_or(50).clamp(1, 100);
71 let offset = q
72 .offset
73 .unwrap_or(0)
74 .clamp(0, export::pagination::MAX_OFFSET);
71 let offset = q.offset.unwrap_or(0).clamp(0, api::pagination::MAX_OFFSET);
7572 let out = service
7673 .list_topics(limit, offset)
7774 .await
@@ -116,10 +113,7 @@
116113 Query(q): Query<TopicListQuery>,
117114) -> Result<AppResponseData<Vec<TopicRepoDto>>, ApiError> {
118115 let limit = q.limit.unwrap_or(50).clamp(1, 100);
119 let offset = q
120 .offset
121 .unwrap_or(0)
122 .clamp(0, export::pagination::MAX_OFFSET);
116 let offset = q.offset.unwrap_or(0).clamp(0, api::pagination::MAX_OFFSET);
123117 let out = service
124118 .list_repos_by_topic(&p.name, limit, offset)
125119 .await
Modified lib/service/git/src/handler/watches.rs lib/service/git/src/handler/watches.rs +3 −6 View lib/service/git/src/handler/watches.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Json, Path, Query, State};
3use api::rest::AppResponseData;
44use models::common::watch_mode::WatchMode;
55use serde::Deserialize;
66use utoipa::IntoParams;
@@ -74,10 +74,7 @@
7474 .await?
7575 .0;
7676 let limit = q.limit.unwrap_or(50).clamp(1, 100);
77 let offset = q
78 .offset
79 .unwrap_or(0)
80 .clamp(0, export::pagination::MAX_OFFSET);
77 let offset = q.offset.unwrap_or(0).clamp(0, api::pagination::MAX_OFFSET);
8178 let out = service
8279 .list_watchers(&ctx, q.mode, limit, offset)
8380 .await
Modified lib/service/git/src/handler/whitelists.rs lib/service/git/src/handler/whitelists.rs +3 −3 View lib/service/git/src/handler/whitelists.rs
@@ -1,5 +1,5 @@
1use export::http::{Json, Path, State};
2use export::rest::{AppResponseData, NoData};
1use api::http::{Json, Path, State};
2use api::rest::{AppResponseData, NoData};
33use serde::Deserialize;
44use utoipa::IntoParams;
55use uuid::Uuid;
@@ -170,7 +170,7 @@
170170 description = "移除标签保护策略中的指定用户白名单。",
171171 params(TagWhitelistPath),
172172 responses(
173 (status = 200, description = "remove tag whitelist", body = AppResponseData<export::rest::NoData>)
173 (status = 200, description = "remove tag whitelist", body = AppResponseData<api::rest::NoData>)
174174 )
175175)]
176176pub async fn remove_tag_whitelist(
Modified lib/service/git/src/service/code_comments.rs lib/service/git/src/service/code_comments.rs +2 −2 View lib/service/git/src/service/code_comments.rs
@@ -1,6 +1,6 @@
11use crate::context::facade::GitContext;
2use export::pagination::Page;
3use export::users::UserDto;
2use api::pagination::Page;
3use api::users::UserDto;
44use models::repo::code_comment;
55use sea_orm::ActiveValue::Set;
66use sea_orm::{
Modified lib/service/git/src/service/commits.rs lib/service/git/src/service/commits.rs +1 −1 View lib/service/git/src/service/commits.rs
@@ -127,7 +127,7 @@
127127 pub description: Option<String>,
128128 pub target_url: Option<String>,
129129 pub creator_id: i64,
130 pub creator: Option<export::users::UserDto>,
130 pub creator: Option<api::users::UserDto>,
131131 pub created_at: OffsetDateTime,
132132 pub updated_at: Option<OffsetDateTime>,
133133}
Modified lib/service/git/src/service/git_service.rs lib/service/git/src/service/git_service.rs +2 −2 View lib/service/git/src/service/git_service.rs
@@ -1,6 +1,6 @@
11use std::sync::Arc;
22
3use export::AppDatabase;
3use db::AppDatabase;
44use proto::KenShellClient;
55use sea_orm::DatabaseConnection;
66
@@ -42,7 +42,7 @@
4242 self.database.write()
4343 }
4444
45 pub fn db_read(&self) -> &export::DbConn {
45 pub fn db_read(&self) -> &db::DbConn {
4646 self.database.read()
4747 }
4848}
Modified lib/service/git/src/service/releases.rs lib/service/git/src/service/releases.rs +2 −2 View lib/service/git/src/service/releases.rs
@@ -1,5 +1,5 @@
1use export::pagination::Page;
2use export::users::UserDto;
1use api::pagination::Page;
2use api::users::UserDto;
33use models::repo::repo_release;
44use sea_orm::ActiveValue::Set;
55use sea_orm::{
Modified lib/service/git/src/service/repos.rs lib/service/git/src/service/repos.rs +3 −3 View lib/service/git/src/service/repos.rs
@@ -457,8 +457,8 @@
457457 &self,
458458 space_name: String,
459459 caller: Option<i64>,
460 page: export::pagination::PageQuery,
461 ) -> Result<export::pagination::Page<RepoSummaryDto>, GitError> {
460 page: api::pagination::PageQuery,
461 ) -> Result<api::pagination::Page<RepoSummaryDto>, GitError> {
462462 let space = self.lookup_space(&space_name).await?;
463463 let dirs = dirs::Entity::find()
464464 .filter(dirs::Column::SpaceId.eq(space.id()))
@@ -502,7 +502,7 @@
502502 .skip(offset as usize)
503503 .take(limit as usize)
504504 .collect();
505 Ok(export::pagination::Page {
505 Ok(api::pagination::Page {
506506 items,
507507 total,
508508 limit,
Modified lib/service/git/src/service/stars.rs lib/service/git/src/service/stars.rs +1 −1 View lib/service/git/src/service/stars.rs
@@ -144,7 +144,7 @@
144144 } else {
145145 u.displayname.clone()
146146 },
147 avatar_url: export::resolve_user_avatar_url(u.user_id, &u.avatar_url),
147 avatar_url: api::resolve_user_avatar_url(u.user_id, &u.avatar_url),
148148 starred_at: row.created_at,
149149 })
150150 })
Modified lib/service/git/src/service/watches.rs lib/service/git/src/service/watches.rs +1 −1 View lib/service/git/src/service/watches.rs
@@ -140,7 +140,7 @@
140140 } else {
141141 u.displayname.clone()
142142 },
143 avatar_url: export::resolve_user_avatar_url(u.user_id, &u.avatar_url),
143 avatar_url: api::resolve_user_avatar_url(u.user_id, &u.avatar_url),
144144 mode: row.mode,
145145 watching_since: row.created_at,
146146 })
Modified lib/service/git/src/service/whitelists.rs lib/service/git/src/service/whitelists.rs +4 −4 View lib/service/git/src/service/whitelists.rs
@@ -17,7 +17,7 @@
1717 pub policy_id: Uuid,
1818 pub kind: WhitelistKind,
1919 pub user_id: Option<i64>,
20 pub user: Option<export::users::UserDto>,
20 pub user: Option<api::users::UserDto>,
2121 pub group_id: Option<Uuid>,
2222 pub created_at: OffsetDateTime,
2323}
@@ -47,7 +47,7 @@
4747pub struct TagWhitelistDto {
4848 pub policy_id: Uuid,
4949 pub user_id: i64,
50 pub user: Option<export::users::UserDto>,
50 pub user: Option<api::users::UserDto>,
5151}
5252
5353impl From<repo_tag_protection_whitelists::Model> for TagWhitelistDto {
@@ -83,14 +83,14 @@
8383 pub(crate) async fn user_dto_map(
8484 &self,
8585 uids: &[i64],
86 ) -> Result<std::collections::HashMap<i64, export::users::UserDto>, GitError> {
86 ) -> Result<std::collections::HashMap<i64, api::users::UserDto>, GitError> {
8787 let mut map = std::collections::HashMap::new();
8888 if uids.is_empty() {
8989 return Ok(map);
9090 }
9191 let rows = auth::users::load_public_users(&self.accounts, uids).await?;
9292 for (uid, user) in rows {
93 map.insert(uid, export::users::UserDto::from_public(&user));
93 map.insert(uid, api::users::UserDto::from_public(&user));
9494 }
9595 Ok(map)
9696 }
Modified lib/service/git/src/share/errors.rs lib/service/git/src/share/errors.rs +2 −10 View lib/service/git/src/share/errors.rs
@@ -22,16 +22,8 @@
2222 Internal(String),
2323}
2424
25impl From<export::ExportError> for GitError {
26 fn from(error: export::ExportError) -> Self {
27 match error {
28 export::ExportError::Database(err) => Self::from(err),
29 other => Self::Internal(other.to_string()),
30 }
31 }
32}
33
34export::access_error_conversion!(GitError, InvalidArgument);
25auth::auth_error_conversion!(GitError);
26api::access_error_conversion!(GitError, InvalidArgument);
3527
3628impl From<sea_orm::DbErr> for GitError {
3729 fn from(err: sea_orm::DbErr) -> Self {
Modified lib/service/git/src/share/policy.rs lib/service/git/src/share/policy.rs +2 −2 View lib/service/git/src/share/policy.rs
@@ -34,7 +34,7 @@
3434}
3535
3636pub async fn load_branch_policy(
37 db: &export::AppDatabase,
37 db: &db::AppDatabase,
3838 repo_id: Uuid,
3939) -> Result<BranchPolicy, GitError> {
4040 let rows = repo_branch_protection_policy::Entity::find()
@@ -45,7 +45,7 @@
4545}
4646
4747pub async fn load_tag_policy(
48 db: &export::AppDatabase,
48 db: &db::AppDatabase,
4949 repo_id: Uuid,
5050) -> Result<BranchPolicy, GitError> {
5151 let rows = repo_tag_protection_policy::Entity::find()
Modified lib/service/git/src/errors.rs lib/service/git/src/errors.rs +1 −1 View lib/service/git/src/errors.rs
@@ -1,7 +1,7 @@
11use std::fmt;
22
33use actix_web::http::StatusCode;
4use export::rest::{AppResponseData, NoData};
4use api::rest::{AppResponseData, NoData};
55use utoipa::IntoResponses;
66
77use crate::share::errors::GitError;
Modified lib/service/git/src/openapi.rs lib/service/git/src/openapi.rs +5 −5 View lib/service/git/src/openapi.rs
@@ -110,11 +110,11 @@
110110 handler::whitelists::remove_tag_whitelist,
111111 ),
112112 components(schemas(
113 export::pagination::PageQuery,
114 export::pagination::Page<crate::service::repos::RepoSummaryDto>,
115 export::pagination::Page<crate::service::branches::BranchDto>,
116 export::pagination::Page<crate::service::tags::TagDto>,
117 export::rest::NoData,
113 api::pagination::PageQuery,
114 api::pagination::Page<crate::service::repos::RepoSummaryDto>,
115 api::pagination::Page<crate::service::branches::BranchDto>,
116 api::pagination::Page<crate::service::tags::TagDto>,
117 api::rest::NoData,
118118 crate::service::hooks::HookEventKind,
119119 models::common::watch_mode::WatchMode,
120120 models::git::git_commit_status::CommitStatusState,
Modified lib/service/git/src/routes.rs lib/service/git/src/routes.rs +3 −3 View lib/service/git/src/routes.rs
@@ -101,8 +101,8 @@
101101 remove_branch_whitelist, remove_tag_whitelist,
102102};
103103use crate::service::GitService;
104use export::http::Router;
105use export::http::routing::{delete, get, post, put};
104use api::http::Router;
105use api::http::routing::{delete, get, post, put};
106106
107107pub fn router(_service: GitService) -> Router<GitService> {
108108 Router::new()
@@ -162,7 +162,7 @@
162162 )
163163 .route(
164164 "/{space_name}/{repo_name}/code-comments/{comment_id}",
165 export::http::routing::patch(update_code_comment).delete(delete_code_comment),
165 api::http::routing::patch(update_code_comment).delete(delete_code_comment),
166166 )
167167 .route(
168168 "/{space_name}/{repo_name}/code-comments/{comment_id}/resolve",
Modified lib/service/git/Cargo.toml lib/service/git/Cargo.toml +3 −1 View lib/service/git/Cargo.toml
@@ -4,12 +4,14 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8bootstrap = { workspace = true }
9db = { workspace = true }
710auth = { workspace = true }
811dir = { workspace = true }
912proto = { workspace = true }
1013tonic = { workspace = true }
1114prost-types = { workspace = true }
12export = { workspace = true }
1315cache = { workspace = true }
1416config = { workspace = true }
1517models = { workspace = true }
Modified lib/service/issues/src/services/admission.rs lib/service/issues/src/services/admission.rs +1 −1 View lib/service/issues/src/services/admission.rs
@@ -1,6 +1,6 @@
11use crate::errors::IssueError;
2use cache::AppRedis;
23use config::quota::QuotaConfig;
3use export::AppRedis;
44use std::ops::Deref;
55
66#[derive(Clone)]
Modified lib/service/issues/src/services/audience.rs lib/service/issues/src/services/audience.rs +6 −7 View lib/service/issues/src/services/audience.rs
@@ -1,6 +1,6 @@
11use crate::errors::IssueError;
2use api::users::UserDto;
23use auth::Accounts;
3use export::users::UserDto;
44use models::users::user_notifications::NotificationType;
55use sea_orm::ConnectionTrait;
66use std::collections::HashMap;
@@ -8,14 +8,14 @@
88#[derive(Clone)]
99pub struct Audience {
1010 pub(crate) accounts: Accounts,
11 pub(crate) notifications: export::notify::Notifications,
11 pub(crate) notifications: push::notify::Notifications,
1212 mail: Option<email::MailPublisher>,
1313 pub(crate) default_locale: i18n::UiLocale,
1414}
1515impl Audience {
1616 pub fn new(
1717 accounts: Accounts,
18 notifications: export::notify::Notifications,
18 notifications: push::notify::Notifications,
1919 mail: Option<email::MailPublisher>,
2020 default_locale: i18n::UiLocale,
2121 ) -> Self {
@@ -61,7 +61,7 @@
6161 text: &str,
6262 html: &str,
6363 ) -> Result<(), IssueError> {
64 let request_id = export::middleware::request_id();
64 let request_id = api::middleware::request_id();
6565 email::send_optional(
6666 self.mail.as_ref(),
6767 to,
@@ -77,7 +77,7 @@
7777 pub(crate) async fn notify_user(
7878 &self,
7979 txn: &impl ConnectionTrait,
80 pending: &export::notify::PendingNotifications,
80 pending: &push::notify::PendingNotifications,
8181 recipient: i64,
8282 ntype: NotificationType,
8383 title: String,
@@ -85,8 +85,7 @@
8585 data: Option<serde_json::Value>,
8686 actor_uid: Option<i64>,
8787 ) -> Result<(), IssueError> {
88 let row =
89 export::notify::insert(txn, recipient, ntype, title, body, data, actor_uid).await?;
88 let row = push::notify::insert(txn, recipient, ntype, title, body, data, actor_uid).await?;
9089 pending.push(recipient, row.to_event_value());
9190 Ok(())
9291 }
Modified lib/service/issues/src/services/boards.rs lib/service/issues/src/services/boards.rs +4 −4 View lib/service/issues/src/services/boards.rs
@@ -31,7 +31,7 @@
3131 pub updated_at: Option<OffsetDateTime>,
3232}
3333
34pub type BoardPage = export::pagination::Page<BoardDto>;
34pub type BoardPage = api::pagination::Page<BoardDto>;
3535
3636#[derive(Debug, Clone, Deserialize, ToSchema)]
3737pub struct CreateBoardCmd {
@@ -50,11 +50,11 @@
5050pub struct UpdateBoardCmd {
5151 #[serde(default)]
5252 pub name: Option<String>,
53 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
53 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
5454 pub prefix: Option<Option<String>>,
55 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
55 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
5656 pub icon: Option<Option<String>>,
57 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
57 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
5858 pub description: Option<Option<String>>,
5959}
6060
Modified lib/service/issues/src/services/comments.rs lib/service/issues/src/services/comments.rs +3 −3 View lib/service/issues/src/services/comments.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::issue_event_line::IssueEventType;
33use models::issue::issue_member::{self, IssueMemberKind};
44use models::issue::{comment, issue_content_history};
@@ -29,7 +29,7 @@
2929 pub updated_at: Option<OffsetDateTime>,
3030}
3131
32pub type CommentPage = export::pagination::Page<CommentDto>;
32pub type CommentPage = api::pagination::Page<CommentDto>;
3333
3434#[derive(Debug, Clone, Serialize, ToSchema)]
3535pub struct CommentTreeNode {
@@ -114,7 +114,7 @@
114114 let space_lower_for_txn = space.slug().to_owned();
115115 let item_title_for_txn = item.title.clone();
116116 let mentioned_for_txn = mentioned_uids.clone();
117 let pending = export::notify::PendingNotifications::default();
117 let pending = push::notify::PendingNotifications::default();
118118 let pending_txn = pending.clone();
119119
120120 let inserted =
Modified lib/service/issues/src/services/content_history.rs lib/service/issues/src/services/content_history.rs +2 −2 View lib/service/issues/src/services/content_history.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::issue_content_history;
33use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect};
44use serde::{Deserialize, Serialize};
@@ -22,7 +22,7 @@
2222 pub created_at: OffsetDateTime,
2323}
2424
25pub type ContentHistoryPage = export::pagination::Page<ContentHistoryDto>;
25pub type ContentHistoryPage = api::pagination::Page<ContentHistoryDto>;
2626
2727#[derive(Debug, Clone, Deserialize, IntoParams, ToSchema)]
2828pub struct ListContentHistoryQuery {
Modified lib/service/issues/src/services/events.rs lib/service/issues/src/services/events.rs +2 −2 View lib/service/issues/src/services/events.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::issue_event_line::{self, IssueEventType};
33use sea_orm::{ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect};
44use serde::{Deserialize, Serialize};
@@ -26,7 +26,7 @@
2626 pub created_at: OffsetDateTime,
2727}
2828
29pub type EventPage = export::pagination::Page<EventDto>;
29pub type EventPage = api::pagination::Page<EventDto>;
3030
3131#[derive(Debug, Clone, Deserialize, IntoParams, ToSchema)]
3232pub struct ListEventQuery {
Modified lib/service/issues/src/services/issue_users.rs lib/service/issues/src/services/issue_users.rs +2 −2 View lib/service/issues/src/services/issue_users.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::issue_user;
33use sea_orm::{
44 ActiveModelTrait, ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder,
@@ -23,7 +23,7 @@
2323 pub created_at: OffsetDateTime,
2424}
2525
26pub type IssueUserPage = export::pagination::Page<IssueUserDto>;
26pub type IssueUserPage = api::pagination::Page<IssueUserDto>;
2727
2828#[derive(Debug, Clone, Deserialize, ToSchema)]
2929pub struct UpdateIssueUserCmd {
Modified lib/service/issues/src/services/issues.rs lib/service/issues/src/services/issues.rs +7 −7 View lib/service/issues/src/services/issues.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::issue_event_line::IssueEventType;
33use models::issue::issue_item::IssuePriority;
44use models::issue::{
@@ -70,7 +70,7 @@
7070 pub closed_at: Option<OffsetDateTime>,
7171}
7272
73pub type IssuePage = export::pagination::Page<IssueListItemDto>;
73pub type IssuePage = api::pagination::Page<IssueListItemDto>;
7474
7575#[derive(Debug, Clone, Deserialize, ToSchema)]
7676pub struct CreateIssueCmd {
@@ -85,7 +85,7 @@
8585 pub priority: IssuePriority,
8686 #[serde(
8787 default,
88 deserialize_with = "export::serde_datetime::deserialize_opt_datetime"
88 deserialize_with = "api::serde_datetime::deserialize_opt_datetime"
8989 )]
9090 pub due_at: Option<OffsetDateTime>,
9191 #[serde(default)]
@@ -101,17 +101,17 @@
101101pub struct UpdateIssueCmd {
102102 #[serde(default)]
103103 pub title: Option<String>,
104 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
104 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
105105 pub description: Option<Option<String>>,
106106 #[serde(default)]
107107 pub content: Option<String>,
108 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
108 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
109109 pub milestone_id: Option<Option<Uuid>>,
110110 #[serde(default)]
111111 pub priority: Option<IssuePriority>,
112112 #[serde(
113113 default,
114 deserialize_with = "export::serde_datetime::deserialize_opt_opt_datetime"
114 deserialize_with = "api::serde_datetime::deserialize_opt_opt_datetime"
115115 )]
116116 pub due_at: Option<Option<OffsetDateTime>>,
117117 #[serde(default)]
@@ -497,7 +497,7 @@
497497 let space_lower_for_txn = space.slug().to_owned();
498498 let mentioned_for_txn = mentioned_uids.clone();
499499 let this = self.clone();
500 let pending = export::notify::PendingNotifications::default();
500 let pending = push::notify::PendingNotifications::default();
501501 let pending_txn = pending.clone();
502502
503503 let inserted = self
Modified lib/service/issues/src/services/labels.rs lib/service/issues/src/services/labels.rs +2 −2 View lib/service/issues/src/services/labels.rs
@@ -47,7 +47,7 @@
4747 }
4848}
4949
50pub type LabelPage = export::pagination::Page<LabelDto>;
50pub type LabelPage = api::pagination::Page<LabelDto>;
5151
5252#[derive(Debug, Clone, Deserialize, ToSchema)]
5353pub struct CreateLabelCmd {
@@ -71,7 +71,7 @@
7171 pub exclusive: Option<bool>,
7272 #[serde(default)]
7373 pub exclusive_order: Option<i32>,
74 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
74 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
7575 pub description: Option<Option<String>>,
7676 #[serde(default)]
7777 pub is_archived: Option<bool>,
Modified lib/service/issues/src/services/members.rs lib/service/issues/src/services/members.rs +3 −3 View lib/service/issues/src/services/members.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::issue_event_line::IssueEventType;
33use models::issue::issue_member::{self, IssueMemberKind};
44use models::users::user_notifications::NotificationType;
@@ -27,7 +27,7 @@
2727 pub updated_at: Option<OffsetDateTime>,
2828}
2929
30pub type IssueMemberPage = export::pagination::Page<IssueMemberDto>;
30pub type IssueMemberPage = api::pagination::Page<IssueMemberDto>;
3131
3232#[derive(Debug, Clone, Deserialize, ToSchema)]
3333pub struct CreateIssueMemberCmd {
@@ -96,7 +96,7 @@
9696 let this = self.clone();
9797 let item_title_for_txn = item.title.clone();
9898 let space_lower_for_txn = space.slug().to_owned();
99 let pending = export::notify::PendingNotifications::default();
99 let pending = push::notify::PendingNotifications::default();
100100 let pending_txn = pending.clone();
101101
102102 let inserted =
Modified lib/service/issues/src/services/milestones.rs lib/service/issues/src/services/milestones.rs +4 −4 View lib/service/issues/src/services/milestones.rs
@@ -30,7 +30,7 @@
3030 pub updated_at: Option<OffsetDateTime>,
3131}
3232
33pub type MilestonePage = export::pagination::Page<MilestoneDto>;
33pub type MilestonePage = api::pagination::Page<MilestoneDto>;
3434
3535#[derive(Debug, Clone, Deserialize, ToSchema)]
3636pub struct CreateMilestoneCmd {
@@ -39,7 +39,7 @@
3939 pub description: Option<String>,
4040 #[serde(
4141 default,
42 deserialize_with = "export::serde_datetime::deserialize_opt_datetime"
42 deserialize_with = "api::serde_datetime::deserialize_opt_datetime"
4343 )]
4444 pub due_at: Option<OffsetDateTime>,
4545}
@@ -48,11 +48,11 @@
4848pub struct UpdateMilestoneCmd {
4949 #[serde(default)]
5050 pub name: Option<String>,
51 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
51 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
5252 pub description: Option<Option<String>>,
5353 #[serde(
5454 default,
55 deserialize_with = "export::serde_datetime::deserialize_opt_opt_datetime"
55 deserialize_with = "api::serde_datetime::deserialize_opt_opt_datetime"
5656 )]
5757 pub due_at: Option<Option<OffsetDateTime>>,
5858 #[serde(default)]
Modified lib/service/issues/src/services/reactions.rs lib/service/issues/src/services/reactions.rs +1 −1 View lib/service/issues/src/services/reactions.rs
@@ -1,6 +1,6 @@
11use std::collections::HashMap;
22
3use export::users::UserDto;
3use api::users::UserDto;
44use models::issue::{comment, issue_reactions};
55use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
66use serde::{Deserialize, Serialize};
Modified lib/service/issues/src/services/service.rs lib/service/issues/src/services/service.rs +2 −2 View lib/service/issues/src/services/service.rs
@@ -2,7 +2,7 @@
22use std::sync::Arc;
33
44use config::AppConfig;
5use export::database::AppDatabase;
5use db::AppDatabase;
66use models::issue::issue_event_line::{self, IssueEventType};
77use models::issue::issue_item;
88use sea_orm::{ActiveModelTrait, ConnectionTrait, EntityTrait, Set};
@@ -50,7 +50,7 @@
5050 }
5151
5252 pub fn paginate(&self, limit: Option<u64>, offset: Option<u64>) -> (u64, u64) {
53 export::pagination::page_bounds(
53 api::pagination::page_bounds(
5454 limit,
5555 offset,
5656 self.settings.issues.default_pagination,
Modified lib/service/issues/src/services/stopwatch.rs lib/service/issues/src/services/stopwatch.rs +1 −1 View lib/service/issues/src/services/stopwatch.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::{stopwatch, tracked_time};
33use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set, TransactionTrait};
44use serde::{Deserialize, Serialize};
Modified lib/service/issues/src/services/tracked_time.rs lib/service/issues/src/services/tracked_time.rs +2 −2 View lib/service/issues/src/services/tracked_time.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::issue::tracked_time;
33use sea_orm::{
44 ActiveModelTrait, ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder,
@@ -22,7 +22,7 @@
2222 pub created_at: OffsetDateTime,
2323}
2424
25pub type TrackedTimePage = export::pagination::Page<TrackedTimeDto>;
25pub type TrackedTimePage = api::pagination::Page<TrackedTimeDto>;
2626
2727#[derive(Debug, Clone, Deserialize, IntoParams, ToSchema)]
2828pub struct ListTrackedTimeQuery {
Modified lib/service/issues/src/services/watches.rs lib/service/issues/src/services/watches.rs +1 −1 View lib/service/issues/src/services/watches.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::common::watch_mode::WatchMode;
33use models::issue::issue_watch;
44use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
Modified lib/service/issues/src/errors.rs lib/service/issues/src/errors.rs +5 −5 View lib/service/issues/src/errors.rs
@@ -27,7 +27,8 @@
2727
2828impl std::error::Error for IssueError {}
2929
30export::db_error_conversions!(IssueError);
30auth::auth_error_conversion!(IssueError);
31api::db_error_conversions!(IssueError);
3132
3233impl From<dir::Error> for IssueError {
3334 fn from(error: dir::Error) -> Self {
@@ -39,11 +40,10 @@
3940 }
4041}
4142
42export::export_error_conversion!(IssueError);
43export::json_payload_conversion!(IssueError);
44export::access_error_conversion!(IssueError, BadRequest);
43api::json_payload_conversion!(IssueError);
44api::access_error_conversion!(IssueError, BadRequest);
4545
46export::api_error! {
46api::api_error! {
4747 log: "issues",
4848 pub enum ApiError {
4949 BadRequest(400, "request failed validation"),
Modified lib/service/issues/src/openapi.rs lib/service/issues/src/openapi.rs +5 −5 View lib/service/issues/src/openapi.rs
@@ -1,4 +1,4 @@
1use export::rest::AppResponseData;
1use api::rest::AppResponseData;
22use utoipa::OpenApi;
33
44#[derive(OpenApi)]
@@ -75,7 +75,7 @@
7575 crate::handlers::repo_relations::delete_repo_relation::delete_repo_relation,
7676 ),
7777 components(schemas(
78 AppResponseData<export::rest::NoData>,
78 AppResponseData<api::rest::NoData>,
7979 AppResponseData<crate::services::boards::BoardDto>,
8080 AppResponseData<crate::services::boards::BoardPage>,
8181 AppResponseData<crate::services::issues::IssueDto>,
@@ -105,8 +105,8 @@
105105 AppResponseData<crate::services::issue_users::IssueUserPage>,
106106 AppResponseData<crate::services::repo_relations::RepoRelDto>,
107107 AppResponseData<Vec<crate::services::repo_relations::RepoRelDto>>,
108 export::rest::NoData,
109 export::users::UserDto,
108 api::rest::NoData,
109 api::users::UserDto,
110110 space::services::dto::SpacePath,
111111 crate::services::boards::BoardDto,
112112 crate::services::boards::BoardPage,
@@ -116,7 +116,7 @@
116116 crate::services::boards::BoardPath,
117117 crate::services::issues::IssueDto,
118118 crate::services::issues::IssueListItemDto,
119 export::pagination::Page<crate::services::issues::IssueListItemDto>,
119 api::pagination::Page<crate::services::issues::IssueListItemDto>,
120120 crate::services::issues::IssueState,
121121 crate::services::issues::CreateIssueCmd,
122122 crate::services::issues::UpdateIssueCmd,
Modified lib/service/issues/src/routes.rs lib/service/issues/src/routes.rs +6 −6 View lib/service/issues/src/routes.rs
@@ -1,5 +1,5 @@
1use export::http::Router;
2use export::http::routing::{delete, get, post, put};
1use api::http::Router;
2use api::http::routing::{delete, get, post, put};
33
44use crate::handlers::attachments::create_attachment::create_issue_attachment;
55use crate::handlers::attachments::delete_attachment::delete_issue_attachment;
@@ -158,7 +158,7 @@
158158 )
159159 .route(
160160 "/issues/{space_name}/boards/{board_id}/issues/{issue_id}/reactions/@me",
161 export::http::routing::put(add_issue_reaction).delete(remove_issue_reaction),
161 api::http::routing::put(add_issue_reaction).delete(remove_issue_reaction),
162162 )
163163 .route(
164164 "/issues/{space_name}/boards/{board_id}/issues/{issue_id}/comments/{comment_id}/reactions",
@@ -166,7 +166,7 @@
166166 )
167167 .route(
168168 "/issues/{space_name}/boards/{board_id}/issues/{issue_id}/comments/{comment_id}/reactions/@me",
169 export::http::routing::put(add_comment_reaction).delete(remove_comment_reaction),
169 api::http::routing::put(add_comment_reaction).delete(remove_comment_reaction),
170170 )
171171 .route(
172172 "/issues/{space_name}/boards/{board_id}/issues/{issue_id}/watch",
@@ -227,7 +227,7 @@
227227 )
228228 .route(
229229 "/issues/{space_name}/boards/{board_id}/issues/{issue_id}/times/{time_id}",
230 export::http::routing::patch(
230 api::http::routing::patch(
231231 crate::handlers::tracked_time::update_tracked_time::update_tracked_time,
232232 )
233233 .delete(crate::handlers::tracked_time::delete_tracked_time::delete_tracked_time),
@@ -248,5 +248,5 @@
248248 "/issues/{space_name}/boards/{board_id}/issues/{issue_id}/repos/{rel_id}",
249249 delete(delete_repo_relation),
250250 )
251 .wrap(export::http::Guard::Session)
251 .wrap(api::http::Guard::Session)
252252}
Modified lib/service/issues/Cargo.toml lib/service/issues/Cargo.toml +4 −1 View lib/service/issues/Cargo.toml
@@ -4,6 +4,10 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8cache = { workspace = true }
9db = { workspace = true }
10push = { workspace = true }
711storage = { workspace = true }
812dir = { workspace = true }
913auth = { workspace = true }
@@ -12,7 +16,6 @@
1216futures = { workspace = true }
1317async-trait = { workspace = true }
1418config = { workspace = true }
15export = { workspace = true }
1619events = { workspace = true }
1720i18n = { workspace = true }
1821models = { workspace = true }
Modified lib/service/pulls/src/handlers/inbox.rs lib/service/pulls/src/handlers/inbox.rs +2 −2 View lib/service/pulls/src/handlers/inbox.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::AppResponseData;
2use api::http::{Path, Query, State};
3use api::rest::AppResponseData;
44
55use crate::errors::ApiError;
66use crate::services::inbox::{InboxPage, InboxQuery};
Modified lib/service/pulls/src/services/actors.rs lib/service/pulls/src/services/actors.rs +2 −2 View lib/service/pulls/src/services/actors.rs
@@ -1,8 +1,8 @@
11use crate::errors::PullError;
2use api::users::UserDto;
23use auth::Accounts;
4use cache::AppRedis;
35use config::quota::QuotaConfig;
4use export::AppRedis;
5use export::users::UserDto;
66use std::collections::HashMap;
77
88#[derive(Clone)]
Modified lib/service/pulls/src/services/assignees.rs lib/service/pulls/src/services/assignees.rs +1 −1 View lib/service/pulls/src/services/assignees.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::pull_request::{pull_request_assignee, pull_requests};
33use sea_orm::ActiveValue::Set;
44use sea_orm::{
Modified lib/service/pulls/src/services/comments.rs lib/service/pulls/src/services/comments.rs +2 −2 View lib/service/pulls/src/services/comments.rs
@@ -1,5 +1,5 @@
1use export::pagination::{Page, PageQuery};
2use export::users::UserDto;
1use api::pagination::{Page, PageQuery};
2use api::users::UserDto;
33use git::facade::GitContext;
44use models::pull_request::{pull_request_comment, pull_requests};
55use sea_orm::ActiveValue::Set;
Modified lib/service/pulls/src/services/events.rs lib/service/pulls/src/services/events.rs +2 −2 View lib/service/pulls/src/services/events.rs
@@ -1,5 +1,5 @@
1use export::pagination::{Page, PageQuery};
2use export::users::UserDto;
1use api::pagination::{Page, PageQuery};
2use api::users::UserDto;
33use models::pull_request::{pull_request_event_line, pull_requests};
44use sea_orm::ActiveValue::Set;
55use sea_orm::{
Modified lib/service/pulls/src/services/inbox.rs lib/service/pulls/src/services/inbox.rs +1 −1 View lib/service/pulls/src/services/inbox.rs
@@ -1,4 +1,4 @@
1use export::pagination::Page;
1use api::pagination::Page;
22use models::pull_request::{pull_request_review, pull_request_reviewer, pull_requests};
33use sea_orm::{
44 ColumnTrait, EntityTrait, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect, Select,
Modified lib/service/pulls/src/services/pulls.rs lib/service/pulls/src/services/pulls.rs +5 −5 View lib/service/pulls/src/services/pulls.rs
@@ -1,5 +1,5 @@
1use export::pagination::Page;
2use export::users::UserDto;
1use api::pagination::Page;
2use api::users::UserDto;
33use git::facade::GitContext;
44use models::issue::issue_relation_pull;
55use models::pull_request::{
@@ -127,15 +127,15 @@
127127pub struct UpdatePullCmd {
128128 #[serde(default)]
129129 pub title: Option<String>,
130 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
130 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
131131 pub body: Option<Option<String>>,
132132 #[serde(default)]
133133 pub base_branch: Option<String>,
134134 #[serde(default)]
135135 pub draft: Option<bool>,
136 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
136 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
137137 pub auto_merge: Option<Option<bool>>,
138 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
138 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
139139 pub issue_id: Option<Option<Uuid>>,
140140}
141141
Modified lib/service/pulls/src/services/reviewers.rs lib/service/pulls/src/services/reviewers.rs +1 −1 View lib/service/pulls/src/services/reviewers.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use models::pull_request::{pull_request_review, pull_request_reviewer, pull_requests};
33use sea_orm::ActiveValue::Set;
44use sea_orm::{
Modified lib/service/pulls/src/services/reviews.rs lib/service/pulls/src/services/reviews.rs +1 −1 View lib/service/pulls/src/services/reviews.rs
@@ -1,4 +1,4 @@
1use export::users::UserDto;
1use api::users::UserDto;
22use git::facade::GitContext;
33use models::pull_request::{pull_request_comment, pull_request_review, pull_requests};
44use sea_orm::ActiveValue::Set;
Modified lib/service/pulls/src/services/service.rs lib/service/pulls/src/services/service.rs +2 −2 View lib/service/pulls/src/services/service.rs
@@ -1,5 +1,5 @@
11use ::session::Session;
2use export::AppDatabase;
2use db::AppDatabase;
33use git::facade::GitService;
44use models::pull_request::pull_requests;
55use sea_orm::{ColumnTrait, DatabaseConnection, EntityTrait, PaginatorTrait, QueryFilter};
@@ -31,7 +31,7 @@
3131 }
3232 }
3333
34 pub fn db_read(&self) -> &export::DbConn {
34 pub fn db_read(&self) -> &db::DbConn {
3535 self.database.read()
3636 }
3737
Modified lib/service/pulls/src/errors.rs lib/service/pulls/src/errors.rs +5 −5 View lib/service/pulls/src/errors.rs
@@ -27,10 +27,10 @@
2727
2828impl std::error::Error for PullError {}
2929
30export::db_error_conversions!(PullError);
31export::export_error_conversion!(PullError);
32export::json_payload_conversion!(PullError);
33export::domain_error_passthrough!(PullError from issues::errors::IssueError);
30auth::auth_error_conversion!(PullError);
31api::db_error_conversions!(PullError);
32api::json_payload_conversion!(PullError);
33api::domain_error_passthrough!(PullError from issues::errors::IssueError);
3434
3535impl From<git::facade::GitError> for PullError {
3636 fn from(error: git::facade::GitError) -> Self {
@@ -48,7 +48,7 @@
4848 }
4949}
5050
51export::api_error! {
51api::api_error! {
5252 log: "pulls",
5353 pub enum ApiError {
5454 BadRequest(400, "request failed validation"),
Modified lib/service/pulls/src/openapi.rs lib/service/pulls/src/openapi.rs +5 −5 View lib/service/pulls/src/openapi.rs
@@ -1,6 +1,6 @@
11use utoipa::OpenApi;
22
3use export::rest::{AppResponseData, NoData};
3use api::rest::{AppResponseData, NoData};
44
55#[derive(OpenApi)]
66#[openapi(
@@ -74,7 +74,7 @@
7474 AppResponseData<crate::services::checks::PullGateDto>,
7575 AppResponseData<crate::services::inbox::InboxPage>,
7676 NoData,
77 export::users::UserDto,
77 api::users::UserDto,
7878 issues::services::labels::LabelDto,
7979 crate::services::pulls::PullDto,
8080 crate::services::pulls::PullRefDto,
@@ -103,9 +103,9 @@
103103 crate::services::checks::PullGateDto,
104104 crate::services::approvals::MergeGateDto,
105105 crate::handlers::pulls::update_branch_pull::UpdateBranchDto,
106 export::pagination::Page<crate::services::pulls::PullDto>,
107 export::pagination::Page<crate::services::events::PullEventDto>,
108 export::pagination::Page<crate::services::comments::PullCommentDto>,
106 api::pagination::Page<crate::services::pulls::PullDto>,
107 api::pagination::Page<crate::services::events::PullEventDto>,
108 api::pagination::Page<crate::services::comments::PullCommentDto>,
109109 git::facade::MergeCommitDto,
110110 git::facade::MergeResultDto,
111111 models::pull_request::pull_requests::MergeMethod,
Modified lib/service/pulls/src/routes.rs lib/service/pulls/src/routes.rs +6 −6 View lib/service/pulls/src/routes.rs
@@ -1,5 +1,5 @@
1use export::http::Router;
2use export::http::routing::{get, post, put};
1use api::http::Router;
2use api::http::routing::{get, post, put};
33
44use crate::handlers::assignees::add_pull_assignee::add_pull_assignee;
55use crate::handlers::assignees::list_pull_assignees::list_pull_assignees;
@@ -90,7 +90,7 @@
9090 )
9191 .route(
9292 &format!("{ITEM}/comments/{{comment_id}}"),
93 export::http::routing::patch(update_pull_comment).delete(delete_pull_comment),
93 api::http::routing::patch(update_pull_comment).delete(delete_pull_comment),
9494 )
9595 .route(
9696 &format!("{ITEM}/comments/{{comment_id}}/resolve"),
@@ -102,7 +102,7 @@
102102 )
103103 .route(
104104 &format!("{ITEM}/requested-reviewers/{{user_id}}"),
105 export::http::routing::delete(delete_requested_reviewer),
105 api::http::routing::delete(delete_requested_reviewer),
106106 )
107107 .route(
108108 &format!("{ITEM}/labels"),
@@ -110,7 +110,7 @@
110110 )
111111 .route(
112112 &format!("{ITEM}/labels/{{label_ref}}"),
113 export::http::routing::delete(detach_pull_label),
113 api::http::routing::delete(detach_pull_label),
114114 )
115115 .route(&format!("{ITEM}/assignees"), get(list_pull_assignees))
116116 .route(
@@ -121,6 +121,6 @@
121121 .route(ISSUE_PULLS, get(list_issue_pulls).post(link_issue_pull))
122122 .route(
123123 &format!("{ISSUE_PULLS}/{{relation_id}}"),
124 export::http::routing::delete(unlink_issue_pull),
124 api::http::routing::delete(unlink_issue_pull),
125125 )
126126}
Modified lib/service/pulls/Cargo.toml lib/service/pulls/Cargo.toml +3 −1 View lib/service/pulls/Cargo.toml
@@ -4,9 +4,11 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8cache = { workspace = true }
9db = { workspace = true }
710auth = { workspace = true }
811config = { workspace = true }
9export = { workspace = true }
1012events = { workspace = true }
1113git = { workspace = true }
1214issues = { workspace = true }
Modified lib/service/push/src/lib.rs lib/service/push/src/lib.rs +4 −3 View lib/service/push/src/lib.rs
@@ -1,12 +1,13 @@
11//! Web Push(RFC8030 + RFC8292)服务端实现。
22//!
33//! 分工:本 crate 负责"投递"(签名、加密、HTTP、重试分级),入队点分散在
4//! 各业务 crate,统一入口是 [`export::push::enqueue`];`export::notify` 在
5//! 发布站内通知事件时会自动入队,因此新写的通知天然带上推送,不需要各处
6//! 记得补一行。
4//! 各业务 crate,统一入口是 [`protocol::enqueue`];[`notify`] 在发布站内
5//! 通知事件时会自动入队,因此新写的通知天然带上推送,不需要各处记得补一行。
76
87pub mod client;
98pub mod error;
9pub mod notify;
10pub mod protocol;
1011pub mod worker;
1112
1213pub use client::{DeliveryOutcome, NotificationPayload, SubscriptionKeys, VapidKeys};
Modified lib/service/push/src/worker.rs lib/service/push/src/worker.rs +21 −15 View lib/service/push/src/worker.rs
@@ -8,8 +8,8 @@
88use std::sync::{Arc, Mutex};
99use std::time::Duration;
1010
11use export::AppState;
12use export::push::{PushJob, online_key};
11use crate::protocol::{PushJob, online_key};
12use bootstrap::AppState;
1313use models::users::user_preferences;
1414use models::users::user_push_subscriptions::{self, PushSubscriptionPlatform};
1515use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
@@ -55,7 +55,7 @@
5555 }
5656
5757 pub async fn run(self) {
58 let topic = export::push::QUEUE_TOPIC.to_string();
58 let topic = crate::protocol::QUEUE_TOPIC.to_string();
5959 loop {
6060 let payload = tokio::select! {
6161 _ = self.cancel.cancelled() => break,
@@ -76,7 +76,7 @@
7676 Ok(job) => job,
7777 Err(error) => {
7878 tracing::warn!(%error, "dropping malformed push job");
79 export::push::enqueue_dlq(&self.state.redis, &payload).await;
79 crate::protocol::enqueue_dlq(&self.state.redis, &payload).await;
8080 continue;
8181 }
8282 };
@@ -91,7 +91,7 @@
9191 span.record("request_id", request_id);
9292 }
9393 oltp::propagation::set_parent_from_traceparent(&span, job.trace.as_deref());
94 if let Err(error) = export::middleware::with_request_id(
94 if let Err(error) = api::middleware::with_request_id(
9595 job.request_id.as_deref(),
9696 self.handle(&job).instrument(span),
9797 )
@@ -215,7 +215,7 @@
215215 /// "用户在线"= 任意标签页持有聊天 WS 连接(集合里还有未过期的连接成员);
216216 /// 此时站内 toast 已经送达,再弹系统通知就是重复提醒。
217217 async fn skip_online(&self, uid: i64) -> bool {
218 export::redis::zset_live_count(&self.state.redis, &online_key(uid))
218 cache::client::zset_live_count(&self.state.redis, &online_key(uid))
219219 .await
220220 .unwrap_or(0)
221221 > 0
@@ -225,11 +225,15 @@
225225 async fn build_payload(&self, job: &PushJob) -> Result<NotificationPayload, PushError> {
226226 let (title, icon) = match job.actor_id {
227227 Some(actor_id) => {
228 let actor = auth::users::get_public_user(&auth::Accounts::new(self.state.database.connection().clone(), self.state.cache.clone()), actor_id)
229 .await
230 .map_err(|error| {
231 PushError::Internal(format!("actor lookup failed: {error}"))
232 })?;
228 let actor = auth::users::get_public_user(
229 &auth::Accounts::new(
230 self.state.database.connection().clone(),
231 self.state.cache.clone(),
232 ),
233 actor_id,
234 )
235 .await
236 .map_err(|error| PushError::Internal(format!("actor lookup failed: {error}")))?;
233237 match actor {
234238 Some(actor) => {
235239 let name = if actor.displayname.trim().is_empty() {
@@ -346,18 +350,20 @@
346350 _ = cancel.cancelled() => return,
347351 _ = tokio::time::sleep(Duration::from_secs(backoff)) => {}
348352 }
349 if let Err(error) = redis.lpush_bytes(export::push::QUEUE_TOPIC, &payload).await {
353 if let Err(error) = redis
354 .lpush_bytes(crate::protocol::QUEUE_TOPIC, &payload)
355 .await
356 {
350357 tracing::warn!(%error, %user_id, "push requeue failed");
351358 }
352359 };
353 export::middleware::with_request_id(request_id.as_deref(), requeue.instrument(span))
354 .await;
360 api::middleware::with_request_id(request_id.as_deref(), requeue.instrument(span)).await;
355361 });
356362 }
357363
358364 async fn to_dlq(&self, job: &PushJob) {
359365 if let Ok(payload) = job.encode() {
360 export::push::enqueue_dlq(&self.state.redis, &payload).await;
366 crate::protocol::enqueue_dlq(&self.state.redis, &payload).await;
361367 }
362368 }
363369
Modified lib/service/push/Cargo.toml lib/service/push/Cargo.toml +7 −1 View lib/service/push/Cargo.toml
@@ -4,11 +4,16 @@
44edition.workspace = true
55
66[dependencies]
7bootstrap = { workspace = true }
78auth = { workspace = true }
89config = { workspace = true }
9export = { workspace = true }
10api = { workspace = true }
11cache = { workspace = true }
12db = { workspace = true }
13events = { workspace = true }
1014models = { workspace = true }
1115oltp = { workspace = true }
16queue = { workspace = true }
1217base64 = { workspace = true }
1318serde = { workspace = true, features = ["derive"] }
1419serde_json = { workspace = true }
@@ -18,6 +23,7 @@
1823reqwest = { workspace = true }
1924tokio = { workspace = true, features = ["time", "sync", "rt"] }
2025tokio-util = { workspace = true }
26time = { workspace = true }
2127# `web-push-native` 只提供无 io 的"生成密文请求"能力,HTTP 用本仓既有的
2228# reqwest(rustls);两者都必须落在 http 1.x 上,否则 `http::Uri` 不是同一个类型。
2329http = "1"
Modified lib/service/space/src/handlers/assign_group.rs lib/service/space/src/handlers/assign_group.rs +2 −2 View lib/service/space/src/handlers/assign_group.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dto::MemberPath;
Modified lib/service/space/src/handlers/create_dir_node.rs lib/service/space/src/handlers/create_dir_node.rs +2 −2 View lib/service/space/src/handlers/create_dir_node.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dir::{CreateDirCmd, DirNodeDto};
Modified lib/service/space/src/handlers/create_group.rs lib/service/space/src/handlers/create_group.rs +2 −2 View lib/service/space/src/handlers/create_group.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dto::SpacePath;
Modified lib/service/space/src/handlers/create_join_rule.rs lib/service/space/src/handlers/create_join_rule.rs +2 −2 View lib/service/space/src/handlers/create_join_rule.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dto::SpacePath;
Modified lib/service/space/src/handlers/delete_group.rs lib/service/space/src/handlers/delete_group.rs +2 −2 View lib/service/space/src/handlers/delete_group.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::handlers::get_group::GroupPath;
Modified lib/service/space/src/handlers/delete_join_rule.rs lib/service/space/src/handlers/delete_join_rule.rs +2 −2 View lib/service/space/src/handlers/delete_join_rule.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::join_rules::JoinRulePath;
Modified lib/service/space/src/handlers/delete_space_image.rs lib/service/space/src/handlers/delete_space_image.rs +2 −2 View lib/service/space/src/handlers/delete_space_image.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::images::SpaceImageKindPath;
Modified lib/service/space/src/handlers/explore_spaces.rs lib/service/space/src/handlers/explore_spaces.rs +2 −2 View lib/service/space/src/handlers/explore_spaces.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dto::SpacePath;
Modified lib/service/space/src/handlers/get_group.rs lib/service/space/src/handlers/get_group.rs +2 −2 View lib/service/space/src/handlers/get_group.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44use serde::Deserialize;
55use utoipa::{IntoParams, ToSchema};
66use uuid::Uuid;
Modified lib/service/space/src/handlers/get_space_dir_tree.rs lib/service/space/src/handlers/get_space_dir_tree.rs +2 −2 View lib/service/space/src/handlers/get_space_dir_tree.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, Query, State};
3use api::rest::{AppResponseData, NoData};
44use serde::Deserialize;
55
66use crate::errors::ApiError;
Modified lib/service/space/src/handlers/get_space_image.rs lib/service/space/src/handlers/get_space_image.rs +2 −2 View lib/service/space/src/handlers/get_space_image.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::images::{SpaceImageDto, SpaceImageKindPath};
Modified lib/service/space/src/handlers/get_space_image_file.rs lib/service/space/src/handlers/get_space_image_file.rs +3 −3 View lib/service/space/src/handlers/get_space_image_file.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
22use actix_web::http::header;
3use export::http::{Path, Query, Response, State};
3use api::http::{Path, Query, Response, State};
44use imaging::layout::ImageVariant;
55use serde::Deserialize;
66use utoipa::{IntoParams, ToSchema};
@@ -25,8 +25,8 @@
2525 params(SpaceImageKindPath, SpaceImageVariantQuery),
2626 responses(
2727 (status = 302, description = "redirect to presigned s3 space image url"),
28 (status = 404, description = "space or image not found", body = export::rest::AppResponseData<export::rest::NoData>),
29 (status = 401, description = "authentication required", body = export::rest::AppResponseData<export::rest::NoData>)
28 (status = 404, description = "space or image not found", body = api::rest::AppResponseData<api::rest::NoData>),
29 (status = 401, description = "authentication required", body = api::rest::AppResponseData<api::rest::NoData>)
3030 )
3131)]
3232pub async fn get_space_image_file(
Modified lib/service/space/src/handlers/join_group_self.rs lib/service/space/src/handlers/join_group_self.rs +2 −2 View lib/service/space/src/handlers/join_group_self.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::handlers::get_group::GroupPath;
Modified lib/service/space/src/handlers/join_requests.rs lib/service/space/src/handlers/join_requests.rs +2 −2 View lib/service/space/src/handlers/join_requests.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dto::SpacePath;
Modified lib/service/space/src/handlers/leave_group_self.rs lib/service/space/src/handlers/leave_group_self.rs +2 −2 View lib/service/space/src/handlers/leave_group_self.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::handlers::get_group::GroupPath;
Modified lib/service/space/src/handlers/list_dir_group_overwrites.rs lib/service/space/src/handlers/list_dir_group_overwrites.rs +2 −2 View lib/service/space/src/handlers/list_dir_group_overwrites.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dir::{DirPath, GroupOverwriteDto};
Modified lib/service/space/src/handlers/list_dir_user_overwrites.rs lib/service/space/src/handlers/list_dir_user_overwrites.rs +2 −2 View lib/service/space/src/handlers/list_dir_user_overwrites.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dir::{DirPath, UserOverwriteDto};
Modified lib/service/space/src/handlers/list_groups.rs lib/service/space/src/handlers/list_groups.rs +2 −2 View lib/service/space/src/handlers/list_groups.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dto::{PageQuery, SpacePath};
Modified lib/service/space/src/handlers/list_join_rules.rs lib/service/space/src/handlers/list_join_rules.rs +2 −2 View lib/service/space/src/handlers/list_join_rules.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dto::SpacePath;
Modified lib/service/space/src/handlers/move_dir_node.rs lib/service/space/src/handlers/move_dir_node.rs +2 −2 View lib/service/space/src/handlers/move_dir_node.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dir::{DirNodeDto, DirPath, MoveDirCmd};
Modified lib/service/space/src/handlers/remove_dir_group_overwrite.rs lib/service/space/src/handlers/remove_dir_group_overwrite.rs +2 −2 View lib/service/space/src/handlers/remove_dir_group_overwrite.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::handlers::set_dir_group_overwrite::DirGroupPath;
Modified lib/service/space/src/handlers/remove_dir_user_overwrite.rs lib/service/space/src/handlers/remove_dir_user_overwrite.rs +2 −2 View lib/service/space/src/handlers/remove_dir_user_overwrite.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::handlers::set_dir_user_overwrite::DirUserPath;
Modified lib/service/space/src/handlers/repair_dir_parents.rs lib/service/space/src/handlers/repair_dir_parents.rs +2 −2 View lib/service/space/src/handlers/repair_dir_parents.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dir::RepairDirResp;
Modified lib/service/space/src/handlers/set_dir_group_overwrite.rs lib/service/space/src/handlers/set_dir_group_overwrite.rs +2 −2 View lib/service/space/src/handlers/set_dir_group_overwrite.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44use serde::Deserialize;
55use utoipa::{IntoParams, ToSchema};
66use uuid::Uuid;
Modified lib/service/space/src/handlers/set_dir_user_overwrite.rs lib/service/space/src/handlers/set_dir_user_overwrite.rs +2 −2 View lib/service/space/src/handlers/set_dir_user_overwrite.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44use serde::Deserialize;
55use utoipa::{IntoParams, ToSchema};
66use uuid::Uuid;
Modified lib/service/space/src/handlers/space_admin.rs lib/service/space/src/handlers/space_admin.rs +3 −3 View lib/service/space/src/handlers/space_admin.rs
@@ -7,9 +7,9 @@
77 RoleSummary, SetMemberRoleBody, SetRolePermissionsBody, UpdateBanBody, UpdateMemberBody,
88 UpdateOrganizationBody,
99};
10use export::http::{Extension, Json, Path, Query, State};
11use export::middleware::RequestId;
12use export::rest::{AppResponseData, NoData};
10use api::http::{Extension, Json, Path, Query, State};
11use api::middleware::RequestId;
12use api::rest::{AppResponseData, NoData};
1313use session::Session;
1414use uuid::Uuid;
1515
Modified lib/service/space/src/handlers/unassign_group.rs lib/service/space/src/handlers/unassign_group.rs +2 −2 View lib/service/space/src/handlers/unassign_group.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44use serde::Deserialize;
55use utoipa::{IntoParams, ToSchema};
66use uuid::Uuid;
Modified lib/service/space/src/handlers/update_dir_node.rs lib/service/space/src/handlers/update_dir_node.rs +2 −2 View lib/service/space/src/handlers/update_dir_node.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::dir::{DirNodeDto, DirPath, UpdateDirCmd};
Modified lib/service/space/src/handlers/update_group.rs lib/service/space/src/handlers/update_group.rs +2 −2 View lib/service/space/src/handlers/update_group.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::handlers::get_group::GroupPath;
Modified lib/service/space/src/handlers/update_join_rule.rs lib/service/space/src/handlers/update_join_rule.rs +2 −2 View lib/service/space/src/handlers/update_join_rule.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::join_rules::{JoinRuleDto, JoinRulePath, UpdateJoinRuleCmd};
Modified lib/service/space/src/handlers/upload_space_image.rs lib/service/space/src/handlers/upload_space_image.rs +2 −2 View lib/service/space/src/handlers/upload_space_image.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use actix_web::http::header::CONTENT_TYPE;
3use export::http::{Bytes, HeaderMap, Path, Query, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Bytes, HeaderMap, Path, Query, State};
4use api::rest::{AppResponseData, NoData};
55
66use crate::errors::ApiError;
77use crate::services::images::{SpaceImageDto, SpaceImageKindPath, SpaceImageUploadQuery};
Modified lib/service/space/src/services/dir.rs lib/service/space/src/services/dir.rs +1 −1 View lib/service/space/src/services/dir.rs
@@ -114,7 +114,7 @@
114114
115115#[derive(Debug, Clone, Deserialize, ToSchema)]
116116pub struct MoveDirCmd {
117 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
117 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
118118 pub parent_dir_id: Option<Option<Uuid>>,
119119 #[serde(default)]
120120 pub position: Option<i64>,
Modified lib/service/space/src/services/dto.rs lib/service/space/src/services/dto.rs +3 −3 View lib/service/space/src/services/dto.rs
@@ -6,8 +6,8 @@
66
77pub const RESERVED_SPACE_NAMES: [&str; 1] = ["explore"];
88
9pub use export::users::UserDto;
10pub use export::{resolve_space_image_url, resolve_user_avatar_url};
9pub use api::users::UserDto;
10pub use api::{resolve_space_image_url, resolve_user_avatar_url};
1111
1212#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
1313pub struct SpaceDto {
@@ -30,7 +30,7 @@
3030 pub updated_at: OffsetDateTime,
3131}
3232
33pub use export::pagination::PageQuery;
33pub use api::pagination::PageQuery;
3434
3535#[derive(Debug, Clone, Deserialize, IntoParams, ToSchema)]
3636pub struct SpacePath {
Modified lib/service/space/src/services/groups.rs lib/service/space/src/services/groups.rs +4 −4 View lib/service/space/src/services/groups.rs
@@ -60,9 +60,9 @@
6060 pub name: Option<String>,
6161 #[serde(default)]
6262 pub color: Option<String>,
63 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
63 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
6464 pub unicode_emoji: Option<Option<String>>,
65 #[serde(default, deserialize_with = "export::serde_patch::deserialize_opt_opt")]
65 #[serde(default, deserialize_with = "api::serde_patch::deserialize_opt_opt")]
6666 pub icon_hash: Option<Option<String>>,
6767 #[serde(default)]
6868 pub position: Option<i64>,
@@ -75,7 +75,7 @@
7575 pub group_id: Uuid,
7676}
7777
78pub type GroupPage = export::pagination::Page<GroupDto>;
78pub type GroupPage = api::pagination::Page<GroupDto>;
7979
8080async fn replace_permissions(
8181 db: &impl ConnectionTrait,
@@ -511,7 +511,7 @@
511511 let space = lookup::lookup_space_by_name(self, space_name).await?;
512512 require_perm(self, &space, caller, MANAGE_ROLES).await?;
513513
514 let (limit, offset) = export::pagination::page_bounds(
514 let (limit, offset) = api::pagination::page_bounds(
515515 q.limit,
516516 q.offset,
517517 self.policy.settings.space.default_pagination,
Modified lib/service/space/src/services/images.rs lib/service/space/src/services/images.rs +13 −13 View lib/service/space/src/services/images.rs
@@ -1,5 +1,5 @@
11use crate::{Access, Capability, require};
2use export::AppRedis;
2use cache::AppRedis;
33use std::sync::Arc;
44use storage::S3Client;
55
@@ -279,11 +279,11 @@
279279 let Some(original_key) = space_image_object_key(stored_url) else {
280280 return stored_url.to_string();
281281 };
282 let key_base = export::imaging::preview_key_base_of(&original_key);
282 let key_base = media::preview_key_base_of(&original_key);
283283 let recorded = self
284284 .recorded_space_image_preview(space_id, kind, &key_base)
285285 .await;
286 let state = export::imaging::ensure_preview(
286 let state = media::ensure_preview(
287287 self.storage.as_ref(),
288288 &self.redis,
289289 &key_base,
@@ -321,11 +321,11 @@
321321 self.storage.as_ref().get(&meta_key).await;
322322 if let Ok(bytes) = fetched
323323 && let Ok(record) = serde_json::from_slice::<serde_json::Value>(&bytes)
324 && let Some(state) = export::imaging::recorded_preview(&record)
324 && let Some(state) = media::recorded_preview(&record)
325325 {
326326 return Some(state);
327327 }
328 export::imaging::find_stored_preview(self.storage.as_ref(), key_base).await
328 media::find_stored_preview(self.storage.as_ref(), key_base).await
329329 }
330330
331331 /// Persist the sidecar with the derivative that is currently authoritative.
@@ -353,7 +353,7 @@
353353 "uploaded_at": uploaded_at,
354354 });
355355 if let Some(state) = preview {
356 meta = export::imaging::record_preview(meta, state);
356 meta = media::record_preview(meta, state);
357357 }
358358 if let Err(error) = self
359359 .storage
@@ -375,7 +375,7 @@
375375 let Some(original_key) = space_image_object_key(stored_url) else {
376376 return;
377377 };
378 let key_base = export::imaging::preview_key_base_of(&original_key);
378 let key_base = media::preview_key_base_of(&original_key);
379379 for candidate in imaging::layout::preview_candidate_keys(&key_base) {
380380 if let Err(error) = self.storage.as_ref().delete(&candidate).await {
381381 tracing::warn!(%error, key = %candidate, "failed to delete old space image preview");
@@ -390,7 +390,7 @@
390390 stored_url: &str,
391391 ) -> Result<String, SpaceError> {
392392 let cache_key = space_image_url_cache_key(space_id, kind);
393 match export::redis::get_string(&self.redis, &cache_key).await {
393 match cache::client::get_string(&self.redis, &cache_key).await {
394394 Ok(Some(url)) => return Ok(url),
395395 Ok(None) => {}
396396 Err(error) => {
@@ -403,7 +403,7 @@
403403 .as_ref()
404404 .presign_get(&key, SPACE_IMAGE_URL_TTL_SECS as u32)?;
405405 if let Err(error) =
406 export::redis::set_string(&self.redis, &cache_key, &url, SPACE_IMAGE_URL_TTL_SECS).await
406 cache::client::set_string(&self.redis, &cache_key, &url, SPACE_IMAGE_URL_TTL_SECS).await
407407 {
408408 tracing::warn!(%error, "failed to cache space image presigned url");
409409 }
@@ -502,7 +502,7 @@
502502 .await?;
503503
504504 if let Err(error) =
505 export::redis::delete(&self.redis, &space_image_url_cache_key(space_id, kind)).await
505 cache::client::delete(&self.redis, &space_image_url_cache_key(space_id, kind)).await
506506 {
507507 tracing::warn!(%error, "failed to invalidate space image url cache");
508508 }
@@ -511,8 +511,8 @@
511511 // the small object; the same extension may have been in use before, so
512512 // stale candidates are cleared first.
513513 self.delete_space_image_previews(&stored_url).await;
514 let key_base = export::imaging::preview_key_base_of(&object_key);
515 let preview = export::imaging::ensure_preview(
514 let key_base = media::preview_key_base_of(&object_key);
515 let preview = media::ensure_preview(
516516 self.storage.as_ref(),
517517 &self.redis,
518518 &key_base,
@@ -582,7 +582,7 @@
582582 write_space_image(&self.access, space_id, kind, None, None, None).await?;
583583
584584 if let Err(error) =
585 export::redis::delete(&self.redis, &space_image_url_cache_key(space_id, kind)).await
585 cache::client::delete(&self.redis, &space_image_url_cache_key(space_id, kind)).await
586586 {
587587 tracing::warn!(%error, "failed to invalidate space image url cache");
588588 }
Modified lib/service/space/src/services/internal_authz.rs lib/service/space/src/services/internal_authz.rs +2 −2 View lib/service/space/src/services/internal_authz.rs
@@ -5,7 +5,7 @@
55use crate::errors::{SpaceError, SpaceResult};
66use crate::services::service::SpaceService;
77
8fn access_error(error: export::AccessError) -> SpaceError {
8fn access_error(error: api::AccessError) -> SpaceError {
99 SpaceError::Internal(error.to_string())
1010}
1111
@@ -101,7 +101,7 @@
101101 .await
102102 .map(|()| true)
103103 .or_else(|error| match error {
104 export::AccessError::Forbidden => Ok(false),
104 api::AccessError::Forbidden => Ok(false),
105105 other => Err(access_error(other)),
106106 })
107107 }
Modified lib/service/space/src/services/join_requests.rs lib/service/space/src/services/join_requests.rs +4 −4 View lib/service/space/src/services/join_requests.rs
@@ -22,8 +22,8 @@
2222
2323pub const MAX_JOIN_REQUEST_NOTE_LEN: usize = 512;
2424
25pub type JoinRequestPage = export::pagination::Page<JoinRequestDto>;
26pub type ExploreSpacePage = export::pagination::Page<ExploreSpaceDto>;
25pub type JoinRequestPage = api::pagination::Page<JoinRequestDto>;
26pub type ExploreSpacePage = api::pagination::Page<ExploreSpaceDto>;
2727
2828#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
2929pub struct JoinRequestDto {
@@ -174,7 +174,7 @@
174174 viewer: Option<i64>,
175175 query: ExploreQuery,
176176 ) -> Result<ExploreSpacePage, SpaceError> {
177 let (limit, offset) = export::pagination::page_bounds(
177 let (limit, offset) = api::pagination::page_bounds(
178178 query.limit,
179179 query.offset,
180180 self.policy.settings.space.default_pagination,
@@ -432,7 +432,7 @@
432432 let space = lookup::lookup_space_by_name(self, space_name).await?;
433433 require_perm(self, &space, caller, MANAGE_MEMBERS).await?;
434434
435 let (limit, offset) = export::pagination::page_bounds(
435 let (limit, offset) = api::pagination::page_bounds(
436436 query.limit,
437437 query.offset,
438438 self.policy.settings.space.default_pagination,
Modified lib/service/space/src/services/policy.rs lib/service/space/src/services/policy.rs +1 −1 View lib/service/space/src/services/policy.rs
@@ -1,7 +1,7 @@
11use crate::errors::SpaceError;
22use crate::services::service::SpaceSettings;
33use auth::Accounts;
4use export::AppRedis;
4use cache::AppRedis;
55use models::space::{AllowJoinLevel, spaces};
66use time::{Duration, OffsetDateTime};
77
Modified lib/service/space/src/services/service.rs lib/service/space/src/services/service.rs +2 −2 View lib/service/space/src/services/service.rs
@@ -17,7 +17,7 @@
1717 pub(crate) access: crate::Access,
1818 pub(crate) images: crate::services::images::SpaceImages,
1919 pub(crate) policy: crate::services::policy::SpacePolicy,
20 pub(crate) notifications: export::notify::Notifications,
20 pub(crate) notifications: push::notify::Notifications,
2121}
2222
2323impl SpaceService {
@@ -25,7 +25,7 @@
2525 access: crate::Access,
2626 images: crate::services::images::SpaceImages,
2727 policy: crate::services::policy::SpacePolicy,
28 notifications: export::notify::Notifications,
28 notifications: push::notify::Notifications,
2929 ) -> Self {
3030 Self {
3131 access,
Modified lib/service/space/src/access.rs lib/service/space/src/access.rs +1 −1 View lib/service/space/src/access.rs
@@ -8,7 +8,7 @@
88use time::OffsetDateTime;
99use uuid::Uuid;
1010
11use export::AccessError;
11use api::AccessError;
1212
1313#[derive(Clone)]
1414pub struct Access {
Modified lib/service/space/src/errors.rs lib/service/space/src/errors.rs +14 −15 View lib/service/space/src/errors.rs
@@ -1,7 +1,7 @@
11use actix_web::http::StatusCode;
22use std::fmt;
33
4pub use export::is_unique_violation;
4pub use api::is_unique_violation;
55
66#[derive(Debug)]
77pub enum SpaceError {
@@ -109,15 +109,15 @@
109109 }
110110}
111111
112impl From<export::KenAuthError> for SpaceError {
113 fn from(error: export::KenAuthError) -> Self {
112impl From<auth::KenAuthError> for SpaceError {
113 fn from(error: auth::KenAuthError) -> Self {
114114 match error {
115 export::KenAuthError::NotFound => Self::NotFound,
116 export::KenAuthError::Unauthenticated => Self::Unauthorized,
117 export::KenAuthError::Unavailable(message) => {
115 auth::KenAuthError::NotFound => Self::NotFound,
116 auth::KenAuthError::Unauthenticated => Self::Unauthorized,
117 auth::KenAuthError::Unavailable(message) => {
118118 Self::Internal(format!("kenoauth unavailable: {message}"))
119119 }
120 export::KenAuthError::Rejected(message) => {
120 auth::KenAuthError::Rejected(message) => {
121121 let lower = message.to_lowercase();
122122 if lower.contains("already") || lower.contains("taken") {
123123 Self::Conflict(message)
@@ -127,19 +127,18 @@
127127 Self::BadRequest(message)
128128 }
129129 }
130 export::KenAuthError::Config(message) | export::KenAuthError::Internal(message) => {
130 auth::KenAuthError::Config(message) | auth::KenAuthError::Internal(message) => {
131131 Self::Internal(message)
132132 }
133133 }
134134 }
135135}
136136
137export::db_error_conversions!(SpaceError);
138export::storage_error_conversion!(SpaceError);
139export::export_error_conversion!(SpaceError);
140export::json_payload_conversion!(SpaceError);
137api::db_error_conversions!(SpaceError);
138storage::storage_error_conversion!(SpaceError);
139api::json_payload_conversion!(SpaceError);
141140
142export::api_error! {
141api::api_error! {
143142 log: "space",
144143 pub enum ApiError {
145144 BadRequest(400, "request failed validation"),
@@ -161,7 +160,7 @@
161160 }
162161 Self::build(
163162 status,
164 export::rest::AppResponseData::err(i32::from(status), error.message())
163 api::rest::AppResponseData::err(i32::from(status), error.message())
165164 .with_error_code(error.code()),
166165 )
167166 }
@@ -257,4 +256,4 @@
257256 }
258257}
259258
260export::access_error_conversion!(SpaceError, BadRequest);
259api::access_error_conversion!(SpaceError, BadRequest);
Modified lib/service/space/src/openapi.rs lib/service/space/src/openapi.rs +2 −2 View lib/service/space/src/openapi.rs
@@ -1,4 +1,4 @@
1use export::rest::AppResponseData;
1use api::rest::AppResponseData;
22use utoipa::OpenApi;
33
44#[derive(OpenApi)]
@@ -104,7 +104,7 @@
104104 crate::services::join_requests::JoinRequestPage,
105105 crate::services::join_requests::CreateJoinRequestCmd,
106106 models::space::SpaceJoinRequestState,
107 export::pagination::Page<crate::services::dto::SpaceDto>,
107 api::pagination::Page<crate::services::dto::SpaceDto>,
108108 crate::services::dto::UserDto,
109109 crate::services::groups::GroupDto,
110110 crate::services::groups::GroupPage,
Modified lib/service/space/src/routes.rs lib/service/space/src/routes.rs +3 −3 View lib/service/space/src/routes.rs
@@ -1,5 +1,5 @@
1use export::http::Router;
2use export::http::routing::{delete, get, patch, post, put};
1use api::http::Router;
2use api::http::routing::{delete, get, patch, post, put};
33
44use crate::handlers::assign_group::assign_group;
55use crate::handlers::create_dir_node::create_dir_node;
@@ -231,7 +231,7 @@
231231 "/spaces/{space_name}/permissions/check",
232232 post(crate::handlers::space_admin::check_permission),
233233 )
234 .wrap(export::http::Guard::Session);
234 .wrap(api::http::Guard::Session);
235235
236236 public.merge(protected)
237237}
Modified lib/service/space/Cargo.toml lib/service/space/Cargo.toml +3 −1 View lib/service/space/Cargo.toml
@@ -4,6 +4,9 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8media = { workspace = true }
9push = { workspace = true }
710auth = { workspace = true }
811dir = { workspace = true }
912async-trait = { workspace = true }
@@ -14,7 +17,6 @@
1417db = { workspace = true }
1518deletion = { workspace = true }
1619envelope = { workspace = true }
17export = { workspace = true }
1820events = { workspace = true }
1921internal = { workspace = true }
2022proto = { workspace = true }
Modified lib/service/user/src/handlers/create_meme.rs lib/service/user/src/handlers/create_meme.rs +2 −2 View lib/service/user/src/handlers/create_meme.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::profile::{MemeDto, UpsertMemeCmd};
Modified lib/service/user/src/handlers/delete_avatar.rs lib/service/user/src/handlers/delete_avatar.rs +2 −2 View lib/service/user/src/handlers/delete_avatar.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::State;
3use export::rest::{AppResponseData, NoData};
2use api::http::State;
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::service::UserService;
Modified lib/service/user/src/handlers/delete_meme.rs lib/service/user/src/handlers/delete_meme.rs +2 −2 View lib/service/user/src/handlers/delete_meme.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44use uuid::Uuid;
55
66use crate::errors::ApiError;
Modified lib/service/user/src/handlers/delete_push_subscription.rs lib/service/user/src/handlers/delete_push_subscription.rs +2 −2 View lib/service/user/src/handlers/delete_push_subscription.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44use uuid::Uuid;
55
66use crate::errors::ApiError;
Modified lib/service/user/src/handlers/get_avatar.rs lib/service/user/src/handlers/get_avatar.rs +2 −2 View lib/service/user/src/handlers/get_avatar.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::State;
3use export::rest::{AppResponseData, NoData};
2use api::http::State;
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::avatar::AvatarDto;
Modified lib/service/user/src/handlers/get_profile_detail.rs lib/service/user/src/handlers/get_profile_detail.rs +2 −2 View lib/service/user/src/handlers/get_profile_detail.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::profile::ProfileDetailDto;
Modified lib/service/user/src/handlers/get_user_avatar.rs lib/service/user/src/handlers/get_user_avatar.rs +3 −3 View lib/service/user/src/handlers/get_user_avatar.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use ::session::share::session;
33use actix_web::http::header;
4use export::http::{Path, Query, Response, State};
4use api::http::{Path, Query, Response, State};
55use imaging::layout::ImageVariant;
66use serde::Deserialize;
77use utoipa::{IntoParams, ToSchema};
@@ -25,8 +25,8 @@
2525 params(("user_id" = i64, Path, description = "user id"), AvatarVariantQuery),
2626 responses(
2727 (status = 302, description = "redirect to presigned s3 avatar url"),
28 (status = 404, description = "user not found or has no avatar", body = export::rest::AppResponseData<export::rest::NoData>),
29 (status = 401, description = "authentication required", body = export::rest::AppResponseData<export::rest::NoData>)
28 (status = 404, description = "user not found or has no avatar", body = api::rest::AppResponseData<api::rest::NoData>),
29 (status = 401, description = "authentication required", body = api::rest::AppResponseData<api::rest::NoData>)
3030 )
3131)]
3232pub async fn get_user_avatar(
Modified lib/service/user/src/handlers/list_memes.rs lib/service/user/src/handlers/list_memes.rs +2 −2 View lib/service/user/src/handlers/list_memes.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::profile::{ListLimitQuery, MemeDto};
Modified lib/service/user/src/handlers/list_push_subscriptions.rs lib/service/user/src/handlers/list_push_subscriptions.rs +2 −2 View lib/service/user/src/handlers/list_push_subscriptions.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::push_subscriptions::PushSubscriptionDto;
Modified lib/service/user/src/handlers/list_saved_messages.rs lib/service/user/src/handlers/list_saved_messages.rs +2 −2 View lib/service/user/src/handlers/list_saved_messages.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::notifications::SavedMessageDto;
Modified lib/service/user/src/handlers/my_reports.rs lib/service/user/src/handlers/my_reports.rs +2 −2 View lib/service/user/src/handlers/my_reports.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::notifications::UserReportDto;
Modified lib/service/user/src/handlers/my_spaces.rs lib/service/user/src/handlers/my_spaces.rs +2 −2 View lib/service/user/src/handlers/my_spaces.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::profile::MySpaceDto;
Modified lib/service/user/src/handlers/my_suspensions.rs lib/service/user/src/handlers/my_suspensions.rs +2 −2 View lib/service/user/src/handlers/my_suspensions.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::service::UserService;
Modified lib/service/user/src/handlers/push_config.rs lib/service/user/src/handlers/push_config.rs +2 −2 View lib/service/user/src/handlers/push_config.rs
@@ -1,5 +1,5 @@
1use export::http::State;
2use export::rest::AppResponseData;
1use api::http::State;
2use api::rest::AppResponseData;
33use serde::Serialize;
44use utoipa::ToSchema;
55
Modified lib/service/user/src/handlers/recent_mentions.rs lib/service/user/src/handlers/recent_mentions.rs +2 −2 View lib/service/user/src/handlers/recent_mentions.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Query, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Query, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::notifications::RecentMentionDto;
Modified lib/service/user/src/handlers/save_message.rs lib/service/user/src/handlers/save_message.rs +2 −2 View lib/service/user/src/handlers/save_message.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::notifications::{SaveMessageCmd, SavedMessageDto};
Modified lib/service/user/src/handlers/ssh_key.rs lib/service/user/src/handlers/ssh_key.rs +3 −3 View lib/service/user/src/handlers/ssh_key.rs
@@ -1,9 +1,9 @@
11use crate::errors::ApiError;
22use crate::services::ssh_key::types::{SshKeyAddRequest, SshKeySummary};
3use api::http::{Extension, Json, Path, Query, State};
4use api::middleware::RequestId;
5use api::rest::{AppResponseData, NoData};
36use auth::share::types::ListQuery;
4use export::http::{Extension, Json, Path, Query, State};
5use export::middleware::RequestId;
6use export::rest::{AppResponseData, NoData};
77use session::Session;
88use uuid::Uuid;
99
Modified lib/service/user/src/handlers/unsave_message.rs lib/service/user/src/handlers/unsave_message.rs +2 −2 View lib/service/user/src/handlers/unsave_message.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Path, State};
3use api::rest::{AppResponseData, NoData};
44use uuid::Uuid;
55
66use crate::errors::ApiError;
Modified lib/service/user/src/handlers/update_meme.rs lib/service/user/src/handlers/update_meme.rs +2 −2 View lib/service/user/src/handlers/update_meme.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, Path, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, Path, State};
3use api::rest::{AppResponseData, NoData};
44use uuid::Uuid;
55
66use crate::errors::ApiError;
Modified lib/service/user/src/handlers/upload_avatar.rs lib/service/user/src/handlers/upload_avatar.rs +2 −2 View lib/service/user/src/handlers/upload_avatar.rs
@@ -1,7 +1,7 @@
11use ::session::Session;
22use actix_web::http::header::CONTENT_TYPE;
3use export::http::{Bytes, HeaderMap, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Bytes, HeaderMap, State};
4use api::rest::{AppResponseData, NoData};
55
66use crate::errors::ApiError;
77use crate::services::avatar::AvatarDto;
Modified lib/service/user/src/handlers/upsert_push_subscription.rs lib/service/user/src/handlers/upsert_push_subscription.rs +2 −2 View lib/service/user/src/handlers/upsert_push_subscription.rs
@@ -1,6 +1,6 @@
11use ::session::Session;
2use export::http::{Json, State};
3use export::rest::{AppResponseData, NoData};
2use api::http::{Json, State};
3use api::rest::{AppResponseData, NoData};
44
55use crate::errors::ApiError;
66use crate::services::push_subscriptions::{PushSubscriptionDto, UpsertPushCmd};
Modified lib/service/user/src/services/avatar.rs lib/service/user/src/services/avatar.rs +13 −12 View lib/service/user/src/services/avatar.rs
@@ -7,7 +7,8 @@
77use utoipa::ToSchema;
88
99use crate::errors::UserError;
10use export::{AppDatabase, AppRedis};
10use cache::AppRedis;
11use db::AppDatabase;
1112use std::sync::Arc;
1213use storage::S3Client;
1314
@@ -131,7 +132,7 @@
131132 return Ok(None);
132133 };
133134 let cache_key = Self::avatar_url_cache_key(uid, variant);
134 match export::redis::get_string(&self.redis, &cache_key).await {
135 match cache::client::get_string(&self.redis, &cache_key).await {
135136 Ok(Some(url)) => return Ok(Some(url)),
136137 Ok(None) => {}
137138 Err(error) => {
@@ -149,7 +150,7 @@
149150 .presign_get(&key, AVATAR_URL_TTL_SECS as u32)
150151 .map_err(UserError::from)?;
151152 if let Err(error) =
152 export::redis::set_string(&self.redis, &cache_key, &url, AVATAR_URL_TTL_SECS).await
153 cache::client::set_string(&self.redis, &cache_key, &url, AVATAR_URL_TTL_SECS).await
153154 {
154155 tracing::warn!(%error, "failed to cache avatar presigned url");
155156 }
@@ -179,9 +180,9 @@
179180 let Some(original_key) = avatar_object_key(&user.local_avatar_url) else {
180181 return Ok(Some(user.local_avatar_url));
181182 };
182 let key_base = export::imaging::preview_key_base_of(&original_key);
183 let key_base = media::preview_key_base_of(&original_key);
183184 let recorded = self.recorded_avatar_preview(uid, &key_base).await;
184 let state = export::imaging::ensure_preview(
185 let state = media::ensure_preview(
185186 self.storage.as_ref(),
186187 &self.redis,
187188 &key_base,
@@ -212,11 +213,11 @@
212213 let meta_key = avatar_meta_key(uid);
213214 if let Ok(bytes) = self.storage.as_ref().get(&meta_key).await
214215 && let Ok(record) = serde_json::from_slice::<serde_json::Value>(&bytes)
215 && let Some(state) = export::imaging::recorded_preview(&record)
216 && let Some(state) = media::recorded_preview(&record)
216217 {
217218 return Some(state);
218219 }
219 export::imaging::find_stored_preview(self.storage.as_ref(), key_base).await
220 media::find_stored_preview(self.storage.as_ref(), key_base).await
220221 }
221222
222223 /// Persist the sidecar next to the original, recording which derivative is
@@ -236,7 +237,7 @@
236237 "uploaded_at": now,
237238 });
238239 if let Some(state) = preview {
239 meta = export::imaging::record_preview(meta, state);
240 meta = media::record_preview(meta, state);
240241 }
241242 match serde_json::to_vec(&meta) {
242243 Ok(meta_bytes) => {
@@ -258,7 +259,7 @@
258259 /// Drop both encodings of the derivative. Called before writing a new
259260 /// original (the preset may switch JPEG<->WebP) and again on delete.
260261 async fn delete_avatar_previews(&self, original_key: &str) {
261 let key_base = export::imaging::preview_key_base_of(original_key);
262 let key_base = media::preview_key_base_of(original_key);
262263 for candidate in imaging::layout::preview_candidate_keys(&key_base) {
263264 if let Err(error) = self.storage.as_ref().delete(&candidate).await {
264265 tracing::warn!(%error, key = %candidate, "failed to delete old avatar preview");
@@ -269,7 +270,7 @@
269270 async fn invalidate_avatar_cache(&self, uid: i64) {
270271 for variant in [ImageVariant::Preview, ImageVariant::Original] {
271272 if let Err(error) =
272 export::redis::delete(&self.redis, &Self::avatar_url_cache_key(uid, variant)).await
273 cache::client::delete(&self.redis, &Self::avatar_url_cache_key(uid, variant)).await
273274 {
274275 tracing::warn!(%error, "failed to invalidate avatar url cache");
275276 }
@@ -328,11 +329,11 @@
328329
329330 // The preview is built immediately so the first list view after an upload
330331 // already has it; a failure here is not an upload failure.
331 let key_base = export::imaging::preview_key_base_of(&key);
332 let key_base = media::preview_key_base_of(&key);
332333 // The old derivative shares this base only when the extension is reused;
333334 // clearing it first keeps exactly one candidate object alive.
334335 self.delete_avatar_previews(&key).await;
335 let preview = export::imaging::ensure_preview(
336 let preview = media::ensure_preview(
336337 self.storage.as_ref(),
337338 &self.redis,
338339 &key_base,
Modified lib/service/user/src/services/service.rs lib/service/user/src/services/service.rs +1 −1 View lib/service/user/src/services/service.rs
@@ -1,5 +1,5 @@
11use crate::services::avatar::AvatarService;
2use export::AppDatabase;
2use db::AppDatabase;
33use std::sync::Arc;
44
55#[derive(Clone)]
Modified lib/service/user/src/services/ssh_keys.rs lib/service/user/src/services/ssh_keys.rs +5 −5 View lib/service/user/src/services/ssh_keys.rs
@@ -1,8 +1,8 @@
1use auth::KenAuthError;
12use auth::models::users::user_events::UserEventType;
23use auth::models::users::{user_ssh_keys, users};
34use auth::protos::auth::common::v1::{AuthMethod, PageResponse};
45use auth::protos::auth::v1::*;
5use export::KenAuthError;
66use sea_orm::sea_query::{Expr, ExprTrait};
77use sea_orm::{ColumnTrait, EntityTrait, QueryFilter, QueryOrder, QuerySelect, TransactionTrait};
88use uuid::Uuid;
@@ -30,7 +30,7 @@
3030}
3131
3232impl SshKeys {
33 #[tracing::instrument(skip_all, fields(request_id = %export::middleware::resolve_request_id(request_id)))]
33 #[tracing::instrument(skip_all, fields(request_id = %api::middleware::resolve_request_id(request_id)))]
3434 pub async fn lookup_ssh_key_inner(
3535 &self,
3636 request_id: Option<&str>,
@@ -91,7 +91,7 @@
9191 current_security_version: user.security_version,
9292 })
9393 }
94 #[tracing::instrument(skip_all, fields(request_id = %export::middleware::resolve_request_id(request_id)))]
94 #[tracing::instrument(skip_all, fields(request_id = %api::middleware::resolve_request_id(request_id)))]
9595 pub async fn add_ssh_key_inner(
9696 &self,
9797 request_id: Option<&str>,
@@ -124,7 +124,7 @@
124124 key: Some(crate::share::ssh_keys::ssh_key_info(&row)),
125125 })
126126 }
127 #[tracing::instrument(skip_all, fields(request_id = %export::middleware::resolve_request_id(request_id)))]
127 #[tracing::instrument(skip_all, fields(request_id = %api::middleware::resolve_request_id(request_id)))]
128128 pub async fn list_user_ssh_keys_inner(
129129 &self,
130130 request_id: Option<&str>,
@@ -170,7 +170,7 @@
170170 page: Some(PageResponse { next_page_token }),
171171 })
172172 }
173 #[tracing::instrument(skip_all, fields(request_id = %export::middleware::resolve_request_id(request_id)))]
173 #[tracing::instrument(skip_all, fields(request_id = %api::middleware::resolve_request_id(request_id)))]
174174 pub async fn revoke_ssh_key_inner(
175175 &self,
176176 request_id: Option<&str>,
Modified lib/service/user/src/share/page.rs lib/service/user/src/share/page.rs +1 −1 View lib/service/user/src/share/page.rs
@@ -1 +1 @@
1pub use export::pagination::{DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT, Page, PageQuery};
1pub use api::pagination::{DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT, Page, PageQuery};
Modified lib/service/user/src/share/types.rs lib/service/user/src/share/types.rs +1 −1 View lib/service/user/src/share/types.rs
@@ -1 +1 @@
1pub type ListQuery = export::pagination::PageQuery;
1pub type ListQuery = api::pagination::PageQuery;
Modified lib/service/user/src/errors.rs lib/service/user/src/errors.rs +8 −8 View lib/service/user/src/errors.rs
@@ -25,15 +25,15 @@
2525
2626impl std::error::Error for UserError {}
2727
28export::access_error_conversion!(UserError, BadRequest);
28api::access_error_conversion!(UserError, BadRequest);
2929
30export::db_error_conversions!(UserError);
31export::storage_error_conversion!(UserError);
32export::redis_error_conversion!(UserError);
33export::export_error_conversion!(UserError);
34export::json_payload_conversion!(UserError);
30auth::auth_error_conversion!(UserError);
31api::db_error_conversions!(UserError);
32storage::storage_error_conversion!(UserError);
33cache::redis_error_conversion!(UserError);
34api::json_payload_conversion!(UserError);
3535
36export::api_error! {
36api::api_error! {
3737 log: "user",
3838 pub enum ApiError {
3939 BadRequest(400, "request failed validation"),
@@ -67,7 +67,7 @@
6767 if error.is_internal() {
6868 tracing::warn!(%error, "user SSH key handler failed");
6969 }
70 let mut response = export::rest::AppResponseData::err(i32::from(status), error.message())
70 let mut response = api::rest::AppResponseData::err(i32::from(status), error.message())
7171 .with_error_code(error.code());
7272 if let auth::AuthError::RateLimited { retry_after_secs } = &error {
7373 response = response.with_retry_after(*retry_after_secs);
Modified lib/service/user/src/openapi.rs lib/service/user/src/openapi.rs +2 −2 View lib/service/user/src/openapi.rs
@@ -1,4 +1,4 @@
1use export::rest::NoData;
1use api::rest::NoData;
22use models::users::user::ProfileVisibility;
33use models::users::user_push_subscriptions::PushSubscriptionPlatform;
44use models::users::user_reports::ReportStatus;
@@ -45,7 +45,7 @@
4545 handlers::push_config::push_config,
4646 ),
4747 components(schemas(
48 export::pagination::PageQuery,
48 api::pagination::PageQuery,
4949 imaging::layout::ImageVariant,
5050 NoData,
5151 AvatarFormat,
Modified lib/service/user/src/routes.rs lib/service/user/src/routes.rs +3 −3 View lib/service/user/src/routes.rs
@@ -1,5 +1,5 @@
1use export::http::Router;
2use export::http::routing::{delete, get, put};
1use api::http::Router;
2use api::http::routing::{delete, get, put};
33
44use crate::handlers::create_meme::create_meme;
55use crate::handlers::delete_avatar::delete_avatar;
@@ -69,7 +69,7 @@
6969 )
7070 .route("/me/messages/saved/{message_id}", delete(unsave_message))
7171 .route("/me/suspensions", get(my_suspensions))
72 .wrap(export::http::Guard::Session);
72 .wrap(api::http::Guard::Session);
7373
7474 public.merge(protected)
7575}
Modified lib/service/user/Cargo.toml lib/service/user/Cargo.toml +4 −1 View lib/service/user/Cargo.toml
@@ -4,12 +4,15 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8cache = { workspace = true }
9db = { workspace = true }
10media = { workspace = true }
711auth = { workspace = true }
812chrono = { version = "0.4.45", features = ["serde"] }
913
1014async-trait = { workspace = true }
1115config = { workspace = true }
12export = { workspace = true }
1316models = { workspace = true }
1417i18n = { workspace = true }
1518imaging = { workspace = true }
Modified lib/service/webapi/src/domains/account_deletion.rs lib/service/webapi/src/domains/account_deletion.rs +3 −3 View lib/service/webapi/src/domains/account_deletion.rs
@@ -1,5 +1,5 @@
1use export::AppState;
2use export::http::{Guard, Router};
1use ::bootstrap::AppState;
2use api::http::{Guard, Router};
33
44use crate::bootstrap::Deps;
55
@@ -7,7 +7,7 @@
77 Router::<AppState>::new()
88 .route(
99 "/me/deletion",
10 export::http::get(crate::account_deletion::account_deletion_status)
10 api::http::get(crate::account_deletion::account_deletion_status)
1111 .post(crate::account_deletion::request_account_deletion)
1212 .delete(crate::account_deletion::cancel_account_deletion),
1313 )
Modified lib/service/webapi/src/domains/auth.rs lib/service/webapi/src/domains/auth.rs +1 −1 View lib/service/webapi/src/domains/auth.rs
@@ -1,4 +1,4 @@
1use export::http::Router;
1use api::http::Router;
22
33use crate::bootstrap::Deps;
44
Modified lib/service/webapi/src/domains/chat.rs lib/service/webapi/src/domains/chat.rs +1 −1 View lib/service/webapi/src/domains/chat.rs
@@ -1,4 +1,4 @@
1use export::http::Router;
1use api::http::Router;
22
33use crate::bootstrap::Deps;
44
Modified lib/service/webapi/src/domains/git.rs lib/service/webapi/src/domains/git.rs +1 −1 View lib/service/webapi/src/domains/git.rs
@@ -1,4 +1,4 @@
1use export::http::Router;
1use api::http::Router;
22
33use crate::bootstrap::Deps;
44
Modified lib/service/webapi/src/domains/issues.rs lib/service/webapi/src/domains/issues.rs +1 −1 View lib/service/webapi/src/domains/issues.rs
@@ -1,4 +1,4 @@
1use export::http::Router;
1use api::http::Router;
22
33use crate::bootstrap::Deps;
44
Modified lib/service/webapi/src/domains/pulls.rs lib/service/webapi/src/domains/pulls.rs +1 −1 View lib/service/webapi/src/domains/pulls.rs
@@ -1,4 +1,4 @@
1use export::http::Router;
1use api::http::Router;
22
33use crate::bootstrap::Deps;
44
Modified lib/service/webapi/src/domains/space.rs lib/service/webapi/src/domains/space.rs +1 −1 View lib/service/webapi/src/domains/space.rs
@@ -1,4 +1,4 @@
1use export::http::Router;
1use api::http::Router;
22
33use crate::bootstrap::Deps;
44
Modified lib/service/webapi/src/domains/user.rs lib/service/webapi/src/domains/user.rs +1 −1 View lib/service/webapi/src/domains/user.rs
@@ -1,4 +1,4 @@
1use export::http::Router;
1use api::http::Router;
22
33use crate::bootstrap::Deps;
44
Modified lib/service/webapi/src/middleware/cookie.rs lib/service/webapi/src/middleware/cookie.rs +1 −1 View lib/service/webapi/src/middleware/cookie.rs
@@ -1,5 +1,5 @@
11use actix_web::http::header::{HeaderValue, SET_COOKIE};
2use export::http::Response;
2use api::http::Response;
33
44pub fn append_cookie(response: &mut Response, cookie: &str) {
55 if let Ok(value) = HeaderValue::from_str(cookie) {
Modified lib/service/webapi/src/middleware/csrf.rs lib/service/webapi/src/middleware/csrf.rs +2 −2 View lib/service/webapi/src/middleware/csrf.rs
@@ -5,7 +5,7 @@
55use actix_web::web::Data;
66use actix_web::{Error, HttpResponse};
77
8use export::AppState;
8use ::bootstrap::AppState;
99
1010const SKIP_PREFIXES: [&str; 5] = [
1111 "/healthz",
@@ -59,7 +59,7 @@
5959 "data": null,
6060 "error": null,
6161 "error_code": "csrf_rejected",
62 "request_id": export::middleware::request_id(),
62 "request_id": api::middleware::request_id(),
6363 })))
6464 .map_into_boxed_body());
6565 }
Modified lib/service/webapi/src/middleware/revalidate.rs lib/service/webapi/src/middleware/revalidate.rs +5 −5 View lib/service/webapi/src/middleware/revalidate.rs
@@ -4,8 +4,8 @@
44use actix_web::web::Data;
55use actix_web::{Error, HttpMessage, HttpResponse};
66
7use ::bootstrap::AppState;
78use ::session::Session;
8use export::AppState;
99
1010use crate::middleware::cookie::append_cookie;
1111
@@ -59,7 +59,7 @@
5959 };
6060
6161 let key = format!("auth:recheck:{session_id}:{version}");
62 if export::redis::get_string(&state.redis, &key)
62 if cache::client::get_string(&state.redis, &key)
6363 .await
6464 .ok()
6565 .flatten()
@@ -70,7 +70,7 @@
7070
7171 match accounts.get_session(user_id, version, &session_id).await {
7272 Ok(_) => {
73 let _ = export::redis::set_string(
73 let _ = cache::client::set_string(
7474 &state.redis,
7575 &key,
7676 "1",
@@ -79,14 +79,14 @@
7979 .await;
8080 Ok(next.call(request).await?.map_into_boxed_body())
8181 }
82 Err(export::KenAuthError::Unauthenticated) | Err(export::KenAuthError::NotFound) => {
82 Err(auth::KenAuthError::Unauthenticated) | Err(auth::KenAuthError::NotFound) => {
8383 let mut response = HttpResponse::Unauthorized().json(serde_json::json!({
8484 "code": 401,
8585 "message": "session_revoked",
8686 "data": null,
8787 "error": null,
8888 "error_code": "session_revoked",
89 "request_id": export::middleware::request_id(),
89 "request_id": api::middleware::request_id(),
9090 }));
9191 append_cookie(
9292 &mut response,
Modified lib/service/webapi/src/account_deletion.rs lib/service/webapi/src/account_deletion.rs +3 −3 View lib/service/webapi/src/account_deletion.rs
@@ -1,13 +1,13 @@
11use ::session::Session;
22use ::session::share::session;
3use export::http::{Extension, State};
4use export::rest::{AppResponseData, NoData};
3use api::http::{Extension, State};
4use api::rest::{AppResponseData, NoData};
55use serde::Serialize;
66use time::OffsetDateTime;
77use utoipa::ToSchema;
88
9use ::bootstrap::AppState;
910use auth::errors::{ApiError, AuthBusinessError};
10use export::AppState;
1111
1212#[derive(Debug, Clone, Serialize, ToSchema)]
1313pub struct AccountDeletionDto {
Modified lib/service/webapi/src/assets.rs lib/service/webapi/src/assets.rs +2 −4 View lib/service/webapi/src/assets.rs
@@ -59,9 +59,7 @@
5959 }
6060 None => HttpResponse::ServiceUnavailable()
6161 .insert_header((CONTENT_TYPE, "text/plain; charset=utf-8"))
62 .body(
63 "view/dist has no build output; run `just identity-web-build` and rebuild app\n",
64 ),
62 .body("view/dist has no build output; run `just identity-web-build` and rebuild app\n"),
6563 }
6664}
6765
@@ -71,7 +69,7 @@
7169
7270fn api_not_found() -> HttpResponse {
7371 HttpResponse::NotFound().json(
74 export::rest::AppResponseData::<export::rest::NoData>::err(404, "unknown api route")
72 api::rest::AppResponseData::<api::rest::NoData>::err(404, "unknown api route")
7573 .with_error_code("not_found"),
7674 )
7775}
Modified lib/service/webapi/src/bootstrap.rs lib/service/webapi/src/bootstrap.rs +5 −5 View lib/service/webapi/src/bootstrap.rs
@@ -1,6 +1,6 @@
11use std::sync::Arc;
22
3use export::AppState;
3use ::bootstrap::AppState;
44
55/// Everything a request handler needs, built once at startup.
66///
@@ -11,7 +11,7 @@
1111 pub state: AppState,
1212 pub accounts: auth::Accounts,
1313 pub access: space::Access,
14 pub notifications: export::notify::Notifications,
14 pub notifications: push::notify::Notifications,
1515 pub auth: auth::AuthService,
1616 pub chat: chat::services::service::ChatService,
1717 pub issues: issues::services::service::IssueService,
@@ -28,7 +28,7 @@
2828 auth::Accounts::new(state.database.connection().clone(), state.cache.clone());
2929 let access = space::Access::new(state.database.connection().clone(), state.cache.clone());
3030 let notifications =
31 export::notify::Notifications::new(state.database.clone(), state.redis.clone());
31 push::notify::Notifications::new(state.database.clone(), state.redis.clone());
3232 let auth = auth::AuthService::new(
3333 accounts.clone(),
3434 auth::services::AuthSettings::from_config(&state.config),
@@ -89,7 +89,7 @@
8989 git_config.kenshell_endpoint
9090 )
9191 })
92 .with_request_id(export::middleware::request_id);
92 .with_request_id(api::middleware::request_id);
9393 let git = git::service::GitService::new(
9494 state.database.clone(),
9595 accounts.clone(),
@@ -127,7 +127,7 @@
127127fn build_chat_service(
128128 state: &AppState,
129129 accounts: &auth::Accounts,
130 notifications: &export::notify::Notifications,
130 notifications: &push::notify::Notifications,
131131 access: &space::Access,
132132 space: &space::services::service::SpaceService,
133133) -> chat::services::service::ChatService {
Modified lib/service/webapi/src/cleanup.rs lib/service/webapi/src/cleanup.rs +6 −6 View lib/service/webapi/src/cleanup.rs
@@ -10,9 +10,9 @@
1010
1111use ::session::Session;
1212use ::session::share::session;
13use export::http::routing::{delete, get, post};
14use export::http::{Json, Path, Router, State};
15use export::rest::{AppResponseData, NoData};
13use api::http::routing::{delete, get, post};
14use api::http::{Json, Path, Router, State};
15use api::rest::{AppResponseData, NoData};
1616use models::dir::{dir_overwrite_group, dir_overwrite_users, dirs};
1717use models::issue::issues as boards;
1818use models::repo::repos;
@@ -31,7 +31,7 @@
3131use space::services::service::SpaceService;
3232use space::share::lookup;
3333
34export::api_error! {
34api::api_error! {
3535 log: "cleanup",
3636 pub enum ApiError {
3737 BadRequest(400, "request failed validation"),
@@ -44,7 +44,7 @@
4444
4545#[derive(Clone)]
4646pub struct CleanupState {
47 pub database: std::sync::Arc<export::AppDatabase>,
47 pub database: std::sync::Arc<db::AppDatabase>,
4848 pub space: SpaceService,
4949 pub chat: chat::services::service::ChatService,
5050 pub issues: IssueService,
@@ -80,7 +80,7 @@
8080}
8181
8282pub fn router(
83 database: std::sync::Arc<export::AppDatabase>,
83 database: std::sync::Arc<db::AppDatabase>,
8484 space: SpaceService,
8585 chat: chat::services::service::ChatService,
8686 issues: IssueService,
Modified lib/service/webapi/src/lib.rs lib/service/webapi/src/lib.rs +2 −2 View lib/service/webapi/src/lib.rs
@@ -10,7 +10,7 @@
1010
1111use actix_web::http::Method;
1212use actix_web::{Scope, web};
13use export::http::{Guard, Router};
13use api::http::{Guard, Router};
1414
1515pub const MAX_REQUEST_BODY_BYTES: usize = 2 * 1024 * 1024;
1616
@@ -71,7 +71,7 @@
7171 .nest("/api/v1/internal", internal)
7272 .nest("/api/v1", public)
7373 .nest("/pages", domains::auth::pages(deps))
74 .merge(export::health::router(state.clone()))
74 .merge(::bootstrap::health::router(state.clone()))
7575 .into_scope(web::scope(""))
7676 .default_service(web::to(assets::serve))
7777}
Modified lib/service/webapi/Cargo.toml lib/service/webapi/Cargo.toml +5 −1 View lib/service/webapi/Cargo.toml
@@ -4,6 +4,11 @@
44edition.workspace = true
55
66[dependencies]
7api = { workspace = true }
8bootstrap = { workspace = true }
9cache = { workspace = true }
10db = { workspace = true }
11push = { workspace = true }
712proto = { workspace = true }
813config = { path = "../../infra/config" }
914auth = { workspace = true }
@@ -24,7 +29,6 @@
2429dir = { workspace = true }
2530models = { workspace = true }
2631sea-orm = { workspace = true }
27export = { workspace = true }
2832session = { workspace = true }
2933tokio = { workspace = true }
3034actix-web = { workspace = true }
Modified lib/share/events/data/events.json lib/share/events/data/events.json +3 −3 View lib/share/events/data/events.json
@@ -15,9 +15,9 @@
1515 "version": "1.0.0",
1616 "producer_group": "gitdata",
1717 "topic_prefix": "gitdata",
18 "event_definition": "lib/chat/src/share/events.rs (room_kind / user_kind), lib/export/src/notify.rs (notification)",
18 "event_definition": "lib/chat/src/share/events.rs (room_kind / user_kind), lib/service/push/src/notify.rs (notification)",
1919 "routing": "lib/queue/src/route.rs",
20 "emit": "lib/export/src/events.rs::enqueue <- lib/chat/src/share/realtime.rs::publish_room/publish_user (post-commit), lib/export/src/notify.rs::publish_user_event (post-commit), lib/issues/src/services/service.rs::write_event (same connection as timeline row), lib/pulls/src/services/events.rs::write_event (same connection as timeline row)",
20 "emit": "lib/export/src/events.rs::enqueue <- lib/chat/src/share/realtime.rs::publish_room/publish_user (post-commit), lib/service/push/src/protocol.rs::enqueue (post-commit), lib/issues/src/services/service.rs::write_event (same connection as timeline row), lib/pulls/src/services/events.rs::write_event (same connection as timeline row)",
2121 "publish": "lib/queue/src/relay.rs (durable outbox + relay, max 50 attempts)",
2222 "ordering_key": {
2323 "chat.room": "chat:room:{room_id}",
@@ -2517,7 +2517,7 @@
25172517 "user",
25182518 "request_id"
25192519 ],
2520 "source": "lib/export/src/notify.rs:49",
2520 "source": "lib/service/push/src/notify.rs",
25212521 "atomicity": "post-commit",
25222522 "ordering_key": "notify:user:{user_id}"
25232523 },
Modified Cargo.lock Cargo.lock +89 −45 View Cargo.lock
@@ -448,19 +448,39 @@
448448checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
449449
450450[[package]]
451name = "api"
452version = "1.0.0"
453dependencies = [
454 "actix-web",
455 "envelope",
456 "proto",
457 "sea-orm",
458 "serde",
459 "serde_json",
460 "session",
461 "time 0.3.55",
462 "tracing",
463 "utoipa 5.5.0",
464 "uuid",
465]
466
467[[package]]
451468name = "app"
452469version = "1.0.0"
453470dependencies = [
454471 "actix-web",
455472 "actor",
456473 "anyhow",
474 "api",
457475 "auth",
476 "bootstrap",
477 "cache",
458478 "chat",
459479 "clap",
460480 "config 1.0.0",
481 "db",
461482 "deletion",
462483 "events",
463 "export",
464484 "internal",
465485 "models",
466486 "oltp",
@@ -811,6 +831,7 @@
811831 "actix-web",
812832 "aes-gcm 0.11.1",
813833 "anyhow",
834 "api",
814835 "argon2",
815836 "async-trait",
816837 "base64 0.23.1",
@@ -823,7 +844,6 @@
823844 "email",
824845 "envelope",
825846 "events",
826 "export",
827847 "figment",
828848 "futures-util",
829849 "hmac 0.12.1",
@@ -1123,6 +1143,23 @@
11231143]
11241144
11251145[[package]]
1146name = "bootstrap"
1147version = "1.0.0"
1148dependencies = [
1149 "actix-web",
1150 "api",
1151 "cache",
1152 "config 1.0.0",
1153 "db",
1154 "email",
1155 "events",
1156 "queue",
1157 "redis",
1158 "sea-orm",
1159 "storage",
1160]
1161
1162[[package]]
11261163name = "borsh"
11271164version = "1.8.1"
11281165source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1311,16 +1348,18 @@
13111348version = "1.0.0"
13121349dependencies = [
13131350 "actix-web",
1351 "api",
13141352 "async-trait",
13151353 "auth",
13161354 "base64 0.23.1",
13171355 "bytes",
1356 "cache",
13181357 "config 1.0.0",
1358 "db",
13191359 "dir",
13201360 "email",
13211361 "encoding_rs",
13221362 "events",
1323 "export",
13241363 "futures",
13251364 "hmac 0.13.0",
13261365 "http 0.2.12",
@@ -1329,9 +1368,11 @@
13291368 "internal",
13301369 "livekit-api",
13311370 "livekit-protocol",
1371 "media",
13321372 "models",
13331373 "oltp",
13341374 "proto",
1375 "push",
13351376 "queue",
13361377 "rand 0.8.8",
13371378 "redis",
@@ -1909,9 +1950,12 @@
19091950version = "1.0.0"
19101951dependencies = [
19111952 "async-trait",
1953 "config 1.0.0",
1954 "models",
19121955 "sea-orm",
19131956 "sqlparser",
19141957 "thiserror 2.0.21",
1958 "time 0.3.55",
19151959 "tracing",
19161960]
19171961
@@ -1919,9 +1963,10 @@
19191963name = "deletion"
19201964version = "1.0.0"
19211965dependencies = [
1966 "api",
19221967 "auth",
1968 "bootstrap",
19231969 "config 1.0.0",
1924 "export",
19251970 "models",
19261971 "proto",
19271972 "sea-orm",
@@ -2410,40 +2455,6 @@
24102455 "tokio-util",
24112456 "tonic",
24122457 "tracing",
2413 "uuid",
2414]
2415
2416[[package]]
2417name = "export"
2418version = "1.0.0"
2419dependencies = [
2420 "actix-web",
2421 "async-trait",
2422 "bytes",
2423 "cache",
2424 "config 1.0.0",
2425 "db",
2426 "email",
2427 "envelope",
2428 "events",
2429 "imaging",
2430 "models",
2431 "oltp",
2432 "prost-types 0.14.4",
2433 "proto",
2434 "queue",
2435 "redis",
2436 "sea-orm",
2437 "serde",
2438 "serde_json",
2439 "session",
2440 "sha2 0.11.1",
2441 "storage",
2442 "thiserror 2.0.21",
2443 "time 0.3.55",
2444 "tokio",
2445 "tracing",
2446 "utoipa 5.5.0",
24472458 "uuid",
24482459]
24492460
@@ -2796,13 +2807,15 @@
27962807version = "1.0.0"
27972808dependencies = [
27982809 "actix-web",
2810 "api",
27992811 "async-trait",
28002812 "auth",
2813 "bootstrap",
28012814 "bytes",
28022815 "cache",
28032816 "config 1.0.0",
2817 "db",
28042818 "dir",
2805 "export",
28062819 "flate2",
28072820 "futures",
28082821 "globset",
@@ -3682,18 +3695,21 @@
36823695version = "1.0.0"
36833696dependencies = [
36843697 "actix-web",
3698 "api",
36853699 "async-trait",
36863700 "auth",
36873701 "bytes",
3702 "cache",
36883703 "config 1.0.0",
3704 "db",
36893705 "dir",
36903706 "email",
36913707 "events",
3692 "export",
36933708 "futures",
36943709 "http 0.2.12",
36953710 "i18n",
36963711 "models",
3712 "push",
36973713 "queue",
36983714 "sea-orm",
36993715 "serde",
@@ -4340,6 +4356,17 @@
43404356checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
43414357
43424358[[package]]
4359name = "media"
4360version = "1.0.0"
4361dependencies = [
4362 "cache",
4363 "imaging",
4364 "serde_json",
4365 "storage",
4366 "tracing",
4367]
4368
4369[[package]]
43434370name = "memchr"
43444371version = "2.8.3"
43454372source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5763,10 +5790,12 @@
57635790version = "1.0.0"
57645791dependencies = [
57655792 "actix-web",
5793 "api",
57665794 "auth",
5795 "cache",
57675796 "config 1.0.0",
5797 "db",
57685798 "events",
5769 "export",
57705799 "git",
57715800 "globset",
57725801 "issues",
@@ -5787,17 +5816,23 @@
57875816name = "push"
57885817version = "1.0.0"
57895818dependencies = [
5819 "api",
57905820 "auth",
57915821 "base64 0.23.1",
5822 "bootstrap",
5823 "cache",
57925824 "config 1.0.0",
5793 "export",
5825 "db",
5826 "events",
57945827 "http 1.5.0",
57955828 "models",
57965829 "oltp",
5830 "queue",
57975831 "reqwest 0.12.28",
57985832 "sea-orm",
57995833 "serde",
58005834 "serde_json",
5835 "time 0.3.55",
58015836 "tokio",
58025837 "tokio-util",
58035838 "tracing",
@@ -7297,6 +7332,7 @@
72977332version = "1.0.0"
72987333dependencies = [
72997334 "actix-web",
7335 "api",
73007336 "async-trait",
73017337 "auth",
73027338 "base64 0.23.1",
@@ -7308,13 +7344,14 @@
73087344 "dir",
73097345 "envelope",
73107346 "events",
7311 "export",
73127347 "i18n",
73137348 "imaging",
73147349 "internal",
7350 "media",
73157351 "models",
73167352 "prost-types 0.14.4",
73177353 "proto",
7354 "push",
73187355 "rand 0.8.8",
73197356 "sea-orm",
73207357 "serde",
@@ -8455,15 +8492,18 @@
84558492version = "1.0.0"
84568493dependencies = [
84578494 "actix-web",
8495 "api",
84588496 "async-trait",
84598497 "auth",
84608498 "base64 0.23.1",
8499 "cache",
84618500 "chrono",
84628501 "config 1.0.0",
8463 "export",
8502 "db",
84648503 "futures",
84658504 "i18n",
84668505 "imaging",
8506 "media",
84678507 "models",
84688508 "rand 0.8.8",
84698509 "redis",
@@ -8814,13 +8854,16 @@
88148854dependencies = [
88158855 "actix-cors",
88168856 "actix-web",
8857 "api",
88178858 "auth",
88188859 "base64 0.23.1",
8860 "bootstrap",
8861 "cache",
88198862 "chat",
88208863 "config 1.0.0",
8864 "db",
88218865 "deletion",
88228866 "dir",
8823 "export",
88248867 "git",
88258868 "i18n",
88268869 "issues",
@@ -8829,6 +8872,7 @@
88298872 "proto",
88308873 "pulldown-cmark",
88318874 "pulls",
8875 "push",
88328876 "redis",
88338877 "sea-orm",
88348878 "serde",
Modified Cargo.toml Cargo.toml +3 −1 View Cargo.toml
@@ -16,13 +16,14 @@
1616
1717
1818[workspace.dependencies]
19api = { path = "lib/infra/api" }
1920auth = { path = "lib/service/auth" }
21bootstrap = { path = "lib/infra/bootstrap" }
2022cache = { path = "lib/infra/cache" }
2123chat = { path = "lib/service/chat" }
2224config = { path = "lib/infra/config" }
2325deletion = { path = "lib/service/deletion" }
2426dir = { path = "lib/service/dir" }
25export = { path = "lib/share/export" }
2627models = { path = "lib/share/models" }
2728push = { path = "lib/service/push" }
2829storage = { path = "lib/infra/storage" }
@@ -32,6 +33,7 @@
3233git = { path = "lib/service/git" }
3334i18n = { path = "lib/share/i18n" }
3435imaging = { path = "lib/tools/imaging" }
36media = { path = "lib/tools/media" }
3537crypt = { path = "lib/infra/crypt" }
3638db = { path = "lib/infra/db" }
3739email = { path = "lib/share/email" }