Make "value" property optional on ActorProperty type
This commit is contained in:
parent
bbbd2fcb13
commit
900299b5e8
2 changed files with 26 additions and 15 deletions
|
@ -46,7 +46,7 @@ pub struct ActorProperty {
|
||||||
name: String,
|
name: String,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
object_type: String,
|
object_type: String,
|
||||||
value: String,
|
value: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
|
@ -96,18 +96,23 @@ pub struct Actor {
|
||||||
impl Actor {
|
impl Actor {
|
||||||
/// Parse 'attachment' into ExtraField vector
|
/// Parse 'attachment' into ExtraField vector
|
||||||
pub fn extra_fields(&self) -> Vec<ExtraField> {
|
pub fn extra_fields(&self) -> Vec<ExtraField> {
|
||||||
match &self.attachment {
|
let mut extra_fields = vec![];
|
||||||
Some(properties) => {
|
if let Some(properties) = &self.attachment {
|
||||||
properties.iter()
|
for property in properties {
|
||||||
.map(|prop| ExtraField {
|
if property.object_type != PROPERTY_VALUE {
|
||||||
name: prop.name.clone(),
|
continue;
|
||||||
value: prop.value.clone(),
|
};
|
||||||
|
if let Some(property_value) = &property.value {
|
||||||
|
let field = ExtraField {
|
||||||
|
name: property.name.clone(),
|
||||||
|
value: property_value.clone(),
|
||||||
value_source: None,
|
value_source: None,
|
||||||
})
|
};
|
||||||
.collect()
|
extra_fields.push(field);
|
||||||
},
|
};
|
||||||
None => vec![],
|
};
|
||||||
}
|
};
|
||||||
|
extra_fields
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +196,7 @@ pub fn get_local_actor(
|
||||||
ActorProperty {
|
ActorProperty {
|
||||||
object_type: PROPERTY_VALUE.to_string(),
|
object_type: PROPERTY_VALUE.to_string(),
|
||||||
name: field.name,
|
name: field.name,
|
||||||
value: field.value,
|
value: Some(field.value),
|
||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
let actor = Actor {
|
let actor = Actor {
|
||||||
|
|
|
@ -127,7 +127,10 @@ async fn get_or_fetch_profile_by_actor_id(
|
||||||
instance, actor_id, media_dir,
|
instance, actor_id, media_dir,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| ValidationError("failed to fetch actor"))?;
|
.map_err(|err| {
|
||||||
|
log::warn!("{}", err);
|
||||||
|
ValidationError("failed to fetch actor")
|
||||||
|
})?;
|
||||||
let profile = create_profile(db_client, &profile_data).await?;
|
let profile = create_profile(db_client, &profile_data).await?;
|
||||||
profile
|
profile
|
||||||
},
|
},
|
||||||
|
@ -183,7 +186,10 @@ pub async fn process_note(
|
||||||
Some(object) => object,
|
Some(object) => object,
|
||||||
None => {
|
None => {
|
||||||
let object = fetch_object(&instance, &object_id).await
|
let object = fetch_object(&instance, &object_id).await
|
||||||
.map_err(|_| ValidationError("failed to fetch object"))?;
|
.map_err(|err| {
|
||||||
|
log::warn!("{}", err);
|
||||||
|
ValidationError("failed to fetch object")
|
||||||
|
})?;
|
||||||
log::info!("fetched object {}", object.id);
|
log::info!("fetched object {}", object.id);
|
||||||
object
|
object
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue