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

ambee/giterated

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

Add token extension

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨86d028f

⁨src/messages/repository.rs⁩ - ⁨3108⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::repository::RepositoryVisibility;
4 use crate::model::{
5 repository::{Commit, Repository, RepositoryTreeEntry, RepositoryView},
6 user::User,
7 };
8
9 use super::UserAuthenticated;
10
11 #[derive(Clone, Serialize, Deserialize)]
12 pub struct RepositoryMessage {
13 pub target: Repository,
14 pub command: RepositoryMessageKind,
15 }
16
17 #[derive(Clone, Serialize, Deserialize)]
18 pub enum RepositoryMessageKind {
19 Request(RepositoryRequest),
20 Response(RepositoryResponse),
21 }
22
23 #[derive(Clone, Serialize, Deserialize)]
24 pub enum RepositoryRequest {
25 CreateRepository(UserAuthenticated<CreateRepositoryRequest>),
26 RepositoryFileInspect(RepositoryFileInspectRequest),
27 RepositoryInfo(RepositoryInfoRequest),
28 IssuesCount(RepositoryIssuesCountRequest),
29 IssueLabels(RepositoryIssueLabelsRequest),
30 Issues(RepositoryIssuesRequest),
31 }
32
33 #[derive(Clone, Serialize, Deserialize)]
34 pub enum RepositoryResponse {
35 CreateRepository(CreateRepositoryResponse),
36 RepositoryFileInspection(RepositoryFileInspectionResponse),
37 RepositoryInfo(RepositoryView),
38 IssuesCount(RepositoryIssuesCountResponse),
39 IssueLabels(RepositoryIssueLabelsResponse),
40 Issues(RepositoryIssuesResponse),
41 }
42
43 #[derive(Clone, Serialize, Deserialize)]
44 pub struct CreateRepositoryRequest {
45 pub name: String,
46 pub description: Option<String>,
47 pub visibility: RepositoryVisibility,
48 pub default_branch: String,
49 pub owner: User,
50 }
51
52 #[derive(Clone, Serialize, Deserialize)]
53 pub enum CreateRepositoryResponse {
54 Created,
55 Failed,
56 }
57
58 #[derive(Clone, Serialize, Deserialize)]
59 pub struct RepositoryFileInspectRequest {
60 pub path: RepositoryTreeEntry,
61 }
62
63 #[derive(Clone, Serialize, Deserialize)]
64 pub enum RepositoryFileInspectionResponse {
65 File {
66 commit_metadata: Commit,
67 },
68 Folder {
69 commit_metadata: Commit,
70 members: Vec<RepositoryTreeEntry>,
71 },
72 Invalid {
73 path: RepositoryTreeEntry,
74 },
75 }
76
77 #[derive(Clone, Serialize, Deserialize)]
78 pub struct RepositoryIssuesCountRequest;
79
80 #[derive(Clone, Serialize, Deserialize)]
81 pub struct RepositoryIssuesCountResponse {
82 pub count: u64,
83 }
84
85 #[derive(Clone, Serialize, Deserialize)]
86 pub struct RepositoryIssueLabelsRequest;
87
88 #[derive(Clone, Serialize, Deserialize)]
89 pub struct RepositoryIssueLabelsResponse {
90 pub labels: Vec<IssueLabel>,
91 }
92
93 #[derive(Clone, Serialize, Deserialize)]
94 pub struct IssueLabel {
95 pub name: String,
96 pub color: String,
97 }
98
99 #[derive(Clone, Serialize, Deserialize)]
100 pub struct RepositoryIssuesRequest;
101
102 #[derive(Clone, Serialize, Deserialize)]
103 pub struct RepositoryIssuesResponse {
104 pub issues: Vec<RepositoryIssue>,
105 }
106
107 #[derive(Clone, Serialize, Deserialize)]
108 pub struct RepositoryIssue {
109 pub author: User,
110 pub id: u64,
111 pub title: String,
112 pub contents: String,
113 pub labels: Vec<IssueLabel>,
114 }
115
116 #[derive(Clone, Serialize, Deserialize)]
117 pub struct RepositoryInfoRequest {
118 pub name: String,
119 pub owner: User,
120 pub rev: Option<String>,
121 pub path: Option<String>,
122 pub extra_metadata: bool,
123 }
124