1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-22 01:15:16 +00:00

Can create movie posts

This commit is contained in:
2020-07-08 14:01:40 +02:00
parent 45c70cb40e
commit aafd4c5e7c
4 changed files with 30 additions and 1 deletions

View File

@ -23,6 +23,11 @@ pub fn get_info(movie_id: u64) -> ResultBoxError<Movie> {
.query_row(db_to_movie)
}
/// Check out whether a user own a movie or not
pub fn does_user_has(user_id: &UserID, movie_id: u64) -> ResultBoxError<bool> {
Ok(get_info(movie_id).map(|m| &m.user_id == user_id).unwrap_or(false))
}
/// Turn a database entry into a movie object
fn db_to_movie(row: &database::RowResult) -> ResultBoxError<Movie> {
Ok(Movie {

View File

@ -90,6 +90,11 @@ pub fn create(p: &Post) -> ResultBoxError<u64> {
.add_str("type", "youtube");
}
// Movie post
POST_KIND_MOVIE(id) => {
insert_query = insert_query.add_u64("idvideo", *id);
}
_ => unimplemented!()
/*
POST_KIND_WEBLINK(_) => {},