mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-05 20:15:01 +00:00
Simplify fetch_posts code
This commit is contained in:
parent
507686eaf7
commit
1836d017f9
1 changed files with 3 additions and 9 deletions
|
@ -75,18 +75,12 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_remote_community_posts(
|
fn fetch_remote_community_posts(
|
||||||
instance: &Instance,
|
|
||||||
community: &Community,
|
community: &Community,
|
||||||
conn: &PgConnection,
|
conn: &PgConnection,
|
||||||
) -> Result<Vec<Post>, Error> {
|
) -> Result<Vec<Post>, Error> {
|
||||||
// TODO: need to add outbox field to Community
|
// TODO: need to add outbox field to Community
|
||||||
let endpoint = Url::parse(&format!(
|
let outbox_url = Url::parse(&format!("{}/outbox", community.actor_id))?;
|
||||||
"http://{}/federation/c/{}",
|
let outbox = fetch_remote_object::<OrderedCollection>(&outbox_url)?;
|
||||||
instance.domain, community.name
|
|
||||||
))?;
|
|
||||||
let group = fetch_remote_object::<GroupExt>(&endpoint)?;
|
|
||||||
let outbox_uri = Url::parse(&group.extension.get_outbox().to_string())?;
|
|
||||||
let outbox = fetch_remote_object::<OrderedCollection>(&outbox_uri)?;
|
|
||||||
let items = outbox.collection_props.get_many_items_base_boxes();
|
let items = outbox.collection_props.get_many_items_base_boxes();
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
|
@ -129,7 +123,7 @@ pub fn fetch_all(conn: &PgConnection) -> Result<(), Error> {
|
||||||
if let Some(community_list) = node_info.metadata.community_list_url {
|
if let Some(community_list) = node_info.metadata.community_list_url {
|
||||||
let communities = fetch_communities_from_instance(&community_list, conn)?;
|
let communities = fetch_communities_from_instance(&community_list, conn)?;
|
||||||
for c in communities {
|
for c in communities {
|
||||||
fetch_remote_community_posts(instance, &c, conn)?;
|
fetch_remote_community_posts(&c, conn)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!(
|
warn!(
|
||||||
|
|
Loading…
Reference in a new issue