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:
+14
-16
@@ -34,21 +34,20 @@ impl NotificationService {
|
||||
let user_id = session.user().ok_or(AppError::Unauthorized)?;
|
||||
let now = Utc::now();
|
||||
|
||||
sqlx::query(
|
||||
sqlx::query_as::<_, Notification>(
|
||||
"UPDATE notification SET read_at = $1, updated_at = $2 \
|
||||
WHERE id = $3 AND user_id = $4 AND deleted_at IS NULL",
|
||||
WHERE id = $3 AND user_id = $4 AND deleted_at IS NULL \
|
||||
RETURNING id, user_id, notification_type, target_type, target_id, title, body, \
|
||||
action_url, action_text, read_at, dismissed_at, created_at, updated_at, deleted_at",
|
||||
)
|
||||
.bind(now)
|
||||
.bind(now)
|
||||
.bind(notification_id)
|
||||
.bind(user_id)
|
||||
.execute(self.ctx.db.writer())
|
||||
.fetch_optional(self.ctx.db.writer())
|
||||
.await
|
||||
.map_err(AppError::Database)?;
|
||||
|
||||
Notification::find_by_id(self.ctx.db.reader(), notification_id, user_id)
|
||||
.await?
|
||||
.ok_or(AppError::NotFound("notification not found".into()))
|
||||
.map_err(AppError::Database)?
|
||||
.ok_or(AppError::NotFound("notification not found".into()))
|
||||
}
|
||||
|
||||
pub async fn mark_all_as_read(&self, session: &Session) -> Result<i64, AppError> {
|
||||
@@ -77,21 +76,20 @@ impl NotificationService {
|
||||
let user_id = session.user().ok_or(AppError::Unauthorized)?;
|
||||
let now = Utc::now();
|
||||
|
||||
sqlx::query(
|
||||
sqlx::query_as::<_, Notification>(
|
||||
"UPDATE notification SET dismissed_at = $1, updated_at = $2 \
|
||||
WHERE id = $3 AND user_id = $4 AND deleted_at IS NULL",
|
||||
WHERE id = $3 AND user_id = $4 AND deleted_at IS NULL \
|
||||
RETURNING id, user_id, notification_type, target_type, target_id, title, body, \
|
||||
action_url, action_text, read_at, dismissed_at, created_at, updated_at, deleted_at",
|
||||
)
|
||||
.bind(now)
|
||||
.bind(now)
|
||||
.bind(notification_id)
|
||||
.bind(user_id)
|
||||
.execute(self.ctx.db.writer())
|
||||
.fetch_optional(self.ctx.db.writer())
|
||||
.await
|
||||
.map_err(AppError::Database)?;
|
||||
|
||||
Notification::find_by_id(self.ctx.db.reader(), notification_id, user_id)
|
||||
.await?
|
||||
.ok_or(AppError::NotFound("notification not found".into()))
|
||||
.map_err(AppError::Database)?
|
||||
.ok_or(AppError::NotFound("notification not found".into()))
|
||||
}
|
||||
|
||||
pub async fn delete_notification(
|
||||
|
||||
Reference in New Issue
Block a user