refactor(models): update data models and remove deprecated IM entities
- Update channel, notification, PR, repo, user, workspace models - Remove deleted IM models: articles, channel follows, message attachments/bookmarks/drafts/edit history/embeds/mentions/pins/ polls/reactions/threads, saved messages, thread read states - Add new PR models: review requests, templates - Add repo release assets model - Add base_info module for API detail responses
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::models::base_info::UserBaseInfo;
|
||||
use crate::models::common::{
|
||||
ChannelKind, ChannelType, ForumLayout, ForumSortOrder, JsonValue, Visibility,
|
||||
};
|
||||
@@ -5,7 +6,7 @@ use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow, utoipa::ToSchema)]
|
||||
pub struct Channel {
|
||||
pub id: Uuid,
|
||||
pub workspace_id: Uuid,
|
||||
@@ -41,3 +42,64 @@ pub struct Channel {
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct ChannelDetail {
|
||||
pub id: Uuid,
|
||||
pub workspace_id: Uuid,
|
||||
pub repo_id: Option<Uuid>,
|
||||
pub category_id: Option<Uuid>,
|
||||
pub creator: UserBaseInfo,
|
||||
pub name: String,
|
||||
pub topic: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub channel_type: ChannelType,
|
||||
pub channel_kind: ChannelKind,
|
||||
pub visibility: Visibility,
|
||||
pub position: Option<i32>,
|
||||
pub nsfw: bool,
|
||||
pub archived: bool,
|
||||
pub read_only: bool,
|
||||
pub bitrate: Option<i32>,
|
||||
pub user_limit: Option<i32>,
|
||||
pub rtc_region: Option<String>,
|
||||
pub parent_channel_id: Option<Uuid>,
|
||||
pub last_message_id: Option<Uuid>,
|
||||
pub last_message_at: Option<DateTime<Utc>>,
|
||||
pub archived_at: Option<DateTime<Utc>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
impl Channel {
|
||||
pub fn into_detail(self, creator: UserBaseInfo) -> ChannelDetail {
|
||||
ChannelDetail {
|
||||
id: self.id,
|
||||
workspace_id: self.workspace_id,
|
||||
repo_id: self.repo_id,
|
||||
category_id: self.category_id,
|
||||
creator,
|
||||
name: self.name,
|
||||
topic: self.topic,
|
||||
description: self.description,
|
||||
channel_type: self.channel_type,
|
||||
channel_kind: self.channel_kind,
|
||||
visibility: self.visibility,
|
||||
position: self.position,
|
||||
nsfw: self.nsfw,
|
||||
archived: self.archived,
|
||||
read_only: self.read_only,
|
||||
bitrate: self.bitrate,
|
||||
user_limit: self.user_limit,
|
||||
rtc_region: self.rtc_region,
|
||||
parent_channel_id: self.parent_channel_id,
|
||||
last_message_id: self.last_message_id,
|
||||
last_message_at: self.last_message_at,
|
||||
archived_at: self.archived_at,
|
||||
created_at: self.created_at,
|
||||
updated_at: self.updated_at,
|
||||
deleted_at: self.deleted_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user