feat(service): expand service layer with new domain operations
- 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
This commit is contained in:
@@ -9,7 +9,7 @@ use uuid::Uuid;
|
||||
|
||||
use super::util::clamp_limit_offset;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct CreateSubscriptionParams {
|
||||
pub workspace_id: Option<Uuid>,
|
||||
pub repo_id: Option<Uuid>,
|
||||
@@ -20,7 +20,7 @@ pub struct CreateSubscriptionParams {
|
||||
pub level: SubscriptionLevel,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct UpdateSubscriptionParams {
|
||||
pub event_types: Option<Vec<EventType>>,
|
||||
pub channels: Option<Vec<String>>,
|
||||
@@ -89,10 +89,12 @@ impl NotificationService {
|
||||
let id = Uuid::now_v7();
|
||||
let now = Utc::now();
|
||||
|
||||
sqlx::query(
|
||||
sqlx::query_as::<_, NotificationSubscription>(
|
||||
"INSERT INTO notification_subscription \
|
||||
(id, user_id, workspace_id, repo_id, target_type, target_id, event_types, channels, level, muted, muted_until, created_at, updated_at) \
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, false, NULL, $10, $10)",
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, false, NULL, $10, $10) \
|
||||
RETURNING id, user_id, workspace_id, repo_id, target_type, target_id, event_types, \
|
||||
channels, level, muted, muted_until, created_at, updated_at",
|
||||
)
|
||||
.bind(id)
|
||||
.bind(user_id)
|
||||
@@ -104,15 +106,9 @@ impl NotificationService {
|
||||
.bind(¶ms.channels)
|
||||
.bind(params.level.as_str())
|
||||
.bind(now)
|
||||
.execute(self.ctx.db.writer())
|
||||
.fetch_one(self.ctx.db.writer())
|
||||
.await
|
||||
.map_err(AppError::Database)?;
|
||||
|
||||
NotificationSubscription::find_by_id(self.ctx.db.reader(), id, user_id)
|
||||
.await?
|
||||
.ok_or(AppError::InternalServerError(
|
||||
"failed to fetch created subscription".into(),
|
||||
))
|
||||
.map_err(AppError::Database)
|
||||
}
|
||||
|
||||
pub async fn update_subscription(
|
||||
|
||||
Reference in New Issue
Block a user