add: block list stacks
This commit is contained in:
parent
9bb5f38f76
commit
b71ae1f5a4
28 changed files with 700 additions and 219 deletions
|
@ -91,9 +91,39 @@ impl DataManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
StackMode::BlockList => {
|
||||
return Err(Error::MiscError(
|
||||
"You should use `get_stack_users` for this type".to_string(),
|
||||
));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn get_stack_users(&self, id: usize, batch: usize, page: usize) -> Result<Vec<User>> {
|
||||
let stack = self.get_stack_by_id(id).await?;
|
||||
|
||||
if stack.mode != StackMode::BlockList {
|
||||
return Err(Error::MiscError(
|
||||
"You should use `get_stack_posts` for this type".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
// build list
|
||||
let mut out = Vec::new();
|
||||
let mut i = 0;
|
||||
|
||||
for user in stack.users.iter().skip(batch * page) {
|
||||
if i == batch {
|
||||
break;
|
||||
}
|
||||
|
||||
out.push(self.get_user_by_id(user.to_owned()).await?);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Get all stacks by user.
|
||||
///
|
||||
/// # Arguments
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue