420dedbc1e
- Add IM service modules: audit, channel roles, custom emojis, forum tags, integrations, invitations, repo links, slash commands, stages, voice, webhooks - Add PR service modules: review requests, templates - Add repo service modules: contributors, release assets, git extras (archive, branch rename, commit extras, diff/merge, tag, tree) - Add user service: social (follow/block) - Add internal auth service - Update existing service modules with expanded functionality - Remove deleted IM modules: articles, delivery trace, drafts, follows, messages, polls, presence, reactions, threads
128 lines
2.8 KiB
Rust
128 lines
2.8 KiB
Rust
use std::sync::Arc;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::cache::AppCache;
|
|
use crate::cache::redis::AppRedis;
|
|
use crate::config::AppConfig;
|
|
use crate::etcd::EtcdRegistry;
|
|
use crate::models::db::AppDatabase;
|
|
use crate::queue::NatsQueue;
|
|
use crate::service::im::events::ImEventBus;
|
|
use crate::storage::s3::AppS3Storage;
|
|
|
|
pub mod context;
|
|
pub mod util;
|
|
|
|
pub mod auth;
|
|
pub mod im;
|
|
pub mod internal_auth;
|
|
pub mod issues;
|
|
pub mod notify;
|
|
pub mod pr;
|
|
pub mod repo;
|
|
pub mod user;
|
|
pub mod wiki;
|
|
pub mod workspace;
|
|
|
|
pub use context::ServiceContext;
|
|
|
|
#[derive(Clone)]
|
|
pub struct AuthService {
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct UserService {
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct WorkspaceService {
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct RepoService {
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct IssueService {
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct PrService {
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct NotificationService {
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
pub use im::ImService;
|
|
pub use internal_auth::InternalAuthService;
|
|
|
|
#[derive(Clone)]
|
|
pub struct AppService {
|
|
pub auth: AuthService,
|
|
pub user: UserService,
|
|
pub workspace: WorkspaceService,
|
|
pub repo: RepoService,
|
|
pub issue: IssueService,
|
|
pub pr: PrService,
|
|
pub notify: NotificationService,
|
|
pub im: ImService,
|
|
pub internal_auth: InternalAuthService,
|
|
pub ctx: Arc<ServiceContext>,
|
|
}
|
|
|
|
impl AppService {
|
|
#[allow(clippy::too_many_arguments)]
|
|
pub fn new(
|
|
version: String,
|
|
db: AppDatabase,
|
|
redis: AppRedis,
|
|
cache: Arc<AppCache>,
|
|
config: AppConfig,
|
|
storage: AppS3Storage,
|
|
registry: Arc<EtcdRegistry>,
|
|
nats: Arc<NatsQueue>,
|
|
) -> Self {
|
|
let internal_auth = InternalAuthService::new(redis.clone());
|
|
|
|
let ctx = Arc::new(ServiceContext {
|
|
version,
|
|
db,
|
|
redis,
|
|
cache,
|
|
config,
|
|
storage,
|
|
registry,
|
|
nats,
|
|
im_events: Arc::new(ImEventBus::default()),
|
|
});
|
|
|
|
Self {
|
|
auth: AuthService { ctx: ctx.clone() },
|
|
user: UserService { ctx: ctx.clone() },
|
|
workspace: WorkspaceService { ctx: ctx.clone() },
|
|
repo: RepoService { ctx: ctx.clone() },
|
|
issue: IssueService { ctx: ctx.clone() },
|
|
pr: PrService { ctx: ctx.clone() },
|
|
notify: NotificationService { ctx: ctx.clone() },
|
|
im: ImService { ctx: ctx.clone() },
|
|
internal_auth,
|
|
ctx,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Clone, Debug, utoipa::ToSchema)]
|
|
pub struct Pager {
|
|
pub page: i64,
|
|
pub per_page: i64,
|
|
}
|