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

ambee/giterated

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

Basic Issue data structures

Emilia - ⁨1⁩ year ago

parent: tbd commit: ⁨509aa4e

⁨giterated-models/src/issue/operations.rs⁩ - ⁨1129⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::{
4 error::{OperationError, RepositoryError},
5 object::Object,
6 object_backend::ObjectBackend,
7 operation::GiteratedOperation,
8 };
9
10 use super::{Issue, IssueInfo};
11
12 /// A request to get info about an issue. (graphql please)
13 ///
14 /// # Authentication
15 /// - Instance Authentication
16 /// - Validate request against the `issued_for` public key
17 /// - Validate User token against the user's instance's public key
18 /// # Authorization
19 /// - User Authorization
20 /// - Potential User permissions checks
21 #[derive(Clone, Debug, Serialize, Deserialize)]
22 pub struct IssueInfoRequest {
23 pub id: u64,
24 }
25
26 impl GiteratedOperation<Issue> for IssueInfoRequest {
27 type Success = IssueInfo;
28 type Failure = RepositoryError;
29 }
30
31 impl<S: Clone + Send + Sync, B: ObjectBackend<S> + std::fmt::Debug> Object<'_, S, Issue, B> {
32 pub async fn info(
33 &mut self,
34 id: u64,
35 operation_state: &S,
36 ) -> Result<IssueInfo, OperationError<RepositoryError>> {
37 self.request::<IssueInfoRequest>(IssueInfoRequest { id }, operation_state)
38 .await
39 }
40 }
41