mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 00:45:18 +00:00
Can get information about a single comment
This commit is contained in:
@ -12,13 +12,14 @@ use serde::Serialize;
|
||||
use crate::api_data::http_error::HttpError;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::api_client::APIClient;
|
||||
use crate::data::comment::Comment;
|
||||
use crate::data::config::conf;
|
||||
use crate::data::error::{ExecError, ResultBoxError};
|
||||
use crate::data::group::GroupAccessLevel;
|
||||
use crate::data::group_id::GroupID;
|
||||
use crate::data::post::{Post, PostAccessLevel};
|
||||
use crate::data::user::UserID;
|
||||
use crate::helpers::{account_helper, api_helper, conversations_helper, friends_helper, groups_helper, movies_helper, posts_helper, user_helper, virtual_directory_helper};
|
||||
use crate::helpers::{account_helper, api_helper, comments_helper, conversations_helper, friends_helper, groups_helper, movies_helper, posts_helper, user_helper, virtual_directory_helper};
|
||||
use crate::helpers::virtual_directory_helper::VirtualDirType;
|
||||
use crate::utils::pdf_utils::is_valid_pdf;
|
||||
use crate::utils::string_utils::{check_string_before_insert, check_url, remove_html_nodes};
|
||||
@ -585,6 +586,22 @@ impl HttpRequestHandler {
|
||||
Ok(post)
|
||||
}
|
||||
|
||||
/// Get information about a comment whose ID is specified in the request
|
||||
pub fn post_comment_with_access(&mut self, name: &str) -> ResultBoxError<Comment> {
|
||||
let comment_id = self.post_u64(name)?;
|
||||
let comment = self.ok_or_not_found(
|
||||
comments_helper::get_single(comment_id),
|
||||
"Specified comment not found!",
|
||||
)?;
|
||||
|
||||
let post = posts_helper::get_single(comment.post_id)?;
|
||||
if posts_helper::get_access_level(&post, &self.user_id_opt())? == PostAccessLevel::NO_ACCESS {
|
||||
self.forbidden("You are not allowed to access this post informations !".to_string())?;
|
||||
}
|
||||
|
||||
Ok(comment)
|
||||
}
|
||||
|
||||
/// Get the ID of a movie included in the request
|
||||
pub fn post_movie_id(&mut self, name: &str) -> ResultBoxError<u64> {
|
||||
let movie_id = self.post_u64(name)?;
|
||||
|
Reference in New Issue
Block a user