//! SSH key, OAuth code, issue, and issue comment models. use chrono::{DateTime, Utc}; use serde::Serialize; use sqlx::FromRow; use super::super::enums::CreatorTier; use super::super::id_types::*; use super::super::validated_types::*; /// An SSH public key registered by a user for git push access. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbSshKey { /// Database primary key. pub id: SshKeyId, /// User who owns this key. pub user_id: UserId, /// The SSH public key data (e.g., "ssh-ed25519 AAAA..."). pub public_key: String, /// SHA-256 fingerprint (e.g., "SHA256:abc..."). pub fingerprint: String, /// Human-readable label for the key (e.g., "laptop"). pub label: String, /// When the key was registered. pub created_at: DateTime, } /// An SSH key joined with its owner's username, for authorized_keys rebuild. #[derive(Debug, Clone, FromRow)] pub struct SshKeyWithUsername { /// SSH key primary key. pub id: SshKeyId, /// The SSH public key data. pub public_key: String, /// Owner's username. pub username: String, } /// User info returned by SSH key fingerprint lookup (for CLI auth). #[derive(Debug, Clone, FromRow, Serialize)] pub struct SshKeyUserLookup { pub user_id: UserId, pub username: Username, pub display_name: Option, pub email: Email, pub creator_tier: Option, pub can_create_projects: bool, pub suspended: bool, } /// An OAuth2 authorization code for PKCE flow. #[derive(Debug, Clone, FromRow)] #[allow(dead_code)] // Fields read via sqlx queries and in route handlers pub struct DbOAuthCode { pub id: OAuthCodeId, pub code: String, pub app_id: SyncAppId, pub user_id: UserId, pub code_challenge: String, pub code_challenge_method: String, pub redirect_uri: String, pub expires_at: DateTime, pub used_at: Option>, pub created_at: DateTime, } // ── Git Issue models ── /// An issue filed against a git repository. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbIssue { pub id: IssueId, pub repo_id: GitRepoId, pub number: i32, pub author_user_id: UserId, pub title: String, pub body_markdown: String, pub body_html: String, pub status: super::super::IssueStatus, pub created_at: DateTime, pub updated_at: DateTime, /// Multithreaded forum thread mirroring this issue. Populated by the /// inbound issues handler when MT is configured; `None` otherwise. pub mt_thread_id: Option, } /// An issue with joined metadata for list display. #[derive(Debug, Clone, FromRow)] pub struct DbIssueWithMeta { pub id: IssueId, pub repo_id: GitRepoId, pub number: i32, pub author_user_id: UserId, pub title: String, pub status: super::super::IssueStatus, pub created_at: DateTime, pub updated_at: DateTime, pub author_username: String, pub comment_count: i64, } /// A comment on an issue. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbIssueComment { pub id: IssueCommentId, pub issue_id: IssueId, pub author_user_id: UserId, pub body_markdown: String, pub body_html: String, pub created_at: DateTime, } /// A comment with joined author username. #[derive(Debug, Clone, FromRow)] pub struct DbIssueCommentWithAuthor { pub id: IssueCommentId, pub issue_id: IssueId, pub author_user_id: UserId, pub body_markdown: String, pub body_html: String, pub created_at: DateTime, pub author_username: String, } /// A label that can be attached to issues within a repo. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbIssueLabel { pub id: IssueLabelId, pub repo_id: GitRepoId, pub name: String, pub color: String, }