JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Wow!

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨6530104

⁨plugins/giterated-issues/src/handlers.rs⁩ - ⁨3182⁩ bytes
Raw
1 use crate::setting::Contents;
2 use crate::value::{Author, CommentCount, CreationDate, Name};
3 use crate::IssuesPluginState;
4 use crate::{
5 operations::{
6 CreateIssueRequest, IssueCreationError, IssueEditError, IssueEditRequest,
7 IssuePostCommentError, IssuePostCommentRequest, IssueQueryError, QueryIssuesRequest,
8 },
9 Issue,
10 };
11
12 use giterated_models::{error::OperationError, repository::Repository};
13 use giterated_plugin::StateExtractor;
14
15 pub async fn create_issue_request(
16 repository: Repository,
17 _request: CreateIssueRequest,
18 _state: StateExtractor<IssuesPluginState>,
19 ) -> Result<Issue, OperationError<IssueCreationError>> {
20 // // TODO: AUTHN & AUTHZ
21 // let issue = sqlx::query_as!(
22 // IssueRow,
23 // r#"INSERT INTO issues VALUES (null, $1, $2, $3, $4, $5) RETURNING *"#,
24 // repository.to_string(),
25 // request.author.to_string(),
26 // 0,
27 // request.name,
28 // request.contents,
29 // )
30 // .fetch_one(&state.pool)
31 // .await
32 // .as_internal_error_with_context("creating issue in db")?;
33
34 // Ok(Issue {
35 // repository,
36 // id: issue.id as u32,
37 // })
38
39 Ok(Issue { repository, id: 1 })
40 }
41
42 pub async fn query_issues_request(
43 _repository: Repository,
44 _request: QueryIssuesRequest,
45 _state: StateExtractor<IssuesPluginState>,
46 ) -> Result<Vec<Issue>, OperationError<IssueQueryError>> {
47 // TODO: AUTHN & AUTHZ
48 todo!()
49 }
50
51 pub async fn edit_issue_request(
52 _issue: Issue,
53 _request: IssueEditRequest,
54 _state: StateExtractor<IssuesPluginState>,
55 ) -> Result<(), OperationError<IssueEditError>> {
56 // TODO: AUTHN & AUTHZ
57 todo!()
58 }
59
60 pub async fn issue_post_comment_request(
61 _issue: Issue,
62 _request: IssuePostCommentRequest,
63 _state: StateExtractor<IssuesPluginState>,
64 ) -> Result<u32, OperationError<IssuePostCommentError>> {
65 // TODO: AUTHN & AUTHZ
66 todo!()
67 }
68
69 pub async fn issue_value_author(
70 _issue: Issue,
71 _state: StateExtractor<IssuesPluginState>,
72 ) -> Result<Author, OperationError<anyhow::Error>> {
73 todo!()
74 }
75
76 pub async fn issue_value_creation_date(
77 _issue: Issue,
78 _state: StateExtractor<IssuesPluginState>,
79 ) -> Result<CreationDate, OperationError<anyhow::Error>> {
80 todo!()
81 }
82
83 pub async fn issue_value_comment_count(
84 _issue: Issue,
85 _state: StateExtractor<IssuesPluginState>,
86 ) -> Result<CommentCount, OperationError<anyhow::Error>> {
87 todo!()
88 }
89
90 pub async fn issue_set_setting_name(
91 _issue: Issue,
92 _name: Name,
93 _state: StateExtractor<IssuesPluginState>,
94 ) -> Result<(), OperationError<anyhow::Error>> {
95 todo!()
96 }
97
98 pub async fn issue_get_setting_name(
99 _issue: Issue,
100 _state: StateExtractor<IssuesPluginState>,
101 ) -> Result<Name, OperationError<anyhow::Error>> {
102 todo!()
103 }
104
105 pub async fn issue_set_setting_contents(
106 _issue: Issue,
107 _contents: Contents,
108 _state: StateExtractor<IssuesPluginState>,
109 ) -> Result<(), OperationError<anyhow::Error>> {
110 todo!()
111 }
112
113 pub async fn issue_get_setting_contents(
114 _issue: Issue,
115 _state: StateExtractor<IssuesPluginState>,
116 ) -> Result<Contents, OperationError<anyhow::Error>> {
117 todo!()
118 }
119