From de6e9c0e2e24bcdc435d5d4aff4466c0a04eeb28 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 1 May 2022 13:00:04 +0900 Subject: [PATCH] Fix Post::from_activity07() --- plume-models/src/posts.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 37dfaea7..a2ad8e0d 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -1031,20 +1031,27 @@ impl FromId07 for Post { let article = article.inner; let (blog, authors) = article + .ap_object_ref() .attributed_to() - .ok_or(Error::MissingApProperty) + .ok_or(Error::MissingApProperty)? .iter() .fold((None, vec![]), |(blog, mut authors), link| { - let url = link.to_as_uri().expect("Exists"); - match User::from_id(conn, &url, None, CONFIG.proxy()) { - Ok(u) => { - authors.push(u); - (blog, authors) + if let Some(url) = link.id() { + match User::from_id07(conn, url.as_str(), None, CONFIG.proxy()) { + Ok(u) => { + authors.push(u); + (blog, authors) + } + Err(_) => ( + blog.or_else(|| { + Blog::from_id07(conn, url.as_str(), None, CONFIG.proxy()).ok() + }), + authors, + ), } - Err(_) => ( - blog.or_else(|| Blog::from_id(conn, &url, None, CONFIG.proxy()).ok()), - authors, - ), + } else { + // logically, url possible to be an object without id proprty like {"type":"Person", "name":"Sally"} but we ignore the case + (blog, authors) } });