filters: add limits to follow filters
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -85,11 +85,11 @@ pub fn since_optimize_filter(filter: Filter, notes: &[NoteRef]) -> Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_limit() -> u64 {
|
pub fn default_limit() -> u64 {
|
||||||
250
|
500
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_remote_limit() -> u64 {
|
pub fn default_remote_limit() -> u64 {
|
||||||
150
|
250
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct FilteredTags {
|
pub struct FilteredTags {
|
||||||
@@ -99,22 +99,22 @@ pub struct FilteredTags {
|
|||||||
|
|
||||||
impl FilteredTags {
|
impl FilteredTags {
|
||||||
pub fn into_follow_filter(self) -> Vec<Filter> {
|
pub fn into_follow_filter(self) -> Vec<Filter> {
|
||||||
self.into_filter([1])
|
self.into_filter([1], default_limit())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make this more general
|
// TODO: make this more general
|
||||||
pub fn into_filter<I>(self, kinds: I) -> Vec<Filter>
|
pub fn into_filter<I>(self, kinds: I, limit: u64) -> Vec<Filter>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = u64> + Copy,
|
I: IntoIterator<Item = u64> + Copy,
|
||||||
{
|
{
|
||||||
let mut filters: Vec<Filter> = Vec::with_capacity(2);
|
let mut filters: Vec<Filter> = Vec::with_capacity(2);
|
||||||
|
|
||||||
if let Some(authors) = self.authors {
|
if let Some(authors) = self.authors {
|
||||||
filters.push(authors.kinds(kinds).build())
|
filters.push(authors.kinds(kinds).limit(limit).build())
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(hashtags) = self.hashtags {
|
if let Some(hashtags) = self.hashtags {
|
||||||
filters.push(hashtags.kinds(kinds).build())
|
filters.push(hashtags.kinds(kinds).limit(limit).build())
|
||||||
}
|
}
|
||||||
|
|
||||||
filters
|
filters
|
||||||
|
|||||||
Reference in New Issue
Block a user