mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-14 08:23:59 +00:00
Limit number of items read from community outbox (#84)
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
This commit is contained in:
parent
4981eb38fb
commit
9a343cfe8b
2 changed files with 4 additions and 2 deletions
|
@ -160,7 +160,7 @@ pub fn is_valid_username(name: &str) -> bool {
|
||||||
|
|
||||||
// Can't do a regex here, reverse lookarounds not supported
|
// Can't do a regex here, reverse lookarounds not supported
|
||||||
pub fn is_valid_preferred_username(preferred_username: &str) -> bool {
|
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() >= 3
|
||||||
&& preferred_username.len() <= 20
|
&& preferred_username.len() <= 20
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,7 +325,9 @@ async fn fetch_remote_community(
|
||||||
let outbox =
|
let outbox =
|
||||||
fetch_remote_object::<OrderedCollection>(client, &community.get_outbox_url()?).await?;
|
fetch_remote_object::<OrderedCollection>(client, &community.get_outbox_url()?).await?;
|
||||||
let outbox_items = outbox.items().context(location_info!())?.clone();
|
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 page = PageExt::from_any_base(o)?.context(location_info!())?;
|
||||||
let post = PostForm::from_apub(&page, client, pool, None).await?;
|
let post = PostForm::from_apub(&page, client, pool, None).await?;
|
||||||
let post_ap_id = post.ap_id.clone();
|
let post_ap_id = post.ap_id.clone();
|
||||||
|
|
Loading…
Reference in a new issue