use crate::db::IssueRow; use crate::setting::Contents; use crate::value::{Author, CommentCount, CreationDate, Name}; use crate::IssuesPluginState; use crate::{ operations::{ CreateIssueRequest, IssueCreationError, IssueEditError, IssueEditRequest, IssuePostCommentError, IssuePostCommentRequest, IssueQueryError, QueryIssuesRequest, }, Issue, }; use giterated_models::error::IntoInternalError; use giterated_models::user::User; use giterated_models::{error::OperationError, repository::Repository}; use sqlx::PgPool; pub async fn create_issue_request( state: IssuesPluginState, repository: Repository, request: CreateIssueRequest, ) -> Result> { // TODO: AUTHN & AUTHZ let issue = sqlx::query_as!( IssueRow, r#"INSERT INTO issues VALUES (null, $1, $2, $3, $4, $5) RETURNING *"#, repository.to_string(), request.author.to_string(), 0, request.name, request.contents, ) .fetch_one(&state.pool) .await .as_internal_error_with_context("creating issue in db")?; Ok(Issue { repository, id: issue.id as u32, }) } pub async fn query_issues_request( state: IssuesPluginState, repository: Repository, request: QueryIssuesRequest, ) -> Result, OperationError> { // TODO: AUTHN & AUTHZ todo!() } pub async fn edit_issue_request( state: IssuesPluginState, issue: Issue, request: IssueEditRequest, ) -> Result<(), OperationError> { // TODO: AUTHN & AUTHZ todo!() } pub async fn issue_post_comment_request( state: IssuesPluginState, issue: Issue, request: IssuePostCommentRequest, ) -> Result> { // TODO: AUTHN & AUTHZ todo!() } pub async fn issue_value_author( state: IssuesPluginState, issue: Issue, ) -> Result> { todo!() } pub async fn issue_value_creation_date( state: IssuesPluginState, issue: Issue, ) -> Result> { todo!() } pub async fn issue_value_comment_count( state: IssuesPluginState, issue: Issue, ) -> Result> { todo!() } pub async fn issue_set_setting_name( state: IssuesPluginState, issue: Issue, name: Name, ) -> Result<(), OperationError> { todo!() } pub async fn issue_get_setting_name( state: IssuesPluginState, issue: Issue, ) -> Result> { todo!() } pub async fn issue_set_setting_contents( state: IssuesPluginState, issue: Issue, contents: Contents, ) -> Result<(), OperationError> { todo!() } pub async fn issue_get_setting_contents( state: IssuesPluginState, issue: Issue, ) -> Result> { todo!() }