| 1 |
|
| 2 |
|
| 3 |
use chrono::{DateTime, Utc}; |
| 4 |
use serde::Serialize; |
| 5 |
use sqlx::FromRow; |
| 6 |
|
| 7 |
use super::super::enums::CreatorTier; |
| 8 |
use super::super::id_types::{ |
| 9 |
GitRepoId, IssueCommentId, IssueId, IssueLabelId, OAuthCodeId, OAuthRefreshTokenId, SshKeyId, |
| 10 |
SyncAppId, UserId, |
| 11 |
}; |
| 12 |
use super::super::validated_types::{Email, Username}; |
| 13 |
use crate::currency::SettlementCurrency; |
| 14 |
|
| 15 |
|
| 16 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 17 |
pub struct DbSshKey { |
| 18 |
|
| 19 |
pub id: SshKeyId, |
| 20 |
|
| 21 |
pub user_id: UserId, |
| 22 |
|
| 23 |
pub public_key: String, |
| 24 |
|
| 25 |
pub fingerprint: String, |
| 26 |
|
| 27 |
pub label: String, |
| 28 |
|
| 29 |
pub created_at: DateTime<Utc>, |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
#[derive(Debug, Clone, FromRow)] |
| 34 |
pub struct SshKeyWithUsername { |
| 35 |
|
| 36 |
pub id: SshKeyId, |
| 37 |
|
| 38 |
pub public_key: String, |
| 39 |
|
| 40 |
pub username: String, |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 45 |
pub struct SshKeyUserLookup { |
| 46 |
pub user_id: UserId, |
| 47 |
pub username: Username, |
| 48 |
pub display_name: Option<String>, |
| 49 |
pub email: Email, |
| 50 |
pub creator_tier: Option<CreatorTier>, |
| 51 |
pub can_create_projects: bool, |
| 52 |
pub suspended: bool, |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
pub settlement_currency: SettlementCurrency, |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
pub console_theme: Option<String>, |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
#[derive(Debug, Clone, FromRow)] |
| 68 |
#[allow(dead_code)] |
| 69 |
pub struct DbOAuthCode { |
| 70 |
pub id: OAuthCodeId, |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
pub code: String, |
| 75 |
pub app_id: SyncAppId, |
| 76 |
pub user_id: UserId, |
| 77 |
pub code_challenge: String, |
| 78 |
pub code_challenge_method: String, |
| 79 |
pub redirect_uri: String, |
| 80 |
|
| 81 |
pub scope: String, |
| 82 |
pub expires_at: DateTime<Utc>, |
| 83 |
pub used_at: Option<DateTime<Utc>>, |
| 84 |
pub created_at: DateTime<Utc>, |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
#[derive(Debug, Clone, FromRow)] |
| 90 |
#[allow(dead_code)] |
| 91 |
pub struct DbOAuthRefreshToken { |
| 92 |
pub id: OAuthRefreshTokenId, |
| 93 |
pub token_hash: String, |
| 94 |
pub app_id: SyncAppId, |
| 95 |
pub user_id: UserId, |
| 96 |
pub key: String, |
| 97 |
pub scope: String, |
| 98 |
|
| 99 |
pub chain_id: uuid::Uuid, |
| 100 |
pub expires_at: DateTime<Utc>, |
| 101 |
pub used_at: Option<DateTime<Utc>>, |
| 102 |
pub revoked_at: Option<DateTime<Utc>>, |
| 103 |
|
| 104 |
|
| 105 |
pub issued_after: DateTime<Utc>, |
| 106 |
pub created_at: DateTime<Utc>, |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 113 |
pub struct DbIssue { |
| 114 |
pub id: IssueId, |
| 115 |
pub repo_id: GitRepoId, |
| 116 |
pub number: i32, |
| 117 |
pub author_user_id: UserId, |
| 118 |
pub title: String, |
| 119 |
pub body_markdown: String, |
| 120 |
pub body_html: String, |
| 121 |
pub status: super::super::IssueStatus, |
| 122 |
pub created_at: DateTime<Utc>, |
| 123 |
pub updated_at: DateTime<Utc>, |
| 124 |
|
| 125 |
|
| 126 |
pub mt_thread_id: Option<uuid::Uuid>, |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
#[derive(Debug, Clone, FromRow)] |
| 131 |
pub struct DbIssueWithMeta { |
| 132 |
pub id: IssueId, |
| 133 |
pub repo_id: GitRepoId, |
| 134 |
pub number: i32, |
| 135 |
pub author_user_id: UserId, |
| 136 |
pub title: String, |
| 137 |
pub status: super::super::IssueStatus, |
| 138 |
pub created_at: DateTime<Utc>, |
| 139 |
pub updated_at: DateTime<Utc>, |
| 140 |
pub author_username: String, |
| 141 |
pub comment_count: i64, |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 146 |
pub struct DbIssueComment { |
| 147 |
pub id: IssueCommentId, |
| 148 |
pub issue_id: IssueId, |
| 149 |
pub author_user_id: UserId, |
| 150 |
pub body_markdown: String, |
| 151 |
pub body_html: String, |
| 152 |
pub created_at: DateTime<Utc>, |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
#[derive(Debug, Clone, FromRow)] |
| 157 |
pub struct DbIssueCommentWithAuthor { |
| 158 |
pub id: IssueCommentId, |
| 159 |
pub issue_id: IssueId, |
| 160 |
pub author_user_id: UserId, |
| 161 |
pub body_markdown: String, |
| 162 |
pub body_html: String, |
| 163 |
pub created_at: DateTime<Utc>, |
| 164 |
pub author_username: String, |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
#[derive(Debug, Clone, FromRow, Serialize)] |
| 169 |
pub struct DbIssueLabel { |
| 170 |
pub id: IssueLabelId, |
| 171 |
pub repo_id: GitRepoId, |
| 172 |
pub name: String, |
| 173 |
pub color: String, |
| 174 |
} |
| 175 |
|