add: allow free users to create 2 invites
This commit is contained in:
parent
626c6711ef
commit
2f83497f98
4 changed files with 66 additions and 19 deletions
|
@ -420,6 +420,17 @@ impl DataManager {
|
|||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
// delete invite codes
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"DELETE FROM invite_codes WHERE owner = $1",
|
||||
&[&(id as i64)]
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
return Err(Error::DatabaseError(e.to_string()));
|
||||
}
|
||||
|
||||
// delete message reactions
|
||||
let res = execute!(
|
||||
&conn,
|
||||
|
@ -479,6 +490,16 @@ impl DataManager {
|
|||
self.delete_poll(poll.id, &user).await?;
|
||||
}
|
||||
|
||||
// free up invite code
|
||||
if self.0.0.security.enable_invite_codes {
|
||||
if user.invite_code != 0 && self.get_invite_code_by_id(user.invite_code).await.is_ok() {
|
||||
// we're checking if the code is ok because the owner might've deleted their account,
|
||||
// deleting all of their invite codes as well
|
||||
self.update_invite_code_is_used(user.invite_code, false)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
// ...
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue