Adjust chat permisisons to allow deletion for channel admins
This commit is contained in:
parent
b168bded1d
commit
162f625716
2 changed files with 28 additions and 8 deletions
|
@ -337,8 +337,22 @@ impl Database {
|
|||
.filter(channel_message::Column::SenderId.eq(user_id))
|
||||
.exec(&*tx)
|
||||
.await?;
|
||||
|
||||
if result.rows_affected == 0 {
|
||||
Err(anyhow!("no such message"))?;
|
||||
if self
|
||||
.check_user_is_channel_admin(channel_id, user_id, &*tx)
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
let result = channel_message::Entity::delete_by_id(message_id)
|
||||
.exec(&*tx)
|
||||
.await?;
|
||||
if result.rows_affected == 0 {
|
||||
Err(anyhow!("no such message"))?;
|
||||
}
|
||||
} else {
|
||||
Err(anyhow!("operation could not be completed"))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(participant_connection_ids)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue