mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 22:01:19 +00:00
Add logging to find bug (ref #1283)
Also simplify check_object_domain()
This commit is contained in:
parent
7d7fe5962a
commit
8fc4e1ecfe
4 changed files with 17 additions and 6 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1761,6 +1761,7 @@ dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"awc",
|
"awc",
|
||||||
"background-jobs",
|
"background-jobs",
|
||||||
|
"backtrace",
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
@ -46,3 +46,4 @@ anyhow = "1.0"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
background-jobs = " 0.8"
|
background-jobs = " 0.8"
|
||||||
reqwest = { version = "0.10", features = ["json"] }
|
reqwest = { version = "0.10", features = ["json"] }
|
||||||
|
backtrace = "0.3"
|
||||||
|
|
|
@ -48,16 +48,14 @@ pub(in crate::objects) fn check_object_domain<T, Kind>(
|
||||||
where
|
where
|
||||||
T: Base + AsBase<Kind>,
|
T: Base + AsBase<Kind>,
|
||||||
{
|
{
|
||||||
let actor_id = if let Some(url) = expected_domain {
|
let object_id = if let Some(url) = expected_domain {
|
||||||
check_is_apub_id_valid(&url)?;
|
|
||||||
let domain = url.domain().context(location_info!())?;
|
let domain = url.domain().context(location_info!())?;
|
||||||
apub.id(domain)?.context(location_info!())?
|
apub.id(domain)?.context(location_info!())?
|
||||||
} else {
|
} else {
|
||||||
let actor_id = apub.id_unchecked().context(location_info!())?;
|
apub.id_unchecked().context(location_info!())?
|
||||||
check_is_apub_id_valid(&actor_id)?;
|
|
||||||
actor_id
|
|
||||||
};
|
};
|
||||||
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>(
|
pub(in crate::objects) fn set_content_and_source<T, Kind1, Kind2>(
|
||||||
|
|
|
@ -17,6 +17,7 @@ use activitystreams::{
|
||||||
};
|
};
|
||||||
use activitystreams_ext::Ext1;
|
use activitystreams_ext::Ext1;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
use backtrace::Backtrace;
|
||||||
use lemmy_db::{
|
use lemmy_db::{
|
||||||
community::Community,
|
community::Community,
|
||||||
post::{Post, PostForm},
|
post::{Post, PostForm},
|
||||||
|
@ -32,6 +33,7 @@ use lemmy_utils::{
|
||||||
LemmyError,
|
LemmyError,
|
||||||
};
|
};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
use log::error;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[async_trait::async_trait(?Send)]
|
#[async_trait::async_trait(?Send)]
|
||||||
|
@ -130,6 +132,15 @@ impl FromApub for PostForm {
|
||||||
let community =
|
let community =
|
||||||
get_or_fetch_and_upsert_community(community_actor_id, context, request_counter).await?;
|
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() {
|
let thumbnail_url = match &page.inner.image() {
|
||||||
Some(any_image) => Image::from_any_base(
|
Some(any_image) => Image::from_any_base(
|
||||||
any_image
|
any_image
|
||||||
|
|
Loading…
Reference in a new issue