Skip to main content

max / makenotwork

4.1 KB · 145 lines History Blame Raw
1 //! Media, build pipeline, mailing list, custom domain, import, and S3 key models.
2
3 use chrono::{DateTime, Utc};
4 use serde::Serialize;
5 use sqlx::FromRow;
6
7 use super::super::id_types::{
8 BuildConfigId, BuildId, CustomDomainId, GitRepoId, ImportJobId, MailingListId,
9 MailingListSubscriberId, MediaFileId, OtaReleaseId, ProjectId, SyncAppId, UserId,
10 };
11 use super::super::validated_types::Slug;
12
13 // ── Media Library models ──
14
15 /// A user-scoped media file for embedding in markdown content.
16 #[derive(Debug, Clone, FromRow)]
17 pub struct DbMediaFile {
18 pub id: MediaFileId,
19 pub user_id: UserId,
20 pub folder: String,
21 pub filename: String,
22 pub s3_key: String,
23 pub content_type: String,
24 pub file_size_bytes: i64,
25 pub media_type: String,
26 pub scan_status: String,
27 pub created_at: DateTime<Utc>,
28 }
29
30 // ── Build Pipeline models ──
31
32 /// A build pipeline configuration linking a sync app to a git repo.
33 #[derive(Debug, Clone, FromRow)]
34 pub struct DbBuildConfig {
35 pub id: BuildConfigId,
36 pub app_id: SyncAppId,
37 pub repo_id: GitRepoId,
38 pub build_command: String,
39 pub artifact_path: String,
40 pub signing_key_path: String,
41 pub targets: Vec<String>,
42 pub enabled: bool,
43 pub created_at: DateTime<Utc>,
44 pub updated_at: DateTime<Utc>,
45 }
46
47 /// A single build execution triggered by a tag or manual action.
48 #[derive(Debug, Clone, FromRow)]
49 pub struct DbBuild {
50 pub id: BuildId,
51 pub config_id: BuildConfigId,
52 pub app_id: SyncAppId,
53 pub version: String,
54 pub tag: String,
55 pub status: super::super::BuildStatus,
56 pub started_at: Option<DateTime<Utc>>,
57 pub finished_at: Option<DateTime<Utc>>,
58 pub log: String,
59 pub error_message: Option<String>,
60 pub release_id: Option<OtaReleaseId>,
61 pub triggered_by: String,
62 pub created_at: DateTime<Utc>,
63 }
64
65 // ── Mailing List models ──
66
67 /// A per-project mailing list (content, devlog, or patches).
68 #[derive(Debug, Clone, FromRow)]
69 pub struct DbMailingList {
70 pub id: MailingListId,
71 pub project_id: ProjectId,
72 pub list_type: super::super::MailingListType,
73 pub name: String,
74 pub description: Option<String>,
75 pub created_at: DateTime<Utc>,
76 }
77
78 /// A subscription to a mailing list.
79 #[derive(Debug, Clone, FromRow)]
80 pub struct DbMailingListSubscriber {
81 pub id: MailingListSubscriberId,
82 pub list_id: MailingListId,
83 pub user_id: UserId,
84 pub subscribed_at: DateTime<Utc>,
85 }
86
87 // ── Custom Domain models ──
88
89 /// A custom domain configured for a creator's profile.
90 #[derive(Debug, Clone, FromRow)]
91 pub struct DbCustomDomain {
92 pub id: CustomDomainId,
93 pub user_id: UserId,
94 pub domain: String,
95 pub verified: bool,
96 pub verification_token: String,
97 pub created_at: DateTime<Utc>,
98 pub verified_at: Option<DateTime<Utc>>,
99 }
100
101 // ── Import Job models ──
102
103 /// A data import job (CSV/JSON from external platforms).
104 #[derive(Debug, Clone, FromRow, Serialize)]
105 pub struct DbImportJob {
106 pub id: ImportJobId,
107 pub user_id: UserId,
108 pub project_id: ProjectId,
109 pub source: super::super::ImportSource,
110 pub status: super::super::ImportJobStatus,
111 pub total_rows: i32,
112 pub processed_rows: i32,
113 pub created_rows: i32,
114 pub skipped_rows: i32,
115 pub error_log: Option<String>,
116 pub created_at: DateTime<Utc>,
117 pub completed_at: Option<DateTime<Utc>>,
118 }
119
120 /// An item's S3 keys (and DB-known file sizes) for content export.
121 #[derive(Debug, Clone, FromRow)]
122 pub struct ItemS3KeyRow {
123 pub title: String,
124 pub project_id: super::super::ProjectId,
125 pub project_slug: Slug,
126 pub audio_s3_key: Option<String>,
127 pub cover_s3_key: Option<String>,
128 pub video_s3_key: Option<String>,
129 pub audio_file_size_bytes: Option<i64>,
130 pub cover_file_size_bytes: Option<i64>,
131 pub video_file_size_bytes: Option<i64>,
132 }
133
134 /// A version's S3 key (and DB-known file size) for content export.
135 #[derive(Debug, Clone, FromRow)]
136 pub struct VersionS3KeyRow {
137 pub s3_key: Option<String>,
138 pub file_name: Option<String>,
139 pub version_number: String,
140 pub item_title: String,
141 pub project_id: super::super::ProjectId,
142 pub project_slug: Slug,
143 pub file_size_bytes: Option<i64>,
144 }
145