1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-25 23:01:08 +00:00

Fix articles created with invalid ap_id

This commit is contained in:
Felix Ableitner 2024-03-12 10:51:32 +01:00
parent 0b2bfbd3ae
commit e56e8adbdf
3 changed files with 11 additions and 7 deletions

View file

@ -49,11 +49,12 @@ pub(in crate::backend::api) async fn create_article(
}
let local_instance = DbInstance::read_local_instance(&data)?;
let escaped_title = create_article.title.replace(" ", "_");
let ap_id = ObjectId::parse(&format!(
"{}://{}/article/{}",
http_protocol_str(),
extract_domain(&local_instance.ap_id),
create_article.title
escaped_title
))?;
let form = DbArticleForm {
title: create_article.title,
@ -75,6 +76,7 @@ pub(in crate::backend::api) async fn create_article(
let _ = edit_article(Extension(user), data.reset_request_count(), Form(edit_data)).await?;
let article_view = DbArticle::read_view(article.id, &data)?;
dbg!(&article_view);
CreateArticle::send_to_followers(article_view.article.clone(), &data).await?;
Ok(Json(article_view))

View file

@ -66,12 +66,14 @@ impl Object for DbArticle {
expected_domain: &Url,
_data: &Data<Self::DataType>,
) -> Result<(), Self::Error> {
verify_domains_match(json.id.inner(), expected_domain)?;
dbg!(&json);
dbg!(verify_domains_match(json.id.inner(), expected_domain))?;
Ok(())
}
async fn from_json(json: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, Self::Error> {
let instance = json.attributed_to.dereference(data).await?;
dbg!(&json);
let instance = dbg!(json.attributed_to.dereference(data).await)?;
let form = DbArticleForm {
title: json.name,
text: json.content,
@ -80,9 +82,9 @@ impl Object for DbArticle {
instance_id: instance.id,
protected: json.protected,
};
let article = DbArticle::create_or_update(form, data)?;
let article = dbg!(DbArticle::create_or_update(form, data))?;
json.edits.dereference(&article, data).await?;
dbg!(json.edits.dereference(&article, data).await)?;
Ok(article)
}

View file

@ -11,8 +11,8 @@ pub async fn main() -> ibis_lib::backend::error::MyResult<()> {
env_logger::builder()
.filter_level(LevelFilter::Warn)
.filter_module("activitypub_federation", LevelFilter::Info)
.filter_module("ibis", LevelFilter::Info)
.filter_module("activitypub_federation", LevelFilter::Debug)
.filter_module("ibis", LevelFilter::Debug)
.init();
let ibis_config = IbisConfig::read()?;