mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 00:45:18 +00:00
Can get a user id included in a POST request
This commit is contained in:
@ -12,7 +12,7 @@ use crate::data::api_client::APIClient;
|
||||
use crate::data::config::conf;
|
||||
use crate::data::error::{ExecError, ResultBoxError};
|
||||
use crate::data::user::UserID;
|
||||
use crate::helpers::{account_helper, api_helper};
|
||||
use crate::helpers::{account_helper, api_helper, user_helper};
|
||||
|
||||
/// Http request handler
|
||||
///
|
||||
@ -303,4 +303,19 @@ impl HttpRequestHandler {
|
||||
|
||||
Ok(list)
|
||||
}
|
||||
|
||||
/// Get the ID of a user included in a POST request
|
||||
pub fn post_user_id(&mut self, name: &str) -> ResultBoxError<UserID> {
|
||||
let user_id = self.post_i64(name)?;
|
||||
|
||||
if user_id < 1 {
|
||||
self.bad_request(format!("Invalid user specified in '{}'!", name))?;
|
||||
}
|
||||
|
||||
if !user_helper::exists(user_id)? {
|
||||
self.not_found(format!("User with ID {} not found!", user_id))?;
|
||||
}
|
||||
|
||||
Ok(user_id)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user