mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Can create YouTube posts
This commit is contained in:
@ -12,7 +12,7 @@ use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::data::post::{Post, PostAccessLevel, PostFile, PostKind, PostPageKind, PostVisibilityLevel};
|
||||
use crate::helpers::{groups_helper, posts_helper, user_helper};
|
||||
use crate::utils::date_utils::time;
|
||||
use crate::utils::string_utils::check_string_before_insert;
|
||||
use crate::utils::string_utils::{check_string_before_insert, check_youtube_id};
|
||||
use crate::utils::user_data_utils::user_data_path;
|
||||
|
||||
impl PostFile {
|
||||
@ -141,6 +141,18 @@ pub fn create_post(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
PostKind::POST_KIND_IMAGE(PostFile::new_from_created_file(&path)?)
|
||||
}
|
||||
|
||||
"youtube" => {
|
||||
let youtube = r.post_string("youtube_id")?;
|
||||
|
||||
if !check_youtube_id(&youtube) {
|
||||
r.bad_request("Invalid YouTube ID!".to_string())?;
|
||||
}
|
||||
|
||||
PostKind::POST_KIND_YOUTUBE(youtube)
|
||||
}
|
||||
|
||||
// TODO : add support for next types
|
||||
|
||||
_ => {
|
||||
r.internal_error(ExecError::boxed_new("Unsupported kind of post!"))?;
|
||||
unreachable!();
|
||||
|
Reference in New Issue
Block a user