]> Untitled Git - lemmy.git/commitdiff
Add logging to find bug (ref #1283)
authorFelix Ableitner <me@nutomic.com>
Mon, 30 Nov 2020 17:24:10 +0000 (18:24 +0100)
committerFelix Ableitner <me@nutomic.com>
Mon, 30 Nov 2020 17:24:10 +0000 (18:24 +0100)
Also simplify check_object_domain()

Cargo.lock
lemmy_apub/Cargo.toml
lemmy_apub/src/objects/mod.rs
lemmy_apub/src/objects/post.rs

index 7823e9fc21a3f057d155549df6a229ff7ec61e3a..cf741d68948e1e557d398e027646dd50be90e570 100644 (file)
@@ -1761,6 +1761,7 @@ dependencies = [
  "async-trait",
  "awc",
  "background-jobs",
+ "backtrace",
  "base64 0.13.0",
  "bcrypt",
  "chrono",
index 5610ed699051fbb132941e4a74526322139dd613..7e8f792a5e5a67d75bea39a45bea88d41f59b4f5 100644 (file)
@@ -46,3 +46,4 @@ anyhow = "1.0"
 thiserror = "1.0"
 background-jobs = " 0.8"
 reqwest = { version = "0.10", features = ["json"] }
+backtrace = "0.3"
index f365b528c4b5f94cc8b3451cc14f6c7d7d5d5826..a162c165b4f0125870f036885c4997afb4592b4a 100644 (file)
@@ -48,16 +48,14 @@ pub(in crate::objects) fn check_object_domain<T, Kind>(
 where
   T: Base + AsBase<Kind>,
 {
-  let actor_id = if let Some(url) = expected_domain {
-    check_is_apub_id_valid(&url)?;
+  let object_id = if let Some(url) = expected_domain {
     let domain = url.domain().context(location_info!())?;
     apub.id(domain)?.context(location_info!())?
   } else {
-    let actor_id = apub.id_unchecked().context(location_info!())?;
-    check_is_apub_id_valid(&actor_id)?;
-    actor_id
+    apub.id_unchecked().context(location_info!())?
   };
-  Ok(actor_id.to_string())
+  check_is_apub_id_valid(&object_id)?;
+  Ok(object_id.to_string())
 }
 
 pub(in crate::objects) fn set_content_and_source<T, Kind1, Kind2>(
index ce16f8d136982488193e6327e9d81cbcf59b8800..a058d8b7ccbfeca48b7ab5adb112f4b8ae4cb638 100644 (file)
@@ -17,6 +17,7 @@ use activitystreams::{
 };
 use activitystreams_ext::Ext1;
 use anyhow::Context;
+use backtrace::Backtrace;
 use lemmy_db::{
   community::Community,
   post::{Post, PostForm},
@@ -32,6 +33,7 @@ use lemmy_utils::{
   LemmyError,
 };
 use lemmy_websocket::LemmyContext;
+use log::error;
 use url::Url;
 
 #[async_trait::async_trait(?Send)]
@@ -130,6 +132,15 @@ impl FromApub for PostForm {
     let community =
       get_or_fetch_and_upsert_community(community_actor_id, context, request_counter).await?;
 
+    if community.local && creator.local {
+      let page_id = page.id_unchecked().context(location_info!())?;
+      let bt = Backtrace::new();
+      error!(
+        "Lemmy is parsing a local post as remote, page id: {}, stack trace: {:?}",
+        page_id, bt
+      );
+    }
+
     let thumbnail_url = match &page.inner.image() {
       Some(any_image) => Image::from_any_base(
         any_image