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

ambee/giterated

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

`[feature/plugins]` Some plugin work?

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨10a447b

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