use crate::connection::wrapper::ConnectionState; use giterated_models::error::OperationError; use giterated_models::object::GiteratedObject; use giterated_models::repository::{ Repository, RepositoryFileInspectRequest, RepositoryIssueLabelsRequest, RepositoryIssuesCountRequest, RepositoryIssuesRequest, }; use giterated_models::user::User; use giterated_models::{ object::ObjectRequest, settings::{SetSetting, Setting}, value::{GetValue, GiteratedObjectValue}, }; #[async_trait::async_trait] pub trait AuthorizedOperation { /// Authorizes the operation, returning whether the operation was /// authorized or not. async fn authorize( &self, authenticating_user: Option<&User>, object: &O, state: &mut S, ) -> Result>; } #[async_trait::async_trait] impl AuthorizedOperation for SetSetting { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &User, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } } #[async_trait::async_trait] impl AuthorizedOperation for SetSetting { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &Repository, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } } #[async_trait::async_trait] impl AuthorizedOperation for GetValue { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &Repository, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } } #[async_trait::async_trait] impl AuthorizedOperation for ObjectRequest { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &Repository, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } } #[async_trait::async_trait] impl AuthorizedOperation for RepositoryFileInspectRequest { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &Repository, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } } #[async_trait::async_trait] impl AuthorizedOperation for RepositoryIssuesRequest { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &Repository, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } } #[async_trait::async_trait] impl AuthorizedOperation for RepositoryIssueLabelsRequest { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &Repository, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } } #[async_trait::async_trait] impl AuthorizedOperation for RepositoryIssuesCountRequest { async fn authorize( &self, _authenticating_user: Option<&User>, _object: &Repository, _state: &mut ConnectionState, ) -> Result> { // TODO Ok(true) } }