Make RemoteFatchActor follow activitystreams change

This commit is contained in:
Kitaiti Makoto 2022-01-30 00:21:25 +09:00
parent 2ee19a866d
commit 00d31e323f

View File

@ -8,7 +8,10 @@ use crate::{
CONFIG,
USER_CHAN,
};
use activitypub::activity::Create;
use activitystreams::{
activity::{ActorAndObjectRef, Create},
object::{kind::ArticleType, Article},
};
use plume_common::activity_pub::inbox::FromId;
use riker::actors::{Actor, ActorFactoryArgs, ActorRefFactory, Context, Sender, Subscribe, Tell};
use std::sync::Arc;
@ -71,13 +74,17 @@ fn fetch_and_cache_articles(user: &Arc<User>, conn: &DbConn) {
match create_acts {
Ok(create_acts) => {
for create_act in create_acts {
match create_act.object() {
Ok(article) => {
let article = create_act
.object_field_ref()
.as_one()
.and_then(|object| object.extend::<Article, ArticleType>().expect("exists"));
match article {
Some(article) => {
Post::from_activity(conn, article)
.expect("Article from remote user couldn't be saved");
info!("Fetched article from remote user");
}
Err(e) => warn!("Error while fetching articles in background: {:?}", e),
None => warn!("No article found"),
}
}
}