.unwrap();
let creator = get_or_fetch_and_upsert_user(creator_uri, client, pool).await?;
+ let name = group
+ .inner
+ .name()
+ .unwrap()
+ .as_one()
+ .unwrap()
+ .as_xsd_string()
+ .unwrap()
+ .to_string();
+ let title = group.inner.preferred_username().unwrap().to_string();
+ // TODO: should be parsed as html and tags like <script> removed (or use markdown source)
+ // -> same for post.content etc
+ let description = group
+ .inner
+ .content()
+ .map(|s| s.as_single_xsd_string().unwrap().into());
+ check_slurs(&name)?;
+ check_slurs(&title)?;
+ check_slurs_opt(&description)?;
+ let icon = match group.icon() {
+ Some(any_image) => Some(
+ Image::from_any_base(any_image.as_one().unwrap().clone())
+ .unwrap()
+ .unwrap()
+ .url()
+ .unwrap()
+ .as_single_xsd_any_uri()
+ .map(|u| u.to_string()),
+ ),
+ None => None,
+ };
+
+ let banner = match group.image() {
+ Some(any_image) => Some(
+ Image::from_any_base(any_image.as_one().unwrap().clone())
+ .unwrap()
+ .unwrap()
+ .url()
+ .unwrap()
+ .as_single_xsd_any_uri()
+ .map(|u| u.to_string()),
+ ),
+ None => None,
+ };
+
Ok(CommunityForm {
- name: group
- .inner
- .name()
- .unwrap()
- .as_one()
- .unwrap()
- .as_xsd_string()
- .unwrap()
- .into(),
- title: group.inner.preferred_username().unwrap().to_string(),
- // TODO: should be parsed as html and tags like <script> removed (or use markdown source)
- // -> same for post.content etc
- description: group
- .inner
- .content()
- .map(|s| s.as_single_xsd_string().unwrap().into()),
+ name,
+ title,
+ description,
category_id: group.ext_one.category.identifier.parse::<i32>()?,
creator_id: creator.id,
removed: None,
impl FromApub for UserForm {
type ApubType = PersonExt;
/// Parse an ActivityPub person received from another instance into a Lemmy user.
- async fn from_apub(person: &PersonExt, _: &Client, _: &DbPool) -> Result<Self, LemmyError> {
+ async fn from_apub(
+ person: &PersonExt,
+ _: &Client,
+ _: &DbPool,
+ expected_domain: Option<Url>,
+ ) -> Result<Self, LemmyError> {
let avatar = match person.icon() {
- Some(any_image) => Image::from_any_base(any_image.as_one().unwrap().clone())
- .unwrap()
- .unwrap()
- .url()
- .unwrap()
- .as_single_xsd_any_uri()
- .map(|u| u.to_string()),
+ Some(any_image) => Some(
+ Image::from_any_base(any_image.as_one().unwrap().clone())
+ .unwrap()
+ .unwrap()
+ .url()
+ .unwrap()
+ .as_single_xsd_any_uri()
+ .map(|u| u.to_string()),
+ ),
+ None => None,
+ };
+
+ let banner = match person.image() {
+ Some(any_image) => Some(
+ Image::from_any_base(any_image.as_one().unwrap().clone())
+ .unwrap()
+ .unwrap()
+ .url()
+ .unwrap()
+ .as_single_xsd_any_uri()
+ .map(|u| u.to_string()),
+ ),
None => None,
};