1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 19:41:09 +00:00

fix tests

This commit is contained in:
Felix Ableitner 2023-11-27 11:59:05 +01:00
parent c22df74b99
commit 2b0fbc6236

View file

@ -46,6 +46,7 @@ impl UpdateRemoteArticle {
kind: Default::default(), kind: Default::default(),
id, id,
}; };
dbg!(&update);
local_instance local_instance
.send(update, vec![article_instance.inbox], data) .send(update, vec![article_instance.inbox], data)
.await?; .await?;
@ -72,34 +73,22 @@ impl ActivityHandler for UpdateRemoteArticle {
/// Received on article origin instances /// Received on article origin instances
async fn receive(self, data: &Data<Self::DataType>) -> Result<(), Self::Error> { async fn receive(self, data: &Data<Self::DataType>) -> Result<(), Self::Error> {
match DbEdit::from_json(self.object.clone(), data).await { let edit = DbEdit::from_json(self.object.clone(), data).await?;
Ok(edit) => { let article_text = {
let article = {
let lock = data.articles.lock().unwrap(); let lock = data.articles.lock().unwrap();
let article = lock.get(self.object.object.inner()).unwrap(); lock.get(self.object.object.inner()).unwrap().text.clone()
article.clone()
}; };
{
let patch = Patch::from_str(&edit.diff)?; let patch = Patch::from_str(&edit.diff)?;
let applied = apply(&article.text, &patch)?;
match apply(&article_text, &patch) {
Ok(applied) => {
let article = {
let mut lock = data.articles.lock().unwrap(); let mut lock = data.articles.lock().unwrap();
let article = lock.get_mut(edit.article_id.inner()).unwrap(); let article = lock.get_mut(edit.article_id.inner()).unwrap();
article.edits.push(edit.clone());
article.text = applied; article.text = applied;
} article.clone()
let local_instance = data.local_instance();
let id = generate_activity_id(local_instance.ap_id.inner())?;
let update = UpdateLocalArticle {
actor: local_instance.ap_id.clone(),
to: local_instance.follower_ids(),
object: article.clone().into_json(data).await?,
kind: Default::default(),
id,
}; };
data.local_instance() UpdateLocalArticle::send(article, data).await?;
.send_to_followers(update, data)
.await?;
} }
Err(_e) => { Err(_e) => {
let user_instance = self.actor.dereference(data).await?; let user_instance = self.actor.dereference(data).await?;