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

ambee/giterated

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

Finish unified stack refactor.

Adds support for operation state, which will be used to pass authentication information around. Added generic backend that uses a channel to communicate with a typed backend.

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨d15581c

⁨giterated-models/src/user/operations.rs⁩ - ⁨1069⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::{
4 error::{OperationError, UserError},
5 instance::Instance,
6 object::Object,
7 object_backend::ObjectBackend,
8 operation::GiteratedOperation,
9 repository::RepositorySummary,
10 };
11
12 use super::User;
13
14 #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
15 pub struct UserRepositoriesRequest {
16 pub instance: Instance,
17 pub user: User,
18 }
19
20 impl GiteratedOperation<User> for UserRepositoriesRequest {
21 type Success = Vec<RepositorySummary>;
22 type Failure = UserError;
23 }
24
25 impl<S: Clone + Send + Sync, B: ObjectBackend<S> + std::fmt::Debug> Object<'_, S, User, B> {
26 pub async fn repositories(
27 &mut self,
28 instance: &Instance,
29 operation_state: &S,
30 ) -> Result<Vec<RepositorySummary>, OperationError<UserError>> {
31 self.request::<UserRepositoriesRequest>(
32 UserRepositoriesRequest {
33 instance: instance.clone(),
34 user: self.inner.clone(),
35 },
36 operation_state,
37 )
38 .await
39 }
40 }
41