Use OneOrMany<&AnyString>::to_as_string()
This commit is contained in:
parent
a80a95d471
commit
3db10a09bb
@ -31,7 +31,7 @@ use plume_common::{
|
|||||||
request::get,
|
request::get,
|
||||||
sign::{gen_keypair, Error as SignError, Result as SignResult, Signer},
|
sign::{gen_keypair, Error as SignError, Result as SignResult, Signer},
|
||||||
ActivityStream, ApSignature, CustomPerson as CustomPerson07, Id, IntoId, PublicKey,
|
ActivityStream, ApSignature, CustomPerson as CustomPerson07, Id, IntoId, PublicKey,
|
||||||
PUBLIC_VISIBILITY,
|
ToAsString, PUBLIC_VISIBILITY,
|
||||||
},
|
},
|
||||||
utils,
|
utils,
|
||||||
};
|
};
|
||||||
@ -1053,45 +1053,20 @@ impl FromId07<DbConn> for User {
|
|||||||
let summary = acct
|
let summary = acct
|
||||||
.object_ref()
|
.object_ref()
|
||||||
.summary()
|
.summary()
|
||||||
.and_then(|prop| {
|
.and_then(|prop| prop.to_as_string())
|
||||||
if let Some(p) = prop.as_one() {
|
|
||||||
p.as_xsd_string()
|
|
||||||
.or_else(|| p.as_rdf_lang_string().map(|ls| ls.value.as_str()))
|
|
||||||
} else if let Some(ps) = prop.as_many() {
|
|
||||||
ps.iter().next().and_then(|p| {
|
|
||||||
p.as_xsd_string()
|
|
||||||
.or_else(|| p.as_rdf_lang_string().map(|ls| ls.value.as_str()))
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let mut new_user = NewUser {
|
let mut new_user = NewUser {
|
||||||
display_name: acct
|
display_name: acct
|
||||||
.object_ref()
|
.object_ref()
|
||||||
.name()
|
.name()
|
||||||
.and_then(|prop| {
|
.and_then(|prop| prop.to_as_string())
|
||||||
if let Some(p) = prop.as_one() {
|
.unwrap_or_else(|| username.clone()),
|
||||||
p.as_xsd_string()
|
username: username.clone(),
|
||||||
.or_else(|| p.as_rdf_lang_string().map(|ls| ls.value.as_str()))
|
|
||||||
} else if let Some(ps) = prop.as_many() {
|
|
||||||
ps.iter().next().and_then(|p| {
|
|
||||||
p.as_xsd_string()
|
|
||||||
.or_else(|| p.as_rdf_lang_string().map(|ls| ls.value.as_str()))
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap_or(&username)
|
|
||||||
.to_string(),
|
|
||||||
username: username.to_string(),
|
|
||||||
outbox_url: actor.outbox()?.ok_or(Error::MissingApProperty)?.to_string(),
|
outbox_url: actor.outbox()?.ok_or(Error::MissingApProperty)?.to_string(),
|
||||||
inbox_url: actor.inbox()?.to_string(),
|
inbox_url: actor.inbox()?.to_string(),
|
||||||
role: 2,
|
role: 2,
|
||||||
summary: summary.to_string(),
|
summary_html: SafeString::new(&summary),
|
||||||
summary_html: SafeString::new(summary),
|
summary,
|
||||||
public_key: acct.ext_one.public_key.public_key_pem.to_string(),
|
public_key: acct.ext_one.public_key.public_key_pem.to_string(),
|
||||||
shared_inbox_url: actor
|
shared_inbox_url: actor
|
||||||
.endpoints()?
|
.endpoints()?
|
||||||
@ -1150,7 +1125,7 @@ impl FromId07<DbConn> for User {
|
|||||||
})?;
|
})?;
|
||||||
new_user.instance_id = instance.id;
|
new_user.instance_id = instance.id;
|
||||||
new_user.fqn = if instance.local {
|
new_user.fqn = if instance.local {
|
||||||
username.to_string()
|
username
|
||||||
} else {
|
} else {
|
||||||
format!("{}@{}", username, instance.public_domain)
|
format!("{}@{}", username, instance.public_domain)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user