]> Untitled Git - lemmy.git/commitdiff
Limit number of items read from community outbox (#84)
authornutomic <nutomic@noreply.yerbamate.dev>
Thu, 13 Aug 2020 13:20:35 +0000 (13:20 +0000)
committerdessalines <dessalines@noreply.yerbamate.dev>
Thu, 13 Aug 2020 13:20:35 +0000 (13:20 +0000)
Limit number of items read from community outbox

Co-authored-by: Felix Ableitner <me@nutomic.com>
Reviewed-on: https://yerbamate.dev/LemmyNet/lemmy/pulls/84

server/lemmy_utils/src/lib.rs
server/src/apub/fetcher.rs

index d4c75bf31593adb8034191cff9b9756f3ab85769..41cdcec8e3b842706b3a4f72caac355561d28e29 100644 (file)
@@ -160,7 +160,7 @@ pub fn is_valid_username(name: &str) -> bool {
 
 // Can't do a regex here, reverse lookarounds not supported
 pub fn is_valid_preferred_username(preferred_username: &str) -> bool {
-  !preferred_username.starts_with("@")
+  !preferred_username.starts_with('@')
     && preferred_username.len() >= 3
     && preferred_username.len() <= 20
 }
index 5fcf6ad97a1067c29816ba56974acad3b9a8329d..d083e10f429678db34e62c8009072e5758147889 100644 (file)
@@ -325,7 +325,9 @@ async fn fetch_remote_community(
   let outbox =
     fetch_remote_object::<OrderedCollection>(client, &community.get_outbox_url()?).await?;
   let outbox_items = outbox.items().context(location_info!())?.clone();
-  for o in outbox_items.many().context(location_info!())? {
+  let outbox_items = outbox_items.many().context(location_info!())?;
+  let outbox_items = outbox_items[0..20].to_vec();
+  for o in outbox_items {
     let page = PageExt::from_any_base(o)?.context(location_info!())?;
     let post = PostForm::from_apub(&page, client, pool, None).await?;
     let post_ap_id = post.ap_id.clone();