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

ambee/giterated

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

Unified stack refactor clean up

Clean up obsolete code and some warnings

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨356f714

⁨giterated-daemon/src/database_backend/updates.rs⁩ - ⁨2320⁩ bytes
Raw
1 use futures_util::{future::BoxFuture, FutureExt};
2 use giterated_models::{
3 repository::{DefaultBranch, Description, Repository},
4 settings::{AnySetting, Setting},
5 update::ValueUpdate,
6 user::User,
7 value::{AnyValue, GiteratedObjectValue},
8 };
9 use giterated_stack::{AuthorizedUser, StackOperationState};
10
11 use super::DatabaseBackend;
12
13 pub fn user_set_value(
14 _object: User,
15 _value_name: String,
16 _value: AnyValue<User>,
17 _operation_state: &StackOperationState,
18 ) -> BoxFuture<'static, Result<(), ()>> {
19 todo!()
20 }
21
22 pub fn user_set_setting(
23 _object: User,
24 _value_name: String,
25 _value: AnySetting,
26 _operation_state: &StackOperationState,
27 ) -> BoxFuture<'static, Result<(), ()>> {
28 todo!()
29 }
30
31 pub fn repository_set_value(
32 _object: Repository,
33 _value_name: String,
34 _value: AnyValue<Repository>,
35 _operation_state: &StackOperationState,
36 ) -> BoxFuture<'static, Result<(), ()>> {
37 todo!()
38 }
39
40 pub fn repository_set_setting(
41 _object: Repository,
42 _value_name: String,
43 _value: AnySetting,
44 _operation_state: &StackOperationState,
45 ) -> BoxFuture<'static, Result<(), ()>> {
46 todo!()
47 }
48
49 pub fn repository_set_description(
50 _object: Repository,
51 _description: Description,
52 _user: AuthorizedUser,
53 ) -> BoxFuture<'static, Result<(), ()>> {
54 async { Ok(()) }.boxed()
55 }
56
57 pub fn repository_set_default_branch(
58 object: Repository,
59 default_branch: DefaultBranch,
60 // Ensure user is authorized for this request
61 _user: AuthorizedUser,
62 backend: DatabaseBackend,
63 ) -> BoxFuture<'static, Result<(), ()>> {
64 async move {
65 let mut repository_backend = backend.repository_backend.lock().await;
66
67 repository_backend
68 .write_setting(
69 &object,
70 DefaultBranch::name(),
71 &serde_json::to_value(default_branch.clone()).unwrap(),
72 )
73 .await
74 .unwrap();
75
76 let _set_value = ValueUpdate {
77 object: object.to_string(),
78 value_name: DefaultBranch::value_name().to_owned(),
79 value: unsafe { AnyValue::from_raw(serde_json::to_value(default_branch).unwrap()) },
80 };
81
82 // Submit value update back to the daemon
83 // state.value_update(set_value);
84 Ok(())
85 }
86 .boxed()
87 }
88