add: outbox tab on profile
tab is only visible to profile owner and mods
This commit is contained in:
parent
5dec98d698
commit
7bda718082
12 changed files with 264 additions and 9 deletions
|
@ -97,6 +97,32 @@ impl DataManager {
|
|||
Ok(res.unwrap())
|
||||
}
|
||||
|
||||
/// Get all questions by `owner` (paginated).
|
||||
pub async fn get_questions_by_owner_paginated(
|
||||
&self,
|
||||
owner: usize,
|
||||
batch: usize,
|
||||
page: usize,
|
||||
) -> Result<Vec<Question>> {
|
||||
let conn = match self.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
||||
let res = query_rows!(
|
||||
&conn,
|
||||
"SELECT * FROM questions WHERE owner = $1 AND NOT context LIKE '%\"is_nsfw\":true%' ORDER BY created DESC LIMIT $2 OFFSET $3",
|
||||
&[&(owner as i64), &(batch as i64), &((page * batch) as i64)],
|
||||
|x| { Self::get_question_from_row(x) }
|
||||
);
|
||||
|
||||
if res.is_err() {
|
||||
return Err(Error::GeneralNotFound("question".to_string()));
|
||||
}
|
||||
|
||||
Ok(res.unwrap())
|
||||
}
|
||||
|
||||
/// Get all questions by `receiver`.
|
||||
pub async fn get_questions_by_receiver(&self, receiver: usize) -> Result<Vec<Question>> {
|
||||
let conn = match self.connect().await {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue