1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-01-30 14:03:00 +00:00

Add YouTube posts support

This commit is contained in:
Pierre HUBERT 2020-07-04 17:06:06 +02:00
parent 8d5013b00a
commit 532bd9e48d
3 changed files with 9 additions and 4 deletions

View File

@ -109,7 +109,10 @@ impl PostAPI {
PostKind::POST_KIND_SURVEY => PostKind::POST_KIND_SURVEY =>
post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, user.clone())?), post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, user.clone())?),
PostKind::POST_KIND_YOUTUBE => {} PostKind::POST_KIND_YOUTUBE(id) => {
post.file_path = Some(id.clone());
post.file_type = Some("youtube".to_string());
}
} }
Ok(post) Ok(post)

View File

@ -61,7 +61,7 @@ pub enum PostKind {
POST_KIND_COUNTDOWN(u64), POST_KIND_COUNTDOWN(u64),
// End time // End time
POST_KIND_SURVEY, POST_KIND_SURVEY,
POST_KIND_YOUTUBE, POST_KIND_YOUTUBE(String),
} }
impl PostKind { impl PostKind {
@ -74,7 +74,7 @@ impl PostKind {
PostKind::POST_KIND_MOVIE(_) => "movie", PostKind::POST_KIND_MOVIE(_) => "movie",
PostKind::POST_KIND_COUNTDOWN(_) => "countdown", PostKind::POST_KIND_COUNTDOWN(_) => "countdown",
PostKind::POST_KIND_SURVEY => "survey", PostKind::POST_KIND_SURVEY => "survey",
PostKind::POST_KIND_YOUTUBE => "youtube", PostKind::POST_KIND_YOUTUBE(_) => "youtube",
}.to_string() }.to_string()
} }
} }

View File

@ -5,7 +5,7 @@
use crate::constants::database_tables_names::POSTS_TABLE; use crate::constants::database_tables_names::POSTS_TABLE;
use crate::data::error::{ExecError, ResultBoxError}; use crate::data::error::{ExecError, ResultBoxError};
use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink}; use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink};
use crate::data::post::PostKind::{POST_KIND_COUNTDOWN, POST_KIND_IMAGE, POST_KIND_MOVIE, POST_KIND_PDF, POST_KIND_SURVEY, POST_KIND_WEBLINK}; use crate::data::post::PostKind::{POST_KIND_COUNTDOWN, POST_KIND_IMAGE, POST_KIND_MOVIE, POST_KIND_PDF, POST_KIND_SURVEY, POST_KIND_WEBLINK, POST_KIND_YOUTUBE};
use crate::data::user::UserID; use crate::data::user::UserID;
use crate::helpers::{database, friends_helper}; use crate::helpers::{database, friends_helper};
use crate::utils::date_utils::time; use crate::utils::date_utils::time;
@ -176,6 +176,8 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError<Post> {
"sondage" => post.kind = POST_KIND_SURVEY, "sondage" => post.kind = POST_KIND_SURVEY,
"youtube" => post.kind = POST_KIND_YOUTUBE(res.get_str("path")?),
_ => {} _ => {}
} }