feat: Chat request implementation #14
1 changed files with 32 additions and 40 deletions
|
@ -103,14 +103,12 @@ impl UsersStatusExt for DatabaseConnection {
|
|||
whitelister: &UserModel,
|
||||
target_public_key: &PublicKey,
|
||||
) -> ServerResult<bool> {
|
||||
whitelister
|
||||
.find_related(UsersStatusEntity)
|
||||
.filter(
|
||||
UsersStatusColumn::Target
|
||||
.eq(target_public_key.to_string())
|
||||
.and(UsersStatusColumn::Status.eq(AccessStatus::Whitelisted)),
|
||||
get_user_status(
|
||||
awiteb marked this conversation as resolved
|
||||
self,
|
||||
whitelister,
|
||||
target_public_key,
|
||||
AccessStatus::Whitelisted,
|
||||
)
|
||||
.one(self)
|
||||
.await
|
||||
.map(|u| u.is_some())
|
||||
.map_err(Into::into)
|
||||
|
@ -121,14 +119,12 @@ impl UsersStatusExt for DatabaseConnection {
|
|||
blacklister: &UserModel,
|
||||
target_public_key: &PublicKey,
|
||||
) -> ServerResult<bool> {
|
||||
blacklister
|
||||
.find_related(UsersStatusEntity)
|
||||
.filter(
|
||||
UsersStatusColumn::Target
|
||||
.eq(target_public_key.to_string())
|
||||
.and(UsersStatusColumn::Status.eq(AccessStatus::Blacklisted)),
|
||||
get_user_status(
|
||||
self,
|
||||
blacklister,
|
||||
target_public_key,
|
||||
AccessStatus::Blacklisted,
|
||||
)
|
||||
.one(self)
|
||||
.await
|
||||
.map(|u| u.is_some())
|
||||
.map_err(Into::into)
|
||||
|
@ -223,14 +219,12 @@ impl UsersStatusExt for DatabaseConnection {
|
|||
whitelister: &UserModel,
|
||||
target_public_key: &PublicKey,
|
||||
) -> ServerResult<()> {
|
||||
if let Some(target_user) = whitelister
|
||||
.find_related(UsersStatusEntity)
|
||||
.filter(
|
||||
UsersStatusColumn::Target
|
||||
.eq(target_public_key.to_string())
|
||||
.and(UsersStatusColumn::Status.eq(AccessStatus::Whitelisted)),
|
||||
if let Some(target_user) = get_user_status(
|
||||
self,
|
||||
whitelister,
|
||||
target_public_key,
|
||||
AccessStatus::Whitelisted,
|
||||
)
|
||||
.one(self)
|
||||
.await?
|
||||
{
|
||||
target_user.delete(self).await?;
|
||||
|
@ -243,14 +237,12 @@ impl UsersStatusExt for DatabaseConnection {
|
|||
blacklister: &UserModel,
|
||||
target_public_key: &PublicKey,
|
||||
) -> ServerResult<()> {
|
||||
if let Some(target_user) = blacklister
|
||||
.find_related(UsersStatusEntity)
|
||||
.filter(
|
||||
UsersStatusColumn::Target
|
||||
.eq(target_public_key.to_string())
|
||||
.and(UsersStatusColumn::Status.eq(AccessStatus::Blacklisted)),
|
||||
if let Some(target_user) = get_user_status(
|
||||
self,
|
||||
blacklister,
|
||||
target_public_key,
|
||||
AccessStatus::Blacklisted,
|
||||
)
|
||||
.one(self)
|
||||
.await?
|
||||
{
|
||||
target_user.delete(self).await?;
|
||||
|
|
Loading…
Reference in a new issue
you can use
get_user_status
here and alsois_blacklisted
. also inremove...
functions