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 CreateTemplateParams {
|
||||
pub key: String,
|
||||
pub notification_type: NotificationType,
|
||||
@@ -22,7 +22,7 @@ pub struct CreateTemplateParams {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct UpdateTemplateParams {
|
||||
pub subject_template: Option<String>,
|
||||
pub title_template: Option<String>,
|
||||
@@ -115,11 +115,13 @@ impl NotificationService {
|
||||
let id = Uuid::now_v7();
|
||||
let now = chrono::Utc::now();
|
||||
|
||||
sqlx::query(
|
||||
sqlx::query_as::<_, NotificationTemplate>(
|
||||
"INSERT INTO notification_template \
|
||||
(id, key, notification_type, channel, locale, subject_template, title_template, \
|
||||
body_template, action_text_template, enabled, created_by, created_at, updated_at) \
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $12)",
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $12) \
|
||||
RETURNING id, key, notification_type, channel, locale, subject_template, title_template, \
|
||||
body_template, action_text_template, enabled, created_by, created_at, updated_at",
|
||||
)
|
||||
.bind(id)
|
||||
.bind(¶ms.key)
|
||||
@@ -133,15 +135,9 @@ impl NotificationService {
|
||||
.bind(params.enabled)
|
||||
.bind(user_id)
|
||||
.bind(now)
|
||||
.execute(self.ctx.db.writer())
|
||||
.fetch_one(self.ctx.db.writer())
|
||||
.await
|
||||
.map_err(AppError::Database)?;
|
||||
|
||||
NotificationTemplate::find_by_id(self.ctx.db.reader(), id)
|
||||
.await?
|
||||
.ok_or(AppError::InternalServerError(
|
||||
"failed to fetch created template".into(),
|
||||
))
|
||||
.map_err(AppError::Database)
|
||||
}
|
||||
|
||||
pub async fn update_template(
|
||||
|
||||
Reference in New Issue
Block a user