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

ambee/giterated

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

So. Much. Work.

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨b05f964

⁨giterated-plugins/giterated-issues/src/operations.rs⁩ - ⁨1995⁩ bytes
Raw
1 use giterated_models::{operation::GiteratedOperation, repository::Repository, user::User};
2 use serde::{Deserialize, Serialize};
3
4 use crate::Issue;
5
6 /// Create an [`Issue`] on a [`Repository`].
7 #[derive(Clone, Debug, Serialize, Deserialize)]
8 pub struct CreateIssueRequest {
9 pub name: String,
10 pub contents: String,
11 pub author: User,
12 }
13
14 impl GiteratedOperation<Repository> for CreateIssueRequest {
15 type Success = Issue;
16
17 type Failure = IssueCreationError;
18 }
19
20 #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)]
21 #[error("failed to create issue")]
22 pub struct IssueCreationError;
23
24 /// Query for [`Issue`]s on a [`Repository`].
25 #[derive(Clone, Debug, Serialize, Deserialize)]
26 pub struct QueryIssuesRequest {}
27
28 impl GiteratedOperation<Repository> for QueryIssuesRequest {
29 type Success = Vec<Issue>;
30
31 type Failure = IssueQueryError;
32 }
33
34 #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)]
35 #[error("failed to query issues")]
36 pub struct IssueQueryError;
37
38 #[derive(Clone, Debug, Serialize, Deserialize)]
39 pub struct IssueEditRequest {
40 // Might not be needed :)
41 }
42
43 impl GiteratedOperation<Issue> for IssueEditRequest {
44 type Success = ();
45
46 type Failure = IssueEditError;
47 }
48
49 #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)]
50 #[error("failed to edit issue")]
51 pub struct IssueEditError;
52
53 #[derive(Clone, Debug, Serialize, Deserialize)]
54 pub struct IssuePostCommentRequest {
55 pub contents: String,
56 pub visibility: CommentVisibility,
57 }
58
59 impl GiteratedOperation<Issue> for IssuePostCommentRequest {
60 type Success = u32;
61
62 type Failure = IssuePostCommentError;
63 }
64
65 #[derive(Clone, Debug, Serialize, Deserialize, thiserror::Error)]
66 #[error("failed to post comment")]
67 pub struct IssuePostCommentError;
68
69 #[derive(PartialEq, Eq, Debug, Hash, Serialize, Deserialize, Clone, sqlx::Type)]
70 #[sqlx(type_name = "comment_visibility", rename_all = "lowercase")]
71 pub enum CommentVisibility {
72 Public,
73 Maintainers,
74 Private,
75 }
76