9eb77ab98b
- 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
106 lines
3.5 KiB
Rust
106 lines
3.5 KiB
Rust
use crate::models::base_info::UserBaseInfo;
|
|
use crate::models::common::{
|
|
ChannelKind, ChannelType, ForumLayout, ForumSortOrder, JsonValue, Visibility,
|
|
};
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow, utoipa::ToSchema)]
|
|
pub struct Channel {
|
|
pub id: Uuid,
|
|
pub workspace_id: Uuid,
|
|
pub repo_id: Option<Uuid>,
|
|
pub category_id: Option<Uuid>,
|
|
pub created_by: Uuid,
|
|
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 default_auto_archive_duration: Option<i32>,
|
|
pub default_reaction_emoji: Option<String>,
|
|
pub default_sort_order: Option<ForumSortOrder>,
|
|
pub default_forum_layout: Option<ForumLayout>,
|
|
pub require_tag: Option<bool>,
|
|
pub available_tags: Option<JsonValue>,
|
|
pub default_thread_rate_limit: Option<i32>,
|
|
pub rate_limit_per_user: Option<i32>,
|
|
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>>,
|
|
}
|
|
|
|
#[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,
|
|
}
|
|
}
|
|
}
|