mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 01:24:04 +00:00 
			
		
		
		
	Add support for movie posts
This commit is contained in:
		@@ -10,4 +10,5 @@ pub mod likes_helper;
 | 
			
		||||
pub mod groups_helper;
 | 
			
		||||
pub mod posts_helper;
 | 
			
		||||
pub mod conversations_helper;
 | 
			
		||||
pub mod virtual_directory_helper;
 | 
			
		||||
pub mod virtual_directory_helper;
 | 
			
		||||
pub mod movies_helper;
 | 
			
		||||
							
								
								
									
										27
									
								
								src/helpers/movies_helper.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/helpers/movies_helper.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
//! # Movies helper
 | 
			
		||||
//!
 | 
			
		||||
//! @author Pierre Hubert
 | 
			
		||||
 | 
			
		||||
use crate::constants::database_tables_names::MOVIES_TABLE;
 | 
			
		||||
use crate::data::error::ResultBoxError;
 | 
			
		||||
use crate::data::movie::Movie;
 | 
			
		||||
use crate::helpers::database;
 | 
			
		||||
 | 
			
		||||
/// Get information about a single movie
 | 
			
		||||
pub fn get_info(movie_id: u64) -> ResultBoxError<Movie> {
 | 
			
		||||
    database::QueryInfo::new(MOVIES_TABLE)
 | 
			
		||||
        .cond_u64("ID", movie_id)
 | 
			
		||||
        .query_row(db_to_movie)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Turn a database entry into a movie object
 | 
			
		||||
fn db_to_movie(row: &database::RowResult) -> ResultBoxError<Movie> {
 | 
			
		||||
    Ok(Movie {
 | 
			
		||||
        id: row.get_u64("ID")?,
 | 
			
		||||
        user_id: row.get_user_id("ID_user")?,
 | 
			
		||||
        name: row.get_str("nom_video")?,
 | 
			
		||||
        uri: row.get_str("URL")?,
 | 
			
		||||
        file_type: row.get_str("file_type")?,
 | 
			
		||||
        size: row.get_usize("size")?,
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
use crate::constants::database_tables_names::POSTS_TABLE;
 | 
			
		||||
use crate::data::error::{ExecError, ResultBoxError};
 | 
			
		||||
use crate::data::post::{Post, PostFile, PostKind, PostPageKind, PostVisibilityLevel, PostWebLink};
 | 
			
		||||
use crate::data::post::PostKind::{POST_KIND_IMAGE, POST_KIND_PDF, POST_KIND_WEBLINK};
 | 
			
		||||
use crate::data::post::PostKind::{POST_KIND_IMAGE, POST_KIND_MOVIE, POST_KIND_PDF, POST_KIND_WEBLINK};
 | 
			
		||||
use crate::data::user::UserID;
 | 
			
		||||
use crate::helpers::{database, friends_helper};
 | 
			
		||||
use crate::utils::date_utils::time;
 | 
			
		||||
@@ -170,6 +170,8 @@ fn db_to_post(res: &database::RowResult) -> ResultBoxError<Post> {
 | 
			
		||||
 | 
			
		||||
        "pdf" => post.kind = POST_KIND_PDF(file?),
 | 
			
		||||
 | 
			
		||||
        "video" => post.kind = POST_KIND_MOVIE(res.get_u64("idvideo")?),
 | 
			
		||||
 | 
			
		||||
        _ => {}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user