Skip to main content

max / makenotwork

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