mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 20:31:10 +00:00
Fix articles created with invalid ap_id
This commit is contained in:
parent
0b2bfbd3ae
commit
e56e8adbdf
3 changed files with 11 additions and 7 deletions
|
@ -49,11 +49,12 @@ pub(in crate::backend::api) async fn create_article(
|
||||||
}
|
}
|
||||||
|
|
||||||
let local_instance = DbInstance::read_local_instance(&data)?;
|
let local_instance = DbInstance::read_local_instance(&data)?;
|
||||||
|
let escaped_title = create_article.title.replace(" ", "_");
|
||||||
let ap_id = ObjectId::parse(&format!(
|
let ap_id = ObjectId::parse(&format!(
|
||||||
"{}://{}/article/{}",
|
"{}://{}/article/{}",
|
||||||
http_protocol_str(),
|
http_protocol_str(),
|
||||||
extract_domain(&local_instance.ap_id),
|
extract_domain(&local_instance.ap_id),
|
||||||
create_article.title
|
escaped_title
|
||||||
))?;
|
))?;
|
||||||
let form = DbArticleForm {
|
let form = DbArticleForm {
|
||||||
title: create_article.title,
|
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 _ = edit_article(Extension(user), data.reset_request_count(), Form(edit_data)).await?;
|
||||||
|
|
||||||
let article_view = DbArticle::read_view(article.id, &data)?;
|
let article_view = DbArticle::read_view(article.id, &data)?;
|
||||||
|
dbg!(&article_view);
|
||||||
CreateArticle::send_to_followers(article_view.article.clone(), &data).await?;
|
CreateArticle::send_to_followers(article_view.article.clone(), &data).await?;
|
||||||
|
|
||||||
Ok(Json(article_view))
|
Ok(Json(article_view))
|
||||||
|
|
|
@ -66,12 +66,14 @@ impl Object for DbArticle {
|
||||||
expected_domain: &Url,
|
expected_domain: &Url,
|
||||||
_data: &Data<Self::DataType>,
|
_data: &Data<Self::DataType>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
verify_domains_match(json.id.inner(), expected_domain)?;
|
dbg!(&json);
|
||||||
|
dbg!(verify_domains_match(json.id.inner(), expected_domain))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn from_json(json: Self::Kind, data: &Data<Self::DataType>) -> Result<Self, Self::Error> {
|
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 {
|
let form = DbArticleForm {
|
||||||
title: json.name,
|
title: json.name,
|
||||||
text: json.content,
|
text: json.content,
|
||||||
|
@ -80,9 +82,9 @@ impl Object for DbArticle {
|
||||||
instance_id: instance.id,
|
instance_id: instance.id,
|
||||||
protected: json.protected,
|
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)
|
Ok(article)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ pub async fn main() -> ibis_lib::backend::error::MyResult<()> {
|
||||||
|
|
||||||
env_logger::builder()
|
env_logger::builder()
|
||||||
.filter_level(LevelFilter::Warn)
|
.filter_level(LevelFilter::Warn)
|
||||||
.filter_module("activitypub_federation", LevelFilter::Info)
|
.filter_module("activitypub_federation", LevelFilter::Debug)
|
||||||
.filter_module("ibis", LevelFilter::Info)
|
.filter_module("ibis", LevelFilter::Debug)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let ibis_config = IbisConfig::read()?;
|
let ibis_config = IbisConfig::read()?;
|
||||||
|
|
Loading…
Reference in a new issue