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

ambee/giterated

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

Fix settings

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨c518454

Showing ⁨⁨2⁩ changed files⁩ with ⁨⁨73⁩ insertions⁩ and ⁨⁨14⁩ deletions⁩

giterated-daemon/src/database_backend/mod.rs

View file
@@ -105,13 +105,7 @@ impl DatabaseBackend {
105 105 .value_setting::<Repository, Visibility>()
106 106 .value_setting::<Repository, DefaultBranch>();
107 107
108 builder
109 .value(user_get_value_bio)
110 .value(user_get_value_display_name)
111 .value(repository_get_value_description)
112 .value(repository_get_value_visibility)
113 .value(repository_get_default_branch)
114 .value(repository_get_latest_commit);
108 builder.value(repository_get_latest_commit);
115 109
116 110 builder
117 111 .operation(user_get_repositories)

giterated-stack/src/handler.rs

View file
@@ -422,6 +422,44 @@ impl<S: GiteratedStackState + 'static> SubstackBuilder<S> {
422 422 ),
423 423 );
424 424
425 let wrapped = OperationWrapper::new(
426 |object: &O,
427 operation: GetValueTyped<T>,
428 state: _,
429 operation_state: StackOperationState,
430 stack: Arc<GiteratedStack>| {
431 let object = object.clone();
432 async move {
433 match stack
434 .get_setting(
435 Box::new(object.clone()) as _,
436 O::object_name().to_string(),
437 GetSetting {
438 setting_name: T::name().to_string(),
439 },
440 &operation_state,
441 )
442 .await
443 {
444 Ok(setting) => Ok(*setting.downcast::<T>().unwrap()),
445 Err(err) => {
446 panic!("Error: {:?}", err);
447 }
448 }
449 }
450 .boxed_local()
451 },
452 self.state.clone(),
453 );
454
455 self.value_getters.insert(
456 ObjectValuePair {
457 object_kind: O::object_name().to_string(),
458 value_kind: T::value_name().to_string(),
459 },
460 wrapped,
461 );
462
425 463 self
426 464 }
427 465
@@ -969,14 +1007,41 @@ impl GiteratedStack {
969 1007 operation.setting_name
970 1008 );
971 1009
972 let setting_getter = self
973 .setting_getters
974 .get(&object_kind)
975 .ok_or_else(|| OperationError::Unhandled)?;
1010 for provider in self.metadata_providers.iter() {
1011 if provider.provides_for(object.as_ref()) {
1012 let setting_meta = self
1013 .metadata
1014 .settings
1015 .get(&ObjectSettingPair {
1016 object_kind: object_kind.clone(),
1017 setting_name: operation.setting_name.clone(),
1018 })
1019 .ok_or_else(|| OperationError::Unhandled)?;
1020
1021 let object_meta = self
1022 .metadata
1023 .objects
1024 .get(&object_kind)
1025 .ok_or_else(|| OperationError::Unhandled)?;
1026
1027 let result = provider
1028 .read(object.as_ref(), object_meta, setting_meta)
1029 .await
1030 .as_internal_error_with_context(format!(
1031 "reading setting {}",
1032 operation.setting_name
1033 ))?;
1034
1035 return Ok(
1036 (setting_meta.deserialize)(result).as_internal_error_with_context(format!(
1037 "deserializing setting {}",
1038 operation.setting_name
1039 ))?,
1040 );
1041 }
1042 }
976 1043
977 setting_getter
978 .handle(&object, &(Box::new(operation) as Box<_>), operation_state)
979 .await
1044 todo!()
980 1045 }
981 1046
982 1047 pub async fn network_set_setting(