add: hide posts from users who have blocked you from timelines

This commit is contained in:
trisua 2025-05-29 18:59:53 -04:00
parent 22ae479bd7
commit 8de5c0ea76
10 changed files with 84 additions and 81 deletions

View file

@ -706,7 +706,6 @@ impl DataManager {
auto_method!(update_user_notification_count(i32)@get_user_by_id -> "UPDATE users SET notification_count = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_user);
auto_method!(incr_user_notifications()@get_user_by_id -> "UPDATE users SET notification_count = notification_count + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --incr);
auto_method!(decr_user_notifications()@get_user_by_id -> "UPDATE users SET notification_count = notification_count - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --decr=notification_count);
auto_method!(set_user_notifications(i32)@get_user_by_id -> "UPDATE users SET notification_count = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_user);
auto_method!(incr_user_follower_count()@get_user_by_id -> "UPDATE users SET follower_count = follower_count + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --incr);
auto_method!(decr_user_follower_count()@get_user_by_id -> "UPDATE users SET follower_count = follower_count - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_user --decr=follower_count);

View file

@ -283,9 +283,10 @@ impl DataManager {
// use changed_count to update user counts
if read == false {
// we don't need to update when marking things as read since that should just be 0
self.set_user_notifications(user.id, changed_count).await?;
self.update_user_notification_count(user.id, changed_count)
.await?;
} else {
self.set_user_notifications(user.id, 0).await?;
self.update_user_notification_count(user.id, 0).await?;
}
// ...

View file

@ -143,6 +143,35 @@ impl DataManager {
res.unwrap()
}
/// Get the owner of all user blocks for the given `receiver`.
pub async fn get_userblocks_initiator_by_receivers(&self, receiver: usize) -> Vec<usize> {
let conn = match self.connect().await {
Ok(c) => c,
Err(_) => return Vec::new(),
};
let res = query_rows!(
&conn,
"SELECT * FROM userblocks WHERE receiver = $1",
&[&(receiver as i64)],
|x| { Self::get_userblock_from_row(x) }
);
if res.is_err() {
return Vec::new();
}
// get owner
let mut out: Vec<usize> = Vec::new();
for b in res.unwrap() {
out.push(b.initiator);
}
// return
out
}
/// Create a new user block in the database.
///
/// # Arguments