1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 23:39:22 +00:00

Add countdown timer posts support

This commit is contained in:
Pierre HUBERT 2020-07-03 17:13:02 +02:00
parent d632d0b888
commit 1e956cdcb5
3 changed files with 16 additions and 5 deletions

View File

@ -37,6 +37,9 @@ pub struct PostAPI {
// Movie specific // Movie specific
video_id: Option<u64>, video_id: Option<u64>,
video_info: Option<MovieAPI>, video_info: Option<MovieAPI>,
// Countdown timer specific
time_end: Option<u64>,
} }
impl PostAPI { impl PostAPI {
@ -67,6 +70,9 @@ impl PostAPI {
// Movie specific // Movie specific
video_id: None, video_id: None,
video_info: None, video_info: None,
// Countdown timer-specific
time_end: None,
}; };
match &p.kind { match &p.kind {
@ -91,7 +97,8 @@ impl PostAPI {
post.video_info = Some(MovieAPI::new(&movies_helper::get_info(*movie_id)?)) post.video_info = Some(MovieAPI::new(&movies_helper::get_info(*movie_id)?))
} }
PostKind::POST_KIND_COUNTDOWN => {} PostKind::POST_KIND_COUNTDOWN(time_end) => post.time_end = Some(*time_end),
PostKind::POST_KIND_SURVEY => {} PostKind::POST_KIND_SURVEY => {}
PostKind::POST_KIND_YOUTUBE => {} PostKind::POST_KIND_YOUTUBE => {}
} }

View File

@ -56,8 +56,10 @@ pub enum PostKind {
POST_KIND_IMAGE(PostFile), POST_KIND_IMAGE(PostFile),
POST_KIND_WEBLINK(PostWebLink), POST_KIND_WEBLINK(PostWebLink),
POST_KIND_PDF(PostFile), POST_KIND_PDF(PostFile),
POST_KIND_MOVIE(u64), // The ID of the movie POST_KIND_MOVIE(u64),
POST_KIND_COUNTDOWN, // The ID of the movie
POST_KIND_COUNTDOWN(u64),
// End time
POST_KIND_SURVEY, POST_KIND_SURVEY,
POST_KIND_YOUTUBE, POST_KIND_YOUTUBE,
} }
@ -70,7 +72,7 @@ impl PostKind {
PostKind::POST_KIND_WEBLINK(_) => "weblink", PostKind::POST_KIND_WEBLINK(_) => "weblink",
PostKind::POST_KIND_PDF(_) => "pdf", PostKind::POST_KIND_PDF(_) => "pdf",
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_IMAGE, POST_KIND_MOVIE, POST_KIND_PDF, POST_KIND_WEBLINK}; use crate::data::post::PostKind::{POST_KIND_COUNTDOWN, POST_KIND_IMAGE, POST_KIND_MOVIE, POST_KIND_PDF, POST_KIND_WEBLINK};
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;
@ -172,6 +172,8 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError<Post> {
"video" => post.kind = POST_KIND_MOVIE(res.get_u64("idvideo")?), "video" => post.kind = POST_KIND_MOVIE(res.get_u64("idvideo")?),
"count_down" => post.kind = POST_KIND_COUNTDOWN(res.get_u64("time_end").unwrap_or(0)),
_ => {} _ => {}
} }