pub fn unban(session_id: &str, user: &User, room: &Room) -> Result<Response, Rejection> {
    if !is_session_id(&session_id) {
        warn!("Ignoring unban request: invalid session_id.");
        return Err(Error::ValidationFailed.into());
    }

    let conn = storage::get_conn()?;
    require_authorization(
        &conn,
        user,
        room,
        AuthorizationRequired { moderator: true, ..Default::default() },
    )?;

    let count = match conn
        .prepare_cached(
            "UPDATE user_permission_overrides SET banned = FALSE \
            WHERE room = ? AND user IN (SELECT id FROM users WHERE session_id = ?)",
        )
        .map_err(db_error)?
        .execute(params![room.id, session_id])
    {
        Ok(count) => count,
        Err(e) => {
            error!("Failed to unban user: {}", e);
            return Err(Error::DatabaseFailedInternally.into());
        }
    };

    let status_code =
        if count > 0 { StatusCode::OK.as_u16() } else { StatusCode::NOT_FOUND.as_u16() };
    Ok(warp::reply::json(&models::StatusCode { status_code }).into_response())
}
/// Unbans the given `public_key` if the requesting user is a moderator.
Unbans the given `public_key` if the requesting user is a moderator.
Unbans the given ` public_key ` if the requesting user is a moderator .
pub fn unban(session_id: &str, user: &User, room: &Room) -> Result<Response, Rejection> {
    if !is_session_id(&session_id) {
        warn!("Ignoring unban request: invalid session_id.");
        return Err(Error::ValidationFailed.into());
    }
    let conn = storage::get_conn()?;
    require_authorization(
        &conn,
        user,
        room,
        AuthorizationRequired { moderator: true, ..Default::default() },
    )?;
    let count = match conn
        .prepare_cached(
            "UPDATE user_permission_overrides SET banned = FALSE \
            WHERE room = ? AND user IN (SELECT id FROM users WHERE session_id = ?)",
        )
        .map_err(db_error)?
        .execute(params![room.id, session_id])
    {
        Ok(count) => count,
        Err(e) => {
            error!("Failed to unban user: {}", e);
            return Err(Error::DatabaseFailedInternally.into());
        }
    };
    let status_code =
        if count > 0 { StatusCode::OK.as_u16() } else { StatusCode::NOT_FOUND.as_u16() };
    Ok(warp::reply::json(&models::StatusCode { status_code }).into_response())
}
pub fn unban ( session_id : & str , user : & User , room : & Room ) -> Result < Response , Rejection > { if ! is_session_id ( & session_id ) { warn ! ( " " ) ; return Err ( Error :: ValidationFailed . into ( ) ) ; } let conn = storage :: get_conn ( ) ? ; require_authorization ( & conn , user , room , AuthorizationRequired { moderator : true , .. Default :: default ( ) } , ) ? ; let count = match conn . prepare_cached ( " \
 " , ) . map_err ( db_error ) ? . execute ( params ! [ room id session_id ] ) { Ok ( count ) => count , Err ( e ) => { error ! ( " " e ) ; return Err ( Error :: DatabaseFailedInternally . into ( ) ) ; } } ; let status_code = if count > 0 { StatusCode :: OK . as_u16 ( ) } else { StatusCode :: NOT_FOUND . as_u16 ( ) } ; Ok ( warp :: reply :: json ( & models :: StatusCode { status_code } ) . into_response ( ) ) }
Unbans the given `public_key` if the requesting user is a moderator.
Unbans the given ` public_key ` if the requesting user is a moderator .
session_id
&str
user
&User
room
&Room
session_id
&str
user
&User
room
&Room