add: implement 9 new scopes, 21 new api endpoints

This commit is contained in:
trisua 2025-06-13 17:47:00 -04:00
parent c3139ef1d2
commit 8f16068a34
14 changed files with 973 additions and 35 deletions

View file

@ -136,7 +136,7 @@ impl DataManager {
/// * `id` - the ID of the post the requested posts are commenting on
/// * `batch` - the limit of posts in each page
/// * `page` - the page number
pub async fn get_post_comments(
pub async fn get_replies_by_post(
&self,
id: usize,
batch: usize,
@ -517,6 +517,30 @@ impl DataManager {
out
}
/// Filter to update posts to clean their owner for public APIs.
pub fn posts_owner_filter(&self, posts: &Vec<FullPost>) -> Vec<FullPost> {
let mut out: Vec<FullPost> = Vec::new();
for mut post in posts.clone() {
post.1.clean();
// reposting
if let Some((ref mut x, _)) = post.3 {
x.clean();
}
// question
if let Some((_, ref mut x)) = post.4 {
x.clean();
}
// ...
out.push(post);
}
out
}
/// Get all posts from the given user (from most recent).
///
/// # Arguments

View file

@ -27,7 +27,7 @@ impl DataManager {
}
}
auto_method!(get_user_warning_by_ip(&str)@get_user_warning_from_row -> "SELECT * FROM user_warnings WHERE ip = $1" --name="user warning" --returns=UserWarning --cache-key-tmpl="atto.user_warning:{}");
auto_method!(get_user_warning_by_id(usize)@get_user_warning_from_row -> "SELECT * FROM user_warnings WHERE id = $1" --name="user warning" --returns=UserWarning --cache-key-tmpl="atto.user_warning:{}");
/// Get all user warnings by user (paginated).
///

View file

@ -28,6 +28,18 @@ impl DataManager {
auto_method!(get_userfollow_by_id()@get_userfollow_from_row -> "SELECT * FROM userfollows WHERE id = $1" --name="user follow" --returns=UserFollow --cache-key-tmpl="atto.userfollow:{}");
/// Filter to update userfollows to clean their users for public APIs.
pub fn userfollows_user_filter(&self, x: &Vec<(UserFollow, User)>) -> Vec<(UserFollow, User)> {
let mut out: Vec<(UserFollow, User)> = Vec::new();
for mut y in x.clone() {
y.1.clean();
out.push(y);
}
out
}
/// Get a user follow by `initiator` and `receiver` (in that order).
pub async fn get_userfollow_by_initiator_receiver(
&self,