add: polls
This commit is contained in:
parent
4dfa09207e
commit
6555324650
29 changed files with 339 additions and 56 deletions
crates/core/src/database
|
@ -245,7 +245,7 @@ impl DataManager {
|
|||
let user = if let Some(ua) = user {
|
||||
ua
|
||||
} else {
|
||||
return Err(Error::MiscError("Could not get user for pull".to_string()));
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
if post.poll_id != 0 {
|
||||
|
@ -259,7 +259,7 @@ impl DataManager {
|
|||
Err(_) => return Err(Error::MiscError("Invalid poll ID attached".to_string())),
|
||||
}))
|
||||
} else {
|
||||
return Err(Error::MiscError("Invalid poll ID attached".to_string()));
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,15 +374,10 @@ impl DataManager {
|
|||
Community,
|
||||
Option<(User, Post)>,
|
||||
Option<(Question, User)>,
|
||||
Option<(Poll, bool)>,
|
||||
)>,
|
||||
> {
|
||||
let mut out: Vec<(
|
||||
Post,
|
||||
User,
|
||||
Community,
|
||||
Option<(User, Post)>,
|
||||
Option<(Question, User)>,
|
||||
)> = Vec::new();
|
||||
let mut out = Vec::new();
|
||||
|
||||
let mut seen_before: HashMap<(usize, usize), (User, Community)> = HashMap::new();
|
||||
let mut seen_user_follow_statuses: HashMap<(usize, usize), bool> = HashMap::new();
|
||||
|
@ -403,6 +398,7 @@ impl DataManager {
|
|||
community.to_owned(),
|
||||
self.get_post_reposting(&post, ignore_users, user).await,
|
||||
self.get_post_question(&post, ignore_users).await?,
|
||||
self.get_post_poll(&post, user).await?,
|
||||
));
|
||||
} else {
|
||||
let ua = self.get_user_by_id(owner).await?;
|
||||
|
@ -450,6 +446,7 @@ impl DataManager {
|
|||
community,
|
||||
self.get_post_reposting(&post, ignore_users, user).await,
|
||||
self.get_post_question(&post, ignore_users).await?,
|
||||
self.get_post_poll(&post, user).await?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -1423,7 +1420,7 @@ impl DataManager {
|
|||
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"INSERT INTO posts VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, null, $13)",
|
||||
"INSERT INTO posts VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, DEFAULT, $13)",
|
||||
params![
|
||||
&(data.id as i64),
|
||||
&(data.created as i64),
|
||||
|
@ -1541,6 +1538,11 @@ impl DataManager {
|
|||
self.delete_upload(upload).await?;
|
||||
}
|
||||
|
||||
// remove poll
|
||||
if y.poll_id != 0 {
|
||||
self.delete_poll(y.poll_id, user).await?;
|
||||
}
|
||||
|
||||
// return
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue