mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 08:55:16 +00:00
Can get a user id included in a POST request
This commit is contained in:
@ -107,6 +107,11 @@ impl QueryInfo {
|
||||
-> Result<Vec<E>, Box<dyn Error>> {
|
||||
query(self, process_function)
|
||||
}
|
||||
|
||||
/// Execute count query
|
||||
pub fn exec_count(self) -> ResultBoxError<usize> {
|
||||
count(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Struct used to read the result of a request
|
||||
|
@ -52,4 +52,11 @@ fn exec_get_user_query(query: database::QueryInfo) -> ResultBoxError<User> {
|
||||
account_image_visibility,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Check out whether a given id maps to a user or not
|
||||
pub fn exists(id: UserID) -> ResultBoxError<bool> {
|
||||
Ok(database::QueryInfo::new(USERS_TABLE)
|
||||
.cond_i64("ID", id)
|
||||
.exec_count()? > 0)
|
||||
}
|
Reference in New Issue
Block a user