feat(api): expand API endpoints for repo, PR, user, workspace management

- Add git operation endpoints: archive, compare branches, diff, tree,
  repository extras
- Add repo endpoints: contributors, delete fork, get branch/commit
  status/deploy key/invitation/member/release/tag/webhook, topics,
  release assets, webhook deliveries/retry
- Add PR endpoints: review requests, templates
- Add user endpoints: block/unblock, follow/unfollow, presence,
  personal access tokens, account restore
- Add workspace endpoints: billing history, approvals, domains,
  integrations, invitations, members, webhooks, restore
- Add internal API, notification API, IM API modules
- Update route configuration and OpenAPI spec
This commit is contained in:
zhenyi
2026-06-10 18:49:27 +08:00
parent 4586b79cb8
commit cec6dce955
161 changed files with 7522 additions and 349 deletions
+63
View File
@@ -0,0 +1,63 @@
use actix_web::{HttpResponse, web};
use serde::Deserialize;
use utoipa::IntoParams;
use crate::api::response::{ApiErrorResponse, ApiResponse};
use crate::error::AppError;
use crate::models::common::{DeviceType, PresenceStatus};
use crate::models::users::UserPresence;
use crate::service::AppService;
use crate::service::user::social::UpdatePresenceParams;
use crate::session::Session;
#[derive(Debug, Deserialize, IntoParams, utoipa::ToSchema)]
pub struct UpdatePresenceBody {
/// New presence status
pub status: PresenceStatus,
/// Optional custom status text (e.g., "In a meeting")
pub custom_status_text: Option<String>,
/// Optional custom status emoji (e.g., ":palm_tree:")
pub custom_status_emoji: Option<String>,
/// Device type the user is currently using
pub device_type: Option<DeviceType>,
/// IP address of the current session
pub ip_address: Option<String>,
}
/// Update user presence
///
/// Updates the presence status for the authenticated user.
/// Supports custom status text, emoji, device type, and IP address.
/// Creates a new presence record if one does not exist.
/// Requires authentication.
#[utoipa::path(
put,
path = "/api/v1/user/presence",
tag = "User",
operation_id = "userUpdatePresence",
params(UpdatePresenceBody),
responses(
(status = 200, description = "Presence updated successfully.", body = ApiResponse<UserPresence>),
(status = 400, description = "Invalid request body", body = ApiErrorResponse),
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
(status = 500, description = "Internal server error", body = ApiErrorResponse),
),
security(
("session_cookie" = [])
)
)]
pub async fn update_presence(
service: web::Data<AppService>,
session: Session,
body: web::Json<UpdatePresenceBody>,
) -> Result<HttpResponse, AppError> {
let params = UpdatePresenceParams {
status: body.status,
custom_status_text: body.custom_status_text.clone(),
custom_status_emoji: body.custom_status_emoji.clone(),
device_type: body.device_type,
ip_address: body.ip_address.clone(),
};
let presence = service.user.user_presence_update(&session, params).await?;
Ok(HttpResponse::Ok().json(ApiResponse::new(presence)))
}