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

ambee/giterated

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

Implement Debug on all messages

Type: Fix

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨249c88e

⁨giterated-models/src/messages/repository.rs⁩ - ⁨4363⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::repository::RepositoryVisibility;
4 use crate::model::{
5 repository::{Commit, Repository, RepositoryTreeEntry},
6 user::User,
7 };
8
9 /// A request to create a repository.
10 ///
11 /// # Authentication
12 /// - Instance Authentication
13 /// - Used to validate User token `issued_for`
14 /// - User Authentication
15 /// - Used to source owning user
16 /// - Used to authorize user token against user's instance
17 /// # Authorization
18 /// - Instance Authorization
19 /// - Used to authorize action using User token requiring a correct `issued_for` and valid issuance from user's instance
20 /// - User Authorization
21 /// - Potential User permissions checks
22 #[derive(Clone, Debug, Serialize, Deserialize)]
23 pub struct RepositoryCreateRequest {
24 pub name: String,
25 pub description: Option<String>,
26 pub visibility: RepositoryVisibility,
27 pub default_branch: String,
28 pub owner: User,
29 }
30
31 #[derive(Clone, Debug, Serialize, Deserialize)]
32 pub struct RepositoryCreateResponse;
33
34 /// A request to inspect the tree of a repository.
35 ///
36 /// # Authentication
37 /// - Instance Authentication
38 /// - Validate request against the `issued_for` public key
39 /// - Validate User token against the user's instance's public key
40 /// # Authorization
41 /// - User Authorization
42 /// - Potential User permissions checks
43 #[derive(Clone, Debug, Serialize, Deserialize)]
44 pub struct RepositoryFileInspectRequest {
45 pub path: RepositoryTreeEntry,
46 }
47
48 #[derive(Clone, Debug, Serialize, Deserialize)]
49 pub enum RepositoryFileInspectionResponse {
50 File {
51 commit_metadata: Commit,
52 },
53 Folder {
54 commit_metadata: Commit,
55 members: Vec<RepositoryTreeEntry>,
56 },
57 Invalid {
58 path: RepositoryTreeEntry,
59 },
60 }
61
62 /// A request to get a repository's information.
63 ///
64 /// # Authentication
65 /// - Instance Authentication
66 /// - Validate request against the `issued_for` public key
67 /// - Validate User token against the user's instance's public key
68 /// # Authorization
69 /// - User Authorization
70 /// - Potential User permissions checks
71 #[derive(Clone, Debug, Serialize, Deserialize)]
72 pub struct RepositoryIssuesCountRequest;
73
74 #[derive(Clone, Debug, Serialize, Deserialize)]
75 pub struct RepositoryIssuesCountResponse {
76 pub count: u64,
77 }
78
79 /// A request to get a repository's issues count.
80 ///
81 /// # Authentication
82 /// - Instance Authentication
83 /// - Validate request against the `issued_for` public key
84 /// - Validate User token against the user's instance's public key
85 /// # Authorization
86 /// - User Authorization
87 /// - Potential User permissions checks
88 #[derive(Clone, Debug, Serialize, Deserialize)]
89 pub struct RepositoryIssueLabelsRequest;
90
91 #[derive(Clone, Debug, Serialize, Deserialize)]
92 pub struct RepositoryIssueLabelsResponse {
93 pub labels: Vec<IssueLabel>,
94 }
95
96 #[derive(Clone, Debug, Serialize, Deserialize)]
97 pub struct IssueLabel {
98 pub name: String,
99 pub color: String,
100 }
101
102 /// A request to get a repository's issue labels.
103 ///
104 /// # Authentication
105 /// - Instance Authentication
106 /// - Validate request against the `issued_for` public key
107 /// - Validate User token against the user's instance's public key
108 /// # Authorization
109 /// - User Authorization
110 /// - Potential User permissions checks
111 #[derive(Clone, Debug, Serialize, Deserialize)]
112 pub struct RepositoryIssuesRequest;
113
114 #[derive(Clone, Debug, Serialize, Deserialize)]
115 pub struct RepositoryIssuesResponse {
116 pub issues: Vec<RepositoryIssue>,
117 }
118
119 /// A request to get a repository's issues.
120 ///
121 /// # Authentication
122 /// - Instance Authentication
123 /// - Validate request against the `issued_for` public key
124 /// - Validate User token against the user's instance's public key
125 /// # Authorization
126 /// - User Authorization
127 /// - Potential User permissions checks
128 #[derive(Clone, Debug, Serialize, Deserialize)]
129 pub struct RepositoryIssue {
130 pub author: User,
131 pub id: u64,
132 pub title: String,
133 pub contents: String,
134 pub labels: Vec<IssueLabel>,
135 }
136
137 #[derive(Clone, Debug, Serialize, Deserialize)]
138 pub struct RepositoryInfoRequest {
139 pub repository: Repository,
140 /// Whether to fetch extra metadata like the last commit made to file or size
141 pub extra_metadata: bool,
142 /// Rev (branch) being requested
143 pub rev: Option<String>,
144 /// Tree path being requested
145 pub path: Option<String>,
146 }
147