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

@ -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