add: followers/following ui
This commit is contained in:
parent
17564ede49
commit
e183a01887
13 changed files with 469 additions and 86 deletions
|
@ -84,6 +84,10 @@ impl DataManager {
|
|||
return Err(Error::DataTooShort("password".to_string()));
|
||||
}
|
||||
|
||||
if self.0.banned_usernames.contains(&data.username) {
|
||||
return Err(Error::MiscError("This username cannot be used".to_string()));
|
||||
}
|
||||
|
||||
// make sure username isn't taken
|
||||
if self.get_user_by_username(&data.username).await.is_ok() {
|
||||
return Err(Error::UsernameInUse);
|
||||
|
|
|
@ -145,6 +145,36 @@ impl DataManager {
|
|||
Ok(res.unwrap())
|
||||
}
|
||||
|
||||
/// Complete a vector of just userfollows with their receiver as well.
|
||||
pub async fn fill_userfollows_with_receiver(
|
||||
&self,
|
||||
userfollows: Vec<UserFollow>,
|
||||
) -> Result<Vec<(UserFollow, User)>> {
|
||||
let mut out: Vec<(UserFollow, User)> = Vec::new();
|
||||
|
||||
for userfollow in userfollows {
|
||||
let receiver = userfollow.receiver.clone();
|
||||
out.push((userfollow, self.get_user_by_id(receiver).await?));
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Complete a vector of just userfollows with their initiator as well.
|
||||
pub async fn fill_userfollows_with_initiator(
|
||||
&self,
|
||||
userfollows: Vec<UserFollow>,
|
||||
) -> Result<Vec<(UserFollow, User)>> {
|
||||
let mut out: Vec<(UserFollow, User)> = Vec::new();
|
||||
|
||||
for userfollow in userfollows {
|
||||
let initiator = userfollow.initiator.clone();
|
||||
out.push((userfollow, self.get_user_by_id(initiator).await?));
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Create a new user follow in the database.
|
||||
///
|
||||
/// # Arguments
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue