add: don't allow poll creator to vote

add: unfollow user when you block them
add: force other user to unfollow you by blocking them
add: leave receiver communities when you block them
This commit is contained in:
trisua 2025-06-05 16:23:57 -04:00
parent 5a330b7a18
commit 460e87e90e
11 changed files with 165 additions and 17 deletions

View file

@ -237,11 +237,14 @@ impl DataManager {
}
/// Get the poll of the given post (if some).
///
/// # Returns
/// `Result<Option<(poll, voted, expired)>>`
pub async fn get_post_poll(
&self,
post: &Post,
user: &Option<User>,
) -> Result<Option<(Poll, bool)>> {
) -> Result<Option<(Poll, bool, bool)>> {
let user = if let Some(ua) = user {
ua
} else {
@ -250,12 +253,16 @@ impl DataManager {
if post.poll_id != 0 {
Ok(Some(match self.get_poll_by_id(post.poll_id).await {
Ok(p) => (
p,
self.get_pollvote_by_owner_poll(user.id, post.poll_id)
.await
.is_ok(),
),
Ok(p) => {
let expired = (unix_epoch_timestamp() as usize) - p.created > p.expires;
(
p,
self.get_pollvote_by_owner_poll(user.id, post.poll_id)
.await
.is_ok(),
expired,
)
}
Err(_) => return Err(Error::MiscError("Invalid poll ID attached".to_string())),
}))
} else {
@ -275,7 +282,7 @@ impl DataManager {
User,
Option<(User, Post)>,
Option<(Question, User)>,
Option<(Poll, bool)>,
Option<(Poll, bool, bool)>,
)>,
> {
let mut out = Vec::new();
@ -374,7 +381,7 @@ impl DataManager {
Community,
Option<(User, Post)>,
Option<(Question, User)>,
Option<(Poll, bool)>,
Option<(Poll, bool, bool)>,
)>,
> {
let mut out = Vec::new();